The Configuration File

MrDocs uses a configuration file to control how the documentation is generated. The file is used to specify options such as the generator to use, additional compilation options, and filters.

Here’s an example of a configuration file:

source-root: ../include
multipage: false
generate: adoc

The Usage page provides a detailed explanation of what to combine options from the configuration file and the command line. The Reference section provides a detailed explanation of the options available.

Build Options

A number of options can be used to specify with which compile options MrDocs should be run.

source-root: ..
compilation-database: ../CMakeLists.txt
cmake: '-D MRDOCS_BUILD=ON'
defines: 'MRDOCS_BUILD'

The compile options primarily come from the compilation-database file. When this file is generated from a CMakeLists.txt script, the cmake option can be used to specify additional options to pass to CMake.

Additionally, the defines option can be used to specify preprocessor definitions that should be used when generating the documentation. These definitions are included in all targets of the compilation database.

Generators

MrDocs supports multiple output formats that can be specified via the generate option:

Format Description

adoc

AsciiDoc format.

html

HTML format.

xml

XML format.

  • Asciidoc is a text-based format that is easy to read and write. It can also be converted to other formats such as HTML and Markdown.

  • HTML can be generated directly with the html format.

  • XML is a structured format that can be used in tests or as an intermediary format for other tools.

The generate option can be used to specify the output format:

# ...
generate: adoc
# ...

Generator Templates

MrDocs attempts to support various alternatives for customizing the output format and style without complex workflows to post-process XML output. For the Asciidoc and HTML generators, the desired customization can usually be achieved by modifying the templates used to generate the output.

In the root of the installation directory, you will find the share/mrdocs/addons/generator directory. This directory contains the templates used to generate the documentation with the markup formats. Users can create a copy of these files and provide their own addons directory via the addons option. This allows users to customize the output format to their needs.

addons: /path/to/custom/addons

One advantage of custom templates over post-processing XML files is the ability to access symbols as a graph. If symbol A refers to symbol B, some properties of symbol B are likely to be required in the documentation of A. All templates and generators can access a reference to B by searching the symbol tree or simply by accessing the elements A refers to.

Filters

Symbol Filters

Not all symbols in a project may be relevant to the documentation. MrDocs provides a way to filter out symbols based on their names.

filters:
  symbols: (1)
    exclude: (2)
    include: (3)
1 Optional symbols key
2 Optional exclude key
3 Optional include key

Symbol filter patterns are specified using (optionally) qualified names, and may contain wildcards:

filters:
  symbols:
    exclude:
      - 'A::B'
      - 'A::f*'

If a symbol matches a pattern in the exclude list, that symbol and its members will not be extracted:

filters:
  symbols:
    exclude:
      - 'A'
// ok, does not match any excluded pattern
void f0();

namespace A // matches the pattern 'A', will not be extracted
{
    // enclosing namespace matches an excluded pattern:
    // the symbol will not be extracted
    void f1();
}

The filters.symbols.include key can be used to override the exclude list for specific symbols. A symbol which matches an included pattern and an excluded pattern will be extracted.

This permits fine-grained control of extraction for individual members of a class or namespace:

filters:
  symbols:
    exclude:
      - 'A'
    include:
      - 'A::g*'
namespace A
{
    // enclosing namespace matches an excluded pattern, will not be extracted
    void f0();

    // ok, matches the pattern 'A::g*' which overrides the exclude list
    void g0();
}

In order for a filter pattern to match a symbol, it must consist of simple identifiers that match the name as written in its declaration: namespace aliases, typedef-names, and decltype specifiers naming the symbol cannot be used.

Specifying include patterns is only useful when the pattern would match a subset of symbols matched by an exclude pattern. An include pattern without a subsuming exclude pattern will be ignored.

File Filters

Symbols can also be filtered based on the files they are declared in. This can be useful for excluding files that exclusively contain implementation details or test code.

input:
  include:
      - ../include  (1)
  file-patterns:
      - *.hpp       (2)
1 A list of directories to include. Only symbols defined in these files will be extracted.
2 A list of file patterns to include. Only symbols defined in files matching these patterns will be extracted.

Private Symbols

The implementation-detail and see-below options can be used to designate namespaces as implementation detail namespaces.

implementation-detail: 'impl'
see-below: 'see_below'

If a namespace is designated as an implementation detail namespace, all symbols within that namespace will be marked as implementation details in the documentation.

namespace impl
{
    class A {};
}

/// @brief A foo function
A foo();

The impl namespace is designated as an implementation detail namespace, so all symbols within it will be marked as implementation details in the documentation. This means the symbol A would not be documented and the function foo could be documented as follows:

/* implementation detail */ foo();

On the other hand, if a namespace is designated as a see_below namespace, all symbols within that namespace will be marked as "see below" in the documentation.

namespace see_below
{
    class B {};
}

In the documentation, the symbol B would be marked as "see-below" and could be documented as:

class B { /* see below */ };

Reference

Command Line Options

The following options can be used to control the general behavior of MrDocs and can only be provided via the command line:

Name Description

inputs

Configuration or compilation database files

config

Configuration file: mrdocs.yml

concurrency

The desired level of concurrency: 0 for hardware-suggested

  • Any argument provided to MrDocs without a key is treated as one path in inputs. These can be paths to the configuration file config, the compilation-database (compilation database or build scripts), or the source-root directory. See the Common Options section for more information on these options.

  • The config option can be used to explicitly specify a configuration file. Any path in inputs whose filename is mrdocs.yml will also be used as the configuration file. If no configuration file is provided via inputs or config, MrDocs will attempt to find mrdocs.yml in the current directory.

The config path is interpreted relative to the current working directory by MrDocs. All other path options are interpreted relative to the mrdocs.yml configuration file.

Common Options

The following options can be defined both in the configuration file and on the command line, where the command line options always take precedence.

Name Description

source-root

Path to the root directory of the source code

output

Directory or file for generating output

compilation-database

Path to the compilation database or a build script to generate it

cmake

CMake arguments when generating the compilation database from CMakeLists.txt

defines

Additional defines passed to the compiler

generate

Documentation generator. Supported generators are: adoc/html/xml

addons

Path to the Addons directory

multipage

True if output should consist of multiple files

base-url

Base URL for links to source code

referenced-declarations

Extraction policy for references to external declarations

anonymous-namespaces

Extraction policy for anonymous namespace

inaccessible-members

Extraction policy for inaccessible members

inaccessible-bases

Extraction policy for inaccessible bases

see-below

Namespace for symbols rendered as "see-below"

implementation-defined

Namespace for symbols rendered as "implementation-defined"

input.include

Input directories to include

input.file-patterns

Input file patterns

filters.symbols.include

Specifies symbol inclusion patterns

filters.symbols.exclude

Specifies symbol exclusion patterns

verbose

True if more information should be output to the console

report

The minimum reporting level: 0 to 4

ignore-map-errors

Continue if files are not mapped correctly

ignore-failures

Whether AST visitation failures should not stop the program

detect-sfinae

Whether to detect the SFINAE idiom