trivelop @rrrene on

Continous Documentation of Elixir packages with Hex and Travis CI

So you can now publish the docs for your Elixir package with

$ mix

That’s it. That is crazy simple. One command and they are online. But we can make it even simpler: Let’s delegate the publishing duties to Travis CI.

There are two things we have to do for that: Configure our Hex account in the Travis build and advise Travis to publish our docs for us.

The rest of the post assumes you have published docs for a Hex package before. If you haven’t, please read this introduction.

1. Putting your Hex credentials into Travis

First, we have to retrieve the information we want to put into our Travis builds:

$ mix hex.config username

$ mix hex.config key

These are our username and password for interacting with Hex. We will use these to tell Travis to publish our docs.

Next, we go to our repo’s Travis page and into “Settings” and then click the tab “Environment Variables”. Here, we add two variables: HEX_USERNAME and HEX_KEY with the output we got above (minus the quotes):

Inch CI

2. Configuring Travis to do our job

Finally, we have to modify .travis.yml and add an after_script: section:

language: erlang
  - 17.1
  - wget
  - unzip -d elixir
  - export PATH=`pwd`/elixir/bin:$PATH
  - mix local.hex --force
  - mix deps.get
script: mix test
  - mix hex.config username $HEX_USERNAME
  - mix hex.config key $HEX_KEY
  - mix

This publishes our docs with the username/key combination we configured, continously.

Using worker:


Docs successfully generated.
View them at "docs/index.html".
[#########################] 100%
Published docs for inch_test v0.0.1
Hosted at
Done. Your build exited with 0.

If you like, let’s have a chat about this on Twitter.

Fork me on GitHub