Skip to content

docs: compile every reference example and inject it into the reference - #382

Open
mvandeberg wants to merge 1 commit into
cppalliance:developfrom
mvandeberg:pr/docstring-code-block-gate
Open

docs: compile every reference example and inject it into the reference#382
mvandeberg wants to merge 1 commit into
cppalliance:developfrom
mvandeberg:pr/docstring-code-block-gate

Conversation

@mvandeberg

Copy link
Copy Markdown
Contributor

The @code examples in the public headers were never compiled by anything, so broken examples shipped to readers: of the 99 examples MrDocs publishes, 33 compiled. The rest referenced undeclared identifiers, elided code with ..., or were fragments that could not build anywhere.

Each example now lives as a tagged region in test/doc/reference/, in a file named after the symbol that documents it, and is compiled by boost_capy_doc_tests with the same warnings-as-errors posture as the page snippets. A Lua extension under doc/addons/extensions/ injects those regions into the MrDocs corpus at doc-build time, so the reference shows code the build has already checked. Compilation and rendering are independent: CI compiles the files whether or not the docs build, the docs build injects them whether or not they compile, and MrDocs stays a dependency of the docs workflow alone.

A bare @par Example heading marks where each example is injected, one region per heading; 27 were added to docstrings that had none.

Beyond compilation, the when_all and when_any examples fix documented undefined behaviour: they ran concurrent read_some calls on a single stream, and now fan out across separate streams.

The docs workflow asserts the injected count and checks the rendered HTML for an example that exists only in a snippet file. A MrDocs without the extension installed ignores the script and renders the reference with no examples at all, while still reporting success.

Five @code blocks stay in their headers, on symbols MrDocs does not publish.

Refs: #380

@cppalliance-bot

cppalliance-bot commented Aug 21, 2026

Copy link
Copy Markdown

An automated preview of the documentation is available at https://382.capy.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-08-21 22:03:17 UTC

@cppalliance-bot

cppalliance-bot commented Aug 21, 2026

Copy link
Copy Markdown

GCOVR code coverage report https://382.capy.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://382.capy.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://382.capy.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-08-21 22:19:48 UTC

@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.99%. Comparing base (59296c7) to head (2194b4a).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #382      +/-   ##
===========================================
- Coverage    98.09%   97.99%   -0.10%     
===========================================
  Files          130      130              
  Lines         6291     6297       +6     
===========================================
  Hits          6171     6171              
- Misses         120      126       +6     
Flag Coverage Δ
linux 97.98% <ø> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
include/boost/capy/buffers.hpp 100.00% <ø> (ø)
include/boost/capy/buffers/buffer_param.hpp 100.00% <ø> (ø)
include/boost/capy/buffers/buffer_slice.hpp 100.00% <ø> (ø)
include/boost/capy/buffers/consuming_buffers.hpp 100.00% <ø> (ø)
include/boost/capy/concept/decomposes_to.hpp 57.14% <ø> (-42.86%) ⬇️
include/boost/capy/cond.hpp 100.00% <ø> (ø)
include/boost/capy/ex/any_executor.hpp 100.00% <ø> (ø)
include/boost/capy/ex/async_event.hpp 100.00% <ø> (ø)
include/boost/capy/ex/async_mutex.hpp 100.00% <ø> (ø)
include/boost/capy/ex/async_waker.hpp 92.95% <ø> (ø)
... and 28 more

... and 38 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59296c7...2194b4a. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mvandeberg
mvandeberg force-pushed the pr/docstring-code-block-gate branch 5 times, most recently from 0c173fd to 5aee6f5 Compare August 21, 2026 21:54
The `@code` examples in the public headers were never compiled by
anything, so broken examples shipped to readers: of the 99 examples
MrDocs publishes, 33 compiled. The rest referenced undeclared
identifiers, elided code with `...`, or were fragments that could not
build anywhere.

Each example now lives as a tagged region in test/doc/reference/, in a
file named after the symbol that documents it, and is compiled by
boost_capy_doc_tests with the same warnings-as-errors posture as the page
snippets. A Lua extension under doc/addons/extensions/ injects those
regions into the MrDocs corpus at doc-build time, so the reference shows
code the build has already checked. Compilation and rendering are
independent: CI compiles the files whether or not the docs build, the
docs build injects them whether or not they compile, and MrDocs stays a
dependency of the docs workflow alone.

A `@par !example <tag>` marker in the docstring records where each
example belongs and which region it wants. The transform replaces the
marker with that region rather than rendering it, so nothing is added to
the page and each example keeps its place: under a descriptive title,
under an `@par Example` heading, or inline in the prose introducing it.
Naming the region lets overloads and duplicated records share one file.

Beyond compilation, the when_all and when_any examples fix documented
undefined behaviour: they ran concurrent read_some calls on a single
stream, and now fan out across separate streams.

MrDocs loads extensions only from
`<install>/share/mrdocs/addons/extensions`, and its `addons-supplemental`
config key is inert, so doc/build_antora.sh installs the extension into a
MrDocs, exports MRDOCS_ROOT, and publishes it to GITHUB_ENV for later
steps. Every caller therefore gets it: this repository's docs workflow,
the C++ Alliance doc build, and a plain local run.

The docs workflow checks the rendered HTML for an example that exists
only in a snippet file, because a MrDocs without the extension renders
the reference with no examples while still reporting success.

Five `@code` blocks stay in their headers, on symbols MrDocs does not
publish.

Refs: cppalliance#380
@mvandeberg
mvandeberg force-pushed the pr/docstring-code-block-gate branch from 5aee6f5 to 75afb3c Compare August 21, 2026 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants