Skip to content

feat: support macros#1192

Open
gennaroprota wants to merge 1 commit intocppalliance:developfrom
gennaroprota:feat/support_macros
Open

feat: support macros#1192
gennaroprota wants to merge 1 commit intocppalliance:developfrom
gennaroprota:feat/support_macros

Conversation

@gennaroprota
Copy link
Copy Markdown
Collaborator

@gennaroprota gennaroprota commented Apr 30, 2026

This adds support for preprocessing macros: #define directives are captured via a clang::PPCallbacks subclass and exposed as MacroSymbol instances at the corpus root (macros aren't in any C++ scope, so they sit alongside the global namespace rather than under it).

Doc-comment association: Clang doesn't link comments to macros, so we look up a preceding doc-comment by source location. A comment is attached only when the lines between it and the directive are blank.

Filters apply to macros, too:

  • extract-all: when off, undocumented macros are dropped.
  • exclude-symbols, include-symbols, implementation-defined, see-below: matched against the macro name.
  • File-pattern filters: matched against the directive's source location.

Schema additions: <macro> is a new top-level element in mrdocs.rnc, sibling of <namespace>, with <source> carrying the verbatim definition (modulo a minor normalization).

New output pages: multipage mode now produces macros.{ext} at the output root, listing every macro with a link to its per-symbol page. The global-namespace page gains a "See also: Macros" navigation hint at the bottom (multipage-only) so the new page is discoverable.

Macro @param blocks are validated.

Golden tests also cover the three filter paths (extract-all: false, include-symbols, exclude-symbols).

Closes issue #1127.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 30, 2026

🚧 Danger.js checks for MrDocs are experimental; expect some rough edges while we tune the rules.

✨ Highlights

  • 🧪 New golden tests added

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🥇 Golden Tests 78% 3800 3800 - 53 53 - - -
🛠️ Source 22% 1087 1062 25 35 6 29 - -
🏗️ Build <1% 13 13 - 1 - 1 - -
Total 100% 4900 4875 25 89 59 30 - -

Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)

🔝 Top Files

  • test-files/golden-tests/symbols/macro/macros.xml (Golden Tests): 649 lines Δ (+649 / -0)
  • test-files/golden-tests/symbols/macro/macros.html (Golden Tests): 531 lines Δ (+531 / -0)
  • test-files/golden-tests/symbols/macro/macros.adoc (Golden Tests): 397 lines Δ (+397 / -0)

Generated by 🚫 dangerJS against c1ce891

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.89%. Comparing base (9c7a140) to head (c1ce891).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1192      +/-   ##
===========================================
+ Coverage    79.19%   81.89%   +2.70%     
===========================================
  Files          308       33     -275     
  Lines        32332     2983   -29349     
  Branches      6493      691    -5802     
===========================================
- Hits         25606     2443   -23163     
+ Misses        4355      373    -3982     
+ Partials      2371      167    -2204     
Flag Coverage Δ
bootstrap 81.89% <ø> (ø)
cpp ?

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cppalliance-bot
Copy link
Copy Markdown

cppalliance-bot commented Apr 30, 2026

An automated preview of the documentation is available at https://1192.mrdocs.prtest2.cppalliance.org/index.html

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

2026-05-01 15:34:07 UTC

@gennaroprota gennaroprota force-pushed the feat/support_macros branch 3 times, most recently from 3016b66 to 2c90a7c Compare May 1, 2026 08:06
This adds support for preprocessing macros: `#define` directives are
captured via a `clang::PPCallbacks` subclass and exposed as
`MacroSymbol` instances at the corpus root (macros aren't in any C++
scope, so they sit alongside the global namespace rather than under it).

Doc-comment association: Clang doesn't link comments to macros, so we
look up a preceding doc-comment by source location. A comment is
attached only when the lines between it and the directive are blank.

Filters apply to macros, too:

- `extract-all`: when off, undocumented macros are dropped.
- `exclude-symbols`, `include-symbols`, `implementation-defined`,
  `see-below`: matched against the macro name.
- File-pattern filters: matched against the directive's source location.

Schema additions: `<macro>` is a new top-level element in mrdocs.rnc,
sibling of `<namespace>`, with `<source>` carrying the verbatim
definition (modulo a minor normalization).

New output pages: multipage mode now produces `macros.{ext}` at the
output root, listing every macro with a link to its per-symbol page. The
global-namespace page gains a "See also: Macros" navigation hint at the
bottom (multipage-only) so the new page is discoverable.

Macro `@param` blocks are validated.

Golden tests also cover the three filter paths (`extract-all: false`,
`include-symbols`, `exclude-symbols`).

Closes issue cppalliance#1127.
@gennaroprota gennaroprota force-pushed the feat/support_macros branch from 2c90a7c to c1ce891 Compare May 1, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants