Inputs

To document your code, MrDocs needs to know where the source lives and how to compile it. The options on this page answer both questions. The Inputs reference lists every option with its default.

Pointing at your code

source-root is the base MrDocs uses to form the per-file paths that link each symbol page back to the source file it lives in (combined with base-url, those paths become full URLs to your repository host). It defaults to the directory holding mrdocs.yml. The example sets source-root: .. so the resulting paths are anchored at the repository root.

docs/mrdocs.yml
## Pattern: handwritten compilation database, no build system.
source-root: ..
compilation-database: compile_commands.json
compilation-database is the option that determines how MrDocs compiles your code. Basic Usage Patterns walks through complete starter projects. Pick the one closest to your project.

If MrDocs is invoking CMake on your behalf (the compilation-database value points at a CMakeLists.txt), cmake passes extra arguments through to that CMake invocation — for example '-D MY_PROJECT_TESTS=OFF' to silence test targets while configuring for the docs build.

Extra includes and defines

The compilation database carries most of the flags MrDocs needs, but you can add to them. includes and system-includes add directories to the header search path, and defines adds preprocessor definitions to every entry in the database.

docs/mrdocs.yml
source-root: ..
input:
  - ../include
includes:
  - ../external
defines:
  - LIB_BUILD
include/lib/api.hpp
#ifdef LIB_BUILD
#include <extlib/types.h>

namespace lib {
/** Use an external widget from `extlib`. */
extlib::widget make_widget();
}
#endif
external/extlib/types.h
namespace extlib { struct widget {}; }

These options are usually the first to reach for when MrDocs reports that a header cannot be found.

Standard library headers

For the C and C++ standard libraries, MrDocs can use the headers installed on your system or the ones it bundles for reproducible results. use-system-stdlib and use-system-libc pick between the two; stdlib-includes and libc-includes say where the bundled headers live.