After some effort (and help from Alan), I managed to add math to mrdocs-based documentation (+antora).
https://gitlab.com/correaa/boost-multi/-/tree/develop/doc/mrdocs-addons?ref_type=heads
However, now I notice that the code to achieve this is incompatible with some clang warnings.
https://cpplang.slack.com/archives/C0508A7LWUV/p1784619895907419
clang 22 -Wdocumentation-unknown-command warning on LaTeX-style math in doc comments (Windows)
Description
Building with clang 22 on Windows, documentation comments using inline LaTeX math (e.g. $A^\mathrm{T}$) trigger a -Wdocumentation-unknown-command warning/error. Clang's documentation parser interprets \mathrm as an unrecognized Doxygen-style command tag, rather than as part of a math expression.
Example
In file included from C:\Users\correaa\boost-multi\include\boost/multi/array.hpp:9:
C:\Users\correaa\boost-multi\include\boost/multi/array_ref.hpp(1722,26): error: unknown command tag name [-Werror,-Wdocumentation-unknown-command]
1722 | /// A transpose view $A^\mathrm{T}$, that exchanges the first two indices
|
Discussion
- Clang's doc-comment parser doesn't treat
$...$ as a math delimiter on its own; Doxygen's convention is \f$ ... \f$ for inline math, which clang (or clang-doc) presumably recognizes/ignores appropriately.
- Without
\f$, clang sees the bare \mathrm inside $...$ as an attempted command tag and flags it as unknown — which is arguably "correct" behavior from clang's point of view, even though it's not actually using Doxygen conventions to render anything.
- Not obviously fixable in general: mrdocs/clang-doc has its own set of recognized commands, some of which plain clang doesn't know either, so there's no single convention that satisfies both.
- Possible mitigations to consider: switch to
\f$ ... \f$ for inline math consistently, suppress -Wdocumentation-unknown-command for this warning specifically, or avoid backslash commands like \mathrm inside math delimiters in doc comments.
Environment
After some effort (and help from Alan), I managed to add math to mrdocs-based documentation (+antora).
https://gitlab.com/correaa/boost-multi/-/tree/develop/doc/mrdocs-addons?ref_type=heads
However, now I notice that the code to achieve this is incompatible with some clang warnings.
https://cpplang.slack.com/archives/C0508A7LWUV/p1784619895907419
clang 22
-Wdocumentation-unknown-commandwarning on LaTeX-style math in doc comments (Windows)Description
Building with clang 22 on Windows, documentation comments using inline LaTeX math (e.g.
$A^\mathrm{T}$) trigger a-Wdocumentation-unknown-commandwarning/error. Clang's documentation parser interprets\mathrmas an unrecognized Doxygen-style command tag, rather than as part of a math expression.Example
Discussion
$...$as a math delimiter on its own; Doxygen's convention is\f$ ... \f$for inline math, which clang (or clang-doc) presumably recognizes/ignores appropriately.\f$, clang sees the bare\mathrminside$...$as an attempted command tag and flags it as unknown — which is arguably "correct" behavior from clang's point of view, even though it's not actually using Doxygen conventions to render anything.\f$ ... \f$for inline math consistently, suppress-Wdocumentation-unknown-commandfor this warning specifically, or avoid backslash commands like\mathrminside math delimiters in doc comments.Environment