Skip to content

Commit 0a1cbad

Browse files
committed
docs: split contribute.adoc guide
1 parent 99333ba commit 0a1cbad

File tree

7 files changed

+165
-147
lines changed

7 files changed

+165
-147
lines changed

docs/modules/ROOT/nav.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
* xref:generators.adoc[]
88
* xref:design-notes.adoc[]
99
* xref:reference:index.adoc[Library Reference]
10-
* xref:contribute.adoc[]
10+
* Contribute
11+
** xref:contribute/quickstart.adoc[]
12+
** xref:contribute/workflow.adoc[]
13+
** xref:contribute/testing.adoc[]
14+
** xref:contribute/options.adoc[]
15+
** xref:contribute/codebase-tour.adoc[]
16+
** xref:contribute/docs.adoc[]
1117
* xref:license.adoc[]
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
= Codebase tour
2+
3+
== Codebase Overview
4+
5+
The Mr.Docs codebase is divided into several modules:
6+
7+
include::partial$workflow.adoc[]
8+
9+
This section provides an overview of each module and how they interact with each other in the Mr.Docs codebase.
10+
11+
=== Directory Layout
12+
13+
The MrDocs codebase is organized as follows:
14+
15+
==== `include/`—The main include directory
16+
17+
This directory contains the public headers for the MrDocs library.
18+
19+
* `include/mrdocs/`—The core library headers
20+
** `include/mrdocs/ADT`—Data Structures
21+
** `include/mrdocs/Dom`—The Document Object Model for Abstract Trees
22+
** `include/mrdocs/Metadata`—`Symbol` nodes and metadata classes
23+
** `include/mrdocs/Support`—Various utility classes
24+
25+
==== `src/`—The main source directory
26+
27+
This directory contains the source code for the MrDocs library and private headers.
28+
29+
* `src/lib/`—The core library
30+
** `src/lib/AST/`—The AST traversal code
31+
** `src/lib/Dom/`—The Document Object Model for Abstract Trees
32+
** `src/lib/Gen/`—Generators
33+
** `src/lib/Lib/`—The core library classes
34+
** `src/lib/Metadata/`—`Symbol` nodes and metadata classes
35+
** `src/lib/Support/`—Various utility classes
36+
* `src/test/`—The test directory
37+
* `src/test_suite/`—The library used for testing
38+
* `src/tool/`—The main program
39+
40+
==== `share/`—Shared resources
41+
42+
This directory contains shared resources for the documentation generators and utilities for developers.
43+
Its subdirectories are installed in the `share` directory of the installation.
44+
45+
* `share/`—Shared resources for the documentation generators
46+
* `share/cmake/`—CMake modules to generate the documentation
47+
* `share/gdb/`—GDB pretty printers
48+
* `share/mrdocs/`—Shared resources for the documentation generators
49+
50+
==== `docs`—Documentation
51+
52+
This directory contains the documentation for the MrDocs project.
53+
The documentation is written in AsciiDoc and can be built using the Antora tool.
54+
55+
* `docs/`—Documentation configuration files and scripts
56+
** `docs/modules/`—The documentation asciidoc files
57+
** `docs/extensions`—Antora extensions for the documentation
58+
59+
==== `third-party/`—Helpers for third-party libraries
60+
61+
This directory contains build scripts and configuration files for third-party libraries.
62+
63+
* `third-party/`—Third-party libraries
64+
** `third-party/llvm/`—CMake Presets for LLVM
65+
** `third-party/duktape/`—CMake scripts for Duktape
66+
** `third-party/lua/`—A bundled Lua interpreter
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
= Docs changes
2+
3+
== `docs`—Documentation
4+
5+
This directory contains the documentation for the MrDocs project.
6+
The documentation is written in AsciiDoc and can be built using the Antora tool.
7+
8+
* `docs/`—Documentation configuration files and scripts
9+
** `docs/modules/`—The documentation asciidoc files
10+
** `docs/extensions`—Antora extensions for the documentation
Lines changed: 5 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
1-
= Contributor's Guide
2-
3-
This page contains information for contributors to the Mr.Docs project.
4-
It is intended to provide an overview of the codebase and the process of adding new features.
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-
11-
== Codebase Overview
12-
13-
The Mr.Docs codebase is divided into several modules:
14-
15-
include::partial$workflow.adoc[]
16-
17-
This section provides an overview of each module and how they interact with each other in the Mr.Docs codebase.
1+
= Options & architecture
182

193
[#options]
20-
=== Parsing options
4+
== Parsing options
215

226
Mr.Docs options affect the behavior of the compilation database, how symbols are extracted, and how the documentation is generated.
237
They are parsed from the command line and configuration file.
@@ -26,12 +10,12 @@ The main entry point of Mr.Docs is the `DoGenerateAction` function in `src/tool/
2610
It loads the options, creates the compilation database, and runs the extraction and generation steps.
2711
The options are formed from a combination of command line arguments and configuration file settings.
2812

29-
==== Command Line Options
13+
=== Command Line Options
3014

3115
Command line and common options are defined in `src/tool/ToolArgs.hpp`.
3216
The `ToolArgs` class uses the `llvm::cl` library to define and parse the command line arguments.
3317

34-
==== Configuration File
18+
=== Configuration File
3519

3620
Common options are defined in `mrdocs/Config.hpp`.
3721
The `Config` class represents all public options that could be defined in a configuration file.
@@ -41,7 +25,7 @@ The function `mrdocs::loadConfig` is also provided to parse all public options f
4125

4226
Internally, Mr.Docs uses the derived `mrdocs::ConfigImpl` class (`src/lib/Lib/ConfigImpl.hpp`) to also store the private representation of parsed options, such as filters.
4327

44-
==== Finalizing Options
28+
=== Finalizing Options
4529

4630
Common options are stored in the `Config` class, while the `ToolArgs` class stores common options and the command line options.
4731
For instance, the `config` option can only be set from the command line, as it would be illogical to expect the location of the configuration file to be defined in the configuration file itself.
@@ -172,129 +156,4 @@ Documentation generators are responsible for traversing the corpus and generatin
172156

173157
The API for documentation generators is defined in `mrdocs/Generator.hpp`.
174158

175-
=== Directory Layout
176-
177-
The MrDocs codebase is organized as follows:
178-
179-
==== `include/`—The main include directory
180-
181-
This directory contains the public headers for the MrDocs library.
182-
183-
* `include/mrdocs/`—The core library headers
184-
** `include/mrdocs/ADT`—Data Structures
185-
** `include/mrdocs/Dom`—The Document Object Model for Abstract Trees
186-
** `include/mrdocs/Metadata`—`Symbol` nodes and metadata classes
187-
** `include/mrdocs/Support`—Various utility classes
188-
189-
==== `src/`—The main source directory
190-
191-
This directory contains the source code for the MrDocs library and private headers.
192-
193-
* `src/lib/`—The core library
194-
** `src/lib/AST/`—The AST traversal code
195-
** `src/lib/Dom/`—The Document Object Model for Abstract Trees
196-
** `src/lib/Gen/`—Generators
197-
** `src/lib/Lib/`—The core library classes
198-
** `src/lib/Metadata/`—`Symbol` nodes and metadata classes
199-
** `src/lib/Support/`—Various utility classes
200-
* `src/test/`—The test directory
201-
* `src/test_suite/`—The library used for testing
202-
* `src/tool/`—The main program
203-
204-
==== `share/`—Shared resources
205-
206-
This directory contains shared resources for the documentation generators and utilities for developers.
207-
Its subdirectories are installed in the `share` directory of the installation.
208-
209-
* `share/`—Shared resources for the documentation generators
210-
* `share/cmake/`—CMake modules to generate the documentation
211-
* `share/gdb/`—GDB pretty printers
212-
* `share/mrdocs/`—Shared resources for the documentation generators
213-
214-
==== `docs`—Documentation
215-
216-
This directory contains the documentation for the MrDocs project.
217-
The documentation is written in AsciiDoc and can be built using the Antora tool.
218-
219-
* `docs/`—Documentation configuration files and scripts
220-
** `docs/modules/`—The documentation asciidoc files
221-
** `docs/extensions`—Antora extensions for the documentation
222-
223-
==== `third-party/`—Helpers for third-party libraries
224-
225-
This directory contains build scripts and configuration files for third-party libraries.
226-
227-
* `third-party/`—Third-party libraries
228-
** `third-party/llvm/`—CMake Presets for LLVM
229-
** `third-party/duktape/`—CMake scripts for Duktape
230-
** `third-party/lua/`—A bundled Lua interpreter
231-
232159
== Polymorphism
233-
234-
== Coding Standards
235-
236-
=== Paths
237-
238-
The AST visitor and metadata all use forward slashes to represent file pathnames, even on Windows.
239-
This is so the generated reference documentation does not vary based on the platform.
240-
241-
=== Exceptions
242-
243-
Errors thrown by the program should always have type `Exception`.
244-
Objects of this type are capable of transporting an `Error` object.
245-
This is important for the scripting to work; exceptions are used to propagate errors from library code to scripts and back to the invoking code.
246-
For exceptional cases, these thrown exceptions should be uncaught.
247-
The tool installs an uncaught exception handler that prints a stack trace and exits the process immediately.
248-
249-
=== Testing
250-
251-
All new features should be accompanied by tests.
252-
The `mrdocs-test` target is used to run the test suites.
253-
This target has its entry point in `src/test/TestMain.cpp`, which can take two paths:
254-
255-
* Golden testing: When input paths are provided to the test executable via the command line, the test suite will run the `DoTestAction()` that iterates all files in `test-files` comparing the input source files with the expected XML output files.
256-
* Unit testing: When no input paths are provided, all unit tests will be run via `unit_test_main()`, defined by our test-suite library in `src/test_suite/test_suite.cpp`.
257-
258-
The fixtures for golden testing are defined in `test-files/golden-tests`, where files in each directory have the following format:
259-
260-
* `mrdocs.yml`: Basic configuration options for all files in this directory.
261-
* `<filename>.cpp`: The input source file to extract symbols from.
262-
* `<filename>.xml`: The expected XML output file generated with the XML generator.
263-
* `<filename>.bad.xml`: The test output file generated when the test fails.
264-
* `<filename>.yml`: Extra configuration options for this specific file.
265-
266-
Multipage golden tests follow a snapshot-based layout:
267-
268-
* The suite defaults to `multipage: false` in `test-files/golden-tests/mrdocs.yml`; a multipage test must provide a `<stem>.yml` that sets `multipage: true`.
269-
* Expected output lives under `<stem>.multipage/<format>/...` (one directory per generator); single-page siblings like `<stem>.html`/`.xml` must be absent.
270-
* The harness skips `.multipage/` directories during discovery and compares generated temp output trees to the snapshot (strict tree + content).
271-
* Add a short comment in the `.cpp` explaining why multipage is required—use it only when single-page output cannot validate the behavior (e.g., relative asset/link handling).
272-
273-
== Style Guide
274-
275-
This project follows informal formatting conventions established by previous Boost projects.
276-
To help contributors, we provide a `.clang-format` file that encodes these rules.
277-
278-
* Do *not* apply clang-format across entire files or the whole project.
279-
* Use the config only as a *reference* for your IDE/editor, or to format the code you **personally add or modify** in a commit.
280-
* Always check the surrounding code and keep consistent with it.
281-
* Do not create style-only commits that introduce large diffs without functional changes.
282-
283-
Why This Approach:
284-
285-
* Keeps history clean: avoids large, style-only commits.
286-
* Ensures new contributors are not lost when adapting to project style.
287-
* Encourages consistency without rigid automation.
288-
289-
General Advice: When in doubt, copy the style of the surrounding code.
290-
The `.clang-format` file is a tool to help you, not a rule to enforce blindly.
291-
292-
The utility script `./util/reformat.sh` can also be used to check a few project invariants, such as header guards and include order.
293-
294-
== Contributing
295-
296-
If you find a bug or have a feature request, please open an issue on the MrDocs GitHub repository: https://github.com/cppalliance/mrdocs/issues
297-
298-
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
299-
300-
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/
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
= Contributor Quickstart
2+
3+
This page contains information for contributors to the Mr.Docs project.
4+
It is intended to provide an overview of the codebase and the process of adding new features.
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.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
= Testing & fixtures
2+
3+
All new features should be accompanied by tests.
4+
The `mrdocs-test` target is used to run the test suites.
5+
This target has its entry point in `src/test/TestMain.cpp`, which can take two paths:
6+
7+
* Golden testing: When input paths are provided to the test executable via the command line, the test suite will run the `DoTestAction()` that iterates all files in `test-files` comparing the input source files with the expected XML output files.
8+
* Unit testing: When no input paths are provided, all unit tests will be run via `unit_test_main()`, defined by our test-suite library in `src/test_suite/test_suite.cpp`.
9+
10+
The fixtures for golden testing are defined in `test-files/golden-tests`, where files in each directory have the following format:
11+
12+
* `mrdocs.yml`: Basic configuration options for all files in this directory.
13+
* `<filename>.cpp`: The input source file to extract symbols from.
14+
* `<filename>.xml`: The expected XML output file generated with the XML generator.
15+
* `<filename>.bad.xml`: The test output file generated when the test fails.
16+
* `<filename>.yml`: Extra configuration options for this specific file.
17+
18+
Multipage golden tests follow a snapshot-based layout:
19+
20+
* The suite defaults to `multipage: false` in `test-files/golden-tests/mrdocs.yml`; a multipage test must provide a `<stem>.yml` that sets `multipage: true`.
21+
* Expected output lives under `<stem>.multipage/<format>/...` (one directory per generator); single-page siblings like `<stem>.html`/`.xml` must be absent.
22+
* The harness skips `.multipage/` directories during discovery and compares generated temp output trees to the snapshot (strict tree + content).
23+
* Add a short comment in the `.cpp` explaining why multipage is required—use it only when single-page output cannot validate the behavior (e.g., relative asset/link handling).
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
= Workflow & PR hygiene
2+
3+
== Coding Standards
4+
5+
=== Paths
6+
7+
The AST visitor and metadata all use forward slashes to represent file pathnames, even on Windows.
8+
This is so the generated reference documentation does not vary based on the platform.
9+
10+
=== Exceptions
11+
12+
Errors thrown by the program should always have type `Exception`.
13+
Objects of this type are capable of transporting an `Error` object.
14+
This is important for the scripting to work; exceptions are used to propagate errors from library code to scripts and back to the invoking code.
15+
For exceptional cases, these thrown exceptions should be uncaught.
16+
The tool installs an uncaught exception handler that prints a stack trace and exits the process immediately.
17+
18+
== Style Guide
19+
20+
This project follows informal formatting conventions established by previous Boost projects.
21+
To help contributors, we provide a `.clang-format` file that encodes these rules.
22+
23+
* Do *not* apply clang-format across entire files or the whole project.
24+
* Use the config only as a *reference* for your IDE/editor, or to format the code you **personally add or modify** in a commit.
25+
* Always check the surrounding code and keep consistent with it.
26+
* Do not create style-only commits that introduce large diffs without functional changes.
27+
28+
Why This Approach:
29+
30+
* Keeps history clean: avoids large, style-only commits.
31+
* Ensures new contributors are not lost when adapting to project style.
32+
* Encourages consistency without rigid automation.
33+
34+
General Advice: When in doubt, copy the style of the surrounding code.
35+
The `.clang-format` file is a tool to help you, not a rule to enforce blindly.
36+
37+
The utility script `./util/reformat.sh` can also be used to check a few project invariants, such as header guards and include order.
38+
39+
== Contributing
40+
41+
If you find a bug or have a feature request, please open an issue on the MrDocs GitHub repository: https://github.com/cppalliance/mrdocs/issues
42+
43+
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
44+
45+
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/

0 commit comments

Comments
 (0)