Ex_doc, how to configure so it lands in the README.md?

How do you configure the docs section of the mix.exs file so that ex_doc produces a hexdocs.pm page that directly lands in its representation of the README.md instead of the main module?

Phoenix does it, but I can’t figure out how…

You’re looking for the main option of ex_doc.

1 Like

A tip: if you are ever curious about how another project/library has their generated HexDocs set up, look for their docs config in mix.exs. I often find myself using these as a reference.

2 Likes

Also, the module doc, e.g. Vapor:

defmodule Vapor do
  @moduledoc "README.md"
             |> File.read!()
             |> String.split("<!-- MDOC !-->")
             |> Enum.fetch!(1)
5 Likes

Wow that one is pretty interesting, will definitely try… thanks!

You can also mark the external file with @external_resource so the docs will be regenerated when the README changed.

There is a very good article convering all this: AppSignal - Livebook for Elixir: Just What the Docs Ordered

4 Likes