You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/modules/ROOT/pages/contribute.adoc
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,11 @@
3
3
This page contains information for contributors to the Mr.Docs project.
4
4
It is intended to provide an overview of the codebase and the process of adding new features.
5
5
6
+
Before sending changes, run `python util/run_all_tests.py`.
7
+
This script is treated as a “source of truth” pass that configures the preferred preset, builds, runs golden + unit + lint/schema/self-doc checks, installs into a local `install/<preset>` prefix, and (by default) builds docs using that fresh install.
8
+
Not every policy can be enforced programmatically, but this script covers the checks that are automated; prefer it over ad-hoc command sequences.
9
+
Use `--skip-docs` to omit docs or `--no-strict` to relax strict warning handling when needed.
10
+
6
11
== Codebase Overview
7
12
8
13
The Mr.Docs codebase is divided into several modules:
@@ -49,19 +54,27 @@ As a last step, `DoGenerateAction` converts the public `Config` settings into a
49
54
[#representing_symbols]
50
55
== Representing Symbols
51
56
52
-
MrDocs has many categories of objects, where we utilize polymorphism with a fixed set of valid derived types, including Symbols (functions, classes, and enums), DocComment blocks, template parameters, template arguments, and data types. For each such family, we follow a consistent file layout. Most of these families are defined in the `mrdocs/Metadata` directory.
57
+
MrDocs has many categories of objects, where we utilize polymorphism with a fixed set of valid derived types, including Symbols (functions, classes, and enums), DocComment blocks, template parameters, template arguments, and data types.
58
+
For each such family, we follow a consistent file layout.
59
+
Most of these families are defined in the `mrdocs/Metadata` directory.
53
60
54
-
Each base class is defined in its own header and, when necessary, implementation file. Each derived class also has its own header and implementation file. Finally, there is a single aggregator header file that includes all the derived headers. This file centralizes logic that requires knowledge of the full set of variants, such as visitors, comparison operators, and other operations that depend on the discriminator.
61
+
Each base class is defined in its own header and, when necessary, implementation file.
62
+
Each derived class also has its own header and implementation file.
63
+
Finally, there is a single aggregator header file that includes all the derived headers.
64
+
This file centralizes logic that requires knowledge of the full set of variants, such as visitors, comparison operators, and other operations that depend on the discriminator.
55
65
56
-
Suppose we have a polymorphic family of `Symbol` objects, with derived types `Function`, `Class`, and `Enum`. The files would be organized as follows:
66
+
Suppose we have a polymorphic family of `Symbol` objects, with derived types `Function`, `Class`, and `Enum`.
67
+
The files would be organized as follows:
57
68
58
69
* The `Symbol/SymbolNodes.inc` file defines the possible derived types and is used to generate code via macros.
59
70
* The `Symbol/SymbolKind.hpp` file defines the `SymbolKind` enum, which is used as a discriminator for the derived types.
60
71
* The base class `Symbol` is defined in `Symbol/BaseSymbol.hpp` and `Symbol/BaseSymbol.cpp` (if needed).
61
72
* The available kinds of derived symbols are defined in `Symbol/<Derived>.hpp` and `Symbol/<Derived>.cpp` files, e.g., `Symbol/Function.hpp` and `Symbol/Function.cpp`.
62
73
* The `Symbol.hpp` file includes all derived headers and defines operations that require knowledge of all variants, such as visitors and comparison operators.
63
74
64
-
This pattern keeps the individual derived types self-contained while making cross-variant operations explicit and localized. When adding a new derived type, contributors should create its header and source file alongside the existing ones and update the corresponding aggregator file to register the new variant. This keeps the codebase predictable, avoids scattering logic, and ensures that operations over polymorphic families remain easy to find and maintain.
75
+
This pattern keeps the individual derived types self-contained while making cross-variant operations explicit and localized.
76
+
When adding a new derived type, contributors should create its header and source file alongside the existing ones and update the corresponding aggregator file to register the new variant.
77
+
This keeps the codebase predictable, avoids scattering logic, and ensures that operations over polymorphic families remain easy to find and maintain.
65
78
66
79
[#extract_symbols]
67
80
=== Extracting Symbols
@@ -139,8 +152,7 @@ This is necessary to generate the full interface for user-defined types.
139
152
After running the AST traversal on all translation units, `CorpusImpl::build` contains finalization steps for the `Corpus` object.
140
153
At this point, we process C++ constructs that are not directly represented in the AST.
141
154
142
-
The first finalization step happens in `CorpusImpl::build` (`src/lib/Lib/CorpusImpl.cpp`), where the `Symbol` objects from a single translation unit
143
-
are merged into a map containing the merged results from all other TUs.
155
+
The first finalization step happens in `CorpusImpl::build` (`src/lib/Lib/CorpusImpl.cpp`), where the `Symbol` objects from a single translation unit are merged into a map containing the merged results from all other TUs.
144
156
The merging step is necessary as there may be multiple identical definitions of the same entity.
145
157
For instance, this represents the case where a function is declared at different points in the code base and might have different attributes or comments.
146
158
At this step, the doc comments are also finalized.
@@ -267,7 +279,8 @@ Why This Approach:
267
279
* Ensures new contributors are not lost when adapting to project style.
268
280
* Encourages consistency without rigid automation.
269
281
270
-
General Advice: When in doubt, copy the style of the surrounding code. The `.clang-format` file is a tool to help you, not a rule to enforce blindly.
282
+
General Advice: When in doubt, copy the style of the surrounding code.
283
+
The `.clang-format` file is a tool to help you, not a rule to enforce blindly.
271
284
272
285
The utility script `./util/reformat.sh` can also be used to check a few project invariants, such as header guards and include order.
273
286
@@ -277,4 +290,4 @@ If you find a bug or have a feature request, please open an issue on the MrDocs
277
290
278
291
If you would like to contribute a feature or bug fix, please open a pull request on the MrDocs GitHub repository: https://github.com/cppalliance/mrdocs/pulls
279
292
280
-
If you would like to discuss a feature or bug fix before opening a pull request, discussing happen in the `#mrdocs` channel on the Cpplang Slack: https://cpplang.slack.com/
293
+
If you would like to discuss a feature or bug fix before opening a pull request, discussing happen in the `#mrdocs` channel on the Cpplang Slack: https://cpplang.slack.com/
This directory holds additional scripts and files for building and testing.
4
+
5
+
== Test runner
6
+
7
+
- Strict tests (self-doc, format check, warn-as-error) are enabled by default; pass `--no-strict` to disable `MRDOCS_BUILD_STRICT_TESTS`.
8
+
- Run `python util/run_all_tests.py` to configure the best release/* preset for your OS, build, and execute the full ctest suite (golden tests first, then the rest).
9
+
- The runner forces compiler warnings to be treated as errors with CI-matching flags: `-Werror -Wall` for gcc/clang and `/WX /W4` for MSVC, without clobbering preset defaults.
10
+
- Add `--update-golden` to refresh golden fixtures before running the test suite when output diffs in error messages are intentional.
11
+
- Use `--preset <name>` to override the automatic selection. The script prefers presets starting with `release/` (or `release-`) that match your OS and compiler, falling back to `debug/*` if needed.
12
+
- After tests (and optional docs), the script installs into `install/<preset>` under the repo root to keep the prefix scoped to the workspace.
13
+
- Docs build runs by default; pass `--skip-docs` to omit the documentation step. Docs are built after install with `MRDOCS_ROOT` pointed at the freshly installed prefix so the generated reference uses that version.
14
+
- Strict tests (self-doc, format check, warn-as-error) are enabled by default; pass `--no-strict` to disable `MRDOCS_BUILD_STRICT_TESTS`.
15
+
- `util/reformat.py` supports `--check` to validate formatting/include guards without modifying files (used by the strict test suite).
0 commit comments