Back to templates

Template details

ExDoc

ExDoc generates HTML, EPUB, and Markdown documentation for Erlang and Elixir projects.

About this template

ExDoc is a documentation generator for Erlang and Elixir projects that compiles API documentation into offline-accessible HTML, Markdown (including llms.txt), and EPUB output, and it is the tool behind Elixir's official docs on HexDocs.

What is ExDoc?

ExDoc is an open-source tool maintained under the elixir-lang GitHub organization, built for creating documentation sites from Elixir @moduledoc / @doc attributes or Erlang EDoc annotations. It takes compiled .beam files in ebin directories as input, plus optional extras such as README.md files, .cheatmd cheatsheets, and .livemd livebooks, and produces searchable HTML, EPUB, Markdown, and llms.txt output. You can run it via Mix for Elixir projects, via Rebar3 for Erlang projects, or as a standalone escript from the command line.

Key Features

  • Multiple output formats — Generates offline-accessible HTML, Markdown (including llms.txt), and EPUB documents automatically.
  • Custom pages and guides — Supports Markdown extras, .cheatmd cheatsheets, and .livemd Livebooks as additional documentation pages.
  • Full-text search and shortcuts — Built-in full-text search, quick-search with autocompletion (s shortcut), and a g shortcut to jump to any HexDocs package documentation.
  • Source linking — Provides a direct link back to the source code for every documented entity.
  • Responsive and accessible — Responsive design for phones and tablets, with night mode that follows browser preferences.
  • Tooltips for links — Shows tooltips for module and function links, both within the current project and across other projects.
  • Syntax highlighting via Makeup — Elixir and Erlang highlighters are included by default; you can add other makeup_LANGUAGE packages, for example makeup_html, to highlight more languages.
  • Extension hooks — Lets you inject custom HTML into every page via before_closing_head_tag and before_closing_body_tag configuration, and listen for the exdoc:loaded JavaScript event.

Who is it for?

  • Elixir library authors — Add ExDoc as a dev dependency and run mix docs to generate a documentation site with version dropdown and "Go to latest" notifications when hosted on HexDocs.
  • Erlang library authors — Use ExDoc via rebar3_ex_doc (for OTP 24 and later) to render EDoc-written documentation into HTML and EPUB.
  • Open-source maintainers — Publish project documentation to HexDocs with automatic metadata pulled in from the project, including application name, version, source URL, and homepage URL.
  • Technical writers — Add tutorials as .livemd Livebooks, quick-reference cheatsheets as .cheatmd, and long-form guides as Markdown extras.

What can you do with ExDoc?

  • Elixir developers: run mix docs after adding the ex_doc Hex package to your dependencies, then customize output with :name, :source_url, :homepage_url, and docs: [main: ..., logo: ..., extras: [...]] options.
  • Erlang developers: invoke the standalone ex_doc escript with project name, version, and one or more ebin directories, and optionally point to a main module and source URL.
  • Umbrella project maintainers: pass multiple ebin directories to the CLI so modules are grouped by application, and override that grouping with a custom groups_per_modules option.
  • Doc site customizers: set before_closing_head_tag and before_closing_body_tag to inject JavaScript for rendering TeX math with KaTeX, Vega-Lite plots, or Mermaid graphs.

How does ExDoc work?

Add ExDoc as a Mix dependency (requires Elixir v1.15 or later), or install it as an escript with mix escript.install hex ex_doc. Document your modules and functions using @moduledoc, @doc, and metadata keys like since and deprecated, or use Erlang EDoc annotations. Run mix docs or the ex_doc executable with your project details, and ExDoc reads the compiled ebin directories, parses the documentation, renders all Markdown content, and outputs the final HTML, EPUB, and Markdown files to the doc directory.

Pros and cons

  • Pros: Free and open source under the Apache 2 License; outputs three formats; supports custom pages, grouping, search, and keyboard shortcuts.
  • Cons: Mix usage requires Elixir v1.15 or later; at least one dependency (earmark_parser) needs the Erlang development environment (for example, erlang-dev on Debian); any documentation generated by ExDoc or derivative works must display a visible link back to the ExDoc repository.

Alternatives

EDoc is the built-in Erlang documentation generator; ExDoc can read EDoc annotations and render them into more modern output. HexDocs is the hosting platform where ExDoc-generated docs are commonly published.

FAQ

Is ExDoc free?

Yes, the ExDoc source code is released under the Apache 2 License, and you can use it without cost. The generated documentation must follow the license's attribution requirement by linking back to the ExDoc repository.

What Elixir version does ExDoc require?

For Mix usage, ExDoc requires Elixir v1.15 or later. Erlang projects on OTP 24 and above can use ExDoc through rebar3_ex_doc or the CLI.

Can ExDoc generate documentation for Erlang projects?

Yes, ExDoc supports Erlang projects. You can use the standalone ex_doc escript or the rebar3_ex_doc plugin with OTP 24+, and it will render documentation written with EDoc annotations.

How do I add extra pages to my docs?

Set the :extras option in your project config to a list of file paths. Supported formats include Markdown (.md), cheatsheets (.cheatmd), and Livebooks (.livemd), which will appear alongside the API reference.

Does ExDoc support syntax highlighting for languages other than Elixir and Erlang?

Yes, ExDoc uses the Makeup project for highlighting. You can add the corresponding makeup_LANGUAGE package, such as makeup_html or makeup_css, to your Mix or Rebar3 dependencies, and those languages will be highlighted.

screenshot of ExDoc on template0.com