Assure Fortran documentation consistency.
fordoctest uses FORD to parse a Fortran
project and reports entities that are missing documentation. It is the Fortran
counterpart of tools such as pydoctest.
pip install fordoctest
For development:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements_dev.txtfordoctest <ford_project_file> [ford_flags] fordoctest <fpm.toml or fpm project directory>
Examples:
fordoctest doc/doc.md fordoctest fpm.toml fordoctest --max-modules 2 doc/doc.md fordoctest --check-imperative doc/doc.md fordoctest --color always doc/doc.md
FORD options such as -d, -m, --exclude and --config are forwarded to
FORD when a markdown project file is used. Run fordoctest --help for the
fordoctest-specific options.
Output is colourised automatically when the terminal supports it. Use
--color always or --color never to force it, or set NO_COLOR to disable
colour in auto mode.
| Code | Meaning |
|---|---|
| 0 | All checks passed |
| 1 | At least one documentation issue was found |
| 2 | The project could not be loaded or the arguments were invalid |
Issues are written to standard error, one per line.
For a FORD markdown project file, use the usual FORD metadata block:
project: My project src_dir: src preprocess: false
For an fpm project, FORD settings can be placed in the [extra.ford] table of
fpm.toml. Without that table, fordoctest checks the standard fpm source
directories (src, app, test, example, examples and benchmark).
Tool-specific options can be stored in [extra.fordoctest]. The historical
spelling [extra.fordoxtest] is accepted as an alias:
[extra.fordoctest] max_modules = 2 check_imperative = true color = "auto" # auto, always or never
Command-line flags take precedence over these values. Unknown keys are rejected so a typo cannot silently disable a check.
By default fordoctest reports:
- More than one module per source file (
--max-moduleschanges the limit). - Undocumented modules, submodules and programs.
- Undocumented file-level, module and program procedures.
- Undocumented procedure arguments.
- Undocumented derived types, type components and type-bound procedures.
- Undocumented interfaces.
Pass --check-imperative to additionally flag procedure documentation whose
first word is a clear third-person or non-imperative form (for example
"Computes..." instead of "Compute..."). This check is a conservative heuristic
and is disabled by default.
FORD's Doxygen support is used directly: !> block comments (the predocmark
setting) are read as documentation, @param fills in argument documentation
and a @brief-only comment still counts as documentation. Trailing !<
comments are not supported by FORD, so document arguments with @param
instead.
Example output:
fordoctestdepends on FORD's parser and project model.- The imperative-verb check only uses a small English word list.
- Module-level variables and local variables inside procedures are not checked.
- There is no automatic documentation fixer.
black --check . pytest --cov=fordoctest --cov-report=term-missing --cov-fail-under=90 python -m build twine check dist/*
The test suite uses temporary FORD projects and does not require a Fortran compiler because preprocessing is disabled in the fixtures.
- Check the main Fortran entity kinds, including derived types, interfaces and submodules.
- Include optional documentation restrictions (imperative verbs).
- Test suite with at least 90% coverage.
- Become independent of FORD's CLI parser (not planned for 0.1).
Mozilla Public License 2.0. See LICENSE.
