Extracts documentation from compiled modules through the BEAM docs chunk.
This reads the same Docs chunk used by IEx and ExDoc, then extracts English
documentation and normalizes its metadata for JSON. Modules must be compiled
and loadable; mix doc_shell.build arranges this inside the host application.
Source files are not required once their BEAM documentation is available.
Each module becomes one entry:
%{
"id" => "MyApp.Accounts",
"title" => "MyApp.Accounts",
"kind" => "module",
"ast" => [...],
"meta" => %{
"module" => "MyApp.Accounts",
"language" => "elixir",
"moduledoc" => "present",
"members" => [...]
}
}ast is the module documentation parsed by DocShell.Ast. members lists
every documented function, macro, callback, and type with its kind, name,
arity, signatures, raw documentation, and metadata such as since or
deprecated. Member documentation is left as Markdown text rather than
parsed, because a page usually renders a member list lazily and parsing every
member of every module up front is work most renderers throw away.
Modules without documentation
A module compiled with --no-docs, or from Erlang without a chunk, is
skipped rather than treated as an error — extract/1 simply omits it. A
module that has a chunk but fails to read is an error, tagged with the module
name.
Modules that have a chunk but no prose are a different case, and they are
deliberately still returned, with an empty ast. meta["moduledoc"] says
which situation each one is in:
"present"— the module has documentation"hidden"— the author wrote@moduledoc false"none"— no@moduledocat all
Extraction stays complete because callers use it for more than rendering: a documentation-coverage report needs the undocumented modules precisely because they are undocumented, and dropping them here would make every codebase look fully documented.
Filtering for display happens later, in
DocShell.Presentation.StaticGenerator, which skips empty entries by
default so mix doc_shell.build does not fill a navigation tree with
internal modules that opted out.
Modules are sorted by name so the artifact is stable across builds.
Summary
Functions
Extracts documentation for a list of compiled modules.
Modules without a documentation chunk are omitted. Modules with hidden or
absent moduledocs are retained with empty ASTs and a metadata status. The
first read failure returns {:error, {module, reason}}.
Extracts one compiled module.
Returns {:ok, nil} when the module carries no docs chunk, which callers
treat as "nothing to document" rather than as a failure.