Running ex_doc for a Phoenix web application

So I have a Phoenix web application in progress. I am able to generate documentation for my codebase using the ex_doc tool – when I run mix docs I get the documentation output into the doc/ folder.

I can then open this doc/ folder, double click on index.html, and view these docs in my browser at file:///Users/jon/myapp/doc/api-reference.html (because index.html just redirects to api_reference.html).

However, I would like these docs to be part of my Phoenix web application – in other words, I would like them available in production at the domain where my app is running. So if my app is running at myapp.com, then I would like to be able to see the docs at a URL like myapp.com/doc/index.html

Also, the documentation for ex_doc (ExDoc — ex_doc v0.25.2) instructs me to include the following in my mix.exs file:

def deps do
[
{:ex_doc, “~> 0.24”, only: :dev, runtime: false},
]
end

I’m curious what the runtime: false option does.

Thanks.

1 Like

runtime: false means the package will not be available in production. Combined with only: :dev means the package is available in development mode. This means you can generate the documentation only in the development and the build phase and the package won’t be available when the app is running in production mode.

You shouldn’t need ex_doc in production. There are few ways to generate documentation e.g. when building a release. Make sure the doc/ folder is retained with the release (overlay or copy into priv/) and then you can serve the docs using Plug.Static within phoenix.