Skip to Content
Introducing Elixir, 2nd Edition
book

Introducing Elixir, 2nd Edition

by Simon St. Laurent, J. David Eisenberg
January 2017
Beginner
248 pages
5h 23m
English
O'Reilly Media, Inc.
Content preview from Introducing Elixir, 2nd Edition

Appendix B. Generating Documentation with ExDoc

In Chapter 2, you learned how to add documentation to your programs. The ExDoc tool takes that documentation and produces nicely formatted reference documentation in web page format. ExDoc works in conjunction with Mix, a tool for creating, compiling, and testing projects. You can find out more about Mix in Chapter 13.

Using ExDoc with Mix

The easiest way to create documentation is to create a project using the Mix tool, using a command of the form:

mix new project_name

Here is what it looks like when creating the documentation for the code in Example 2-4:

$ mix new combined
* creating README.md
* creating .gitignore
* creating mix.exs
* creating lib
* creating lib/combined.ex
* creating test
* creating test/test_helper.exs
* creating test/combined_test.exs

Your mix project was created successfully.
You can use "mix" to compile it, test it, and more:

    cd combined
    mix test

Run "mix help" for more commands.

Change to the combined directory and put all of your source files (for this example, combined.ex, drop.ex, and convert.ex) into the lib directory. The combined.ex file you wrote before will replace the one that Mix created for you in the lib directory.

Now edit the file mix.exs so that the deps function reads as follows:

def deps do
  [{:ex_doc, github: "elixir-lang/ex_doc}]
end

Typing mix deps.get will install ExDoc in a directory named deps. If you have not yet installed Hex (Elixir’s package manager), Mix will prompt you to ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Elixir in Action, Second Edition

Elixir in Action, Second Edition

Sasa Juric

Publisher Resources

ISBN: 9781491956847Errata Page