ExDoc.Formatter.JSON (ExDocJSON v0.3.0)

Copy Markdown View Source

Generates JSON documentation for Elixir and Erlang projects.

The formatter writes a single <project name>.json file (the project name is downcased) to the configured output directory.

Top-level information

  • about - Indicates the version of the JSON structure format.
  • name - Project name
  • version - Project version
  • description - Project summary description
  • homepage_url - Specifies the project's home page
  • source_url - Specifies the project's source code location
  • language - Identifies the primary language of the documents.
  • icon - Path to the project's logo, as given in the :logo option
  • items - This JSON object contains modules, exceptions, protocols, behaviours, Mix tasks, and extras details.

Modules, Exceptions, Protocols, Behaviours, and Mix tasks

Each component is an array of objects that include:

  • id - Module identifier, as used by ExDoc in file names and links
  • module - Module name
  • title - Module title
  • nested_title - Module title when nested under a prefix, see the :nest_modules_by_prefix option
  • nested_context - The prefix the module is nested under
  • group - Specifies the group, see the :groups_for_modules option
  • type - Specifies if the component is a module, exception, etc.
  • language - The ExDoc language module used to extract the documentation
  • deprecated - Deprecation reason, if any
  • annotations - Module annotations
  • doc_format - Format of the documentation, such as text/markdown
  • source_doc - Module documentation, in its source format, by language (for instance {"en": "..."}); "none" or "hidden" otherwise
  • doc_line - Line number where the module documentation starts
  • source_path - Path to the source code file in the project
  • source_url - URL to the source code
  • docs_groups - Titles of the groups that have members, in display order
  • docs - Functions, macros, and callbacks
  • typespecs - Types

Function, callback, and type details

  • id - Identifier, unique within the module, such as "example/2", "c:handle_call/3" or "t:t/0"
  • name - Name
  • arity - Arity
  • type - Specifies if it is a function, macro, callback, type, etc.
  • signature - Indicates the signature
  • defaults - The other arities generated by default arguments, as a list of {"name": ..., "arity": ...} objects
  • group - Title of the group it belongs to
  • deprecated - Deprecation reason, if any
  • annotations - Annotations, such as since 1.3.0 or macro
  • source_doc - Documentation, in the same shape as the module one
  • doc_line - Line number where the documentation starts
  • source_path - Path to the file where the documentation is defined
  • source_url - URL to the source code

Extras

Each extra page is an object with the following fields:

  • id - Identifier
  • title - Document title
  • group - Specifies the group
  • type - Kind of page: extra, cheatmd, livemd or url
  • source - The document content in the source format
  • source_path - Path of the original document
  • source_url - URL of the original document

Extras that link to an external URL have id, title, group, type (always url), and url instead.

Autolinking

This formatter exports the documentation in its source format, so it deliberately does not implement the optional ExDoc.Formatter.autolink_options/0 callback. That lets ExDoc skip the autolinking and syntax highlighting passes, by far the most expensive steps of documentation generation.