trivelop @rrrene on

Inch CI: Can I have Elixir badge?

The short answer is: Yes. After the release of version 0.5.0, we now have multi-language support in Inch and therefore Inch CI badges for Elixir were in reach.

The great news is: The Phoenix Framework accepted my proposal to include a docs badge in its README and both Chris McCord and José Valim were supportive of the idea.

This is how the badge looks like:

Inline docs

It shows an assessment of the inline-docs of a project. Its intention is to show aspiring Elixirists (is that a word?) that documentation is a first class citizen in Elixir. It does not display coverage numbers, but gives visitors a visual feedback that your project is not completely undocumented (it is more like “Yep, there seems to be a nice amount of docs” rather than “61.5% documented”).

You can read about why Inch does not use percentages and the value of the docs badge for maintainers in earlier posts.

Okay, now how can I add my own project?

Building Elixir projects for Inch CI relies on your testing CI server to compile your Elixir app. Typically this will be Travis, so let me show you how it is done:

First, you have to include inch_ex in your dependencies in the mix.exs file:

  defp deps do
    [{:inch_ex, only: docs}]
  end

Your .travis.yml might look something like this:

  language: erlang
  otp_release:
    - 17.1
  before_install:
    - wget http://s3.hex.pm/builds/elixir/v1.0.0.zip
    - unzip -d elixir v1.0.0.zip
  before_script:
    - export PATH=`pwd`/elixir/bin:$PATH
    - mix local.hex --force
    - mix deps.get --only test
  script: mix test

Simply add the following at the end of the file:

  after_script:
    - MIX_ENV=docs mix do deps.get, inch.report

What this does is that your docs are evaluated at the end of your next Travis build. Travis sends a report to Inch CI which then displays the results here (and generates a new badge for you).

Feedback on all of this is always welcome. Reach out via Twitter, create an issue in the Inch CI project or simply email me (mail in Github profile).

Fork me on GitHub