Skip to content

feat: warn when a documented declaration names a filtered symbol - #1316

Open
gennaroprota wants to merge 5 commits into
cppalliance:developfrom
gennaroprota:feat/warn_when_a_documented_declaration_names_a_filtered_symbol
Open

gennaroprota wants to merge 5 commits into
cppalliance:developfrom
gennaroprota:feat/warn_when_a_documented_declaration_names_a_filtered_symbol

Conversation

@gennaroprota

@gennaroprota gennaroprota commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

This PR:

  • Fixes the interaction between filters and @implementationdefined/@seebelow. Before it. the filters won and the commands were thrown away, This meant that, for instance, a function returning a filtered type was rendered with the filtered type name in the docs, and the user had no way to avoid this.

  • Adds the warning issue warning: filtered namespace in public API #337 asks for, and a corresponding option to silence it. Thanks to the above, the user can choose to avoid the warning by marking the filtered symbol @implementationdefined.

Changes

  • Source: An @implementationdefined or @seebelow command outranks the filters that hide kinds of symbols, and survives an exclusion of the file it is in; a FilteredSymbolFinalizer reports filtered symbols named by the documented API.
  • Tests: Golden fixtures for the two filter fixes, and a pair of runs over an input that names a filtered symbol, one expecting a failure and one expecting silence with the warning off.
  • Build: A new warn-if-filtered-in-public-api option, with the generated config schema updated.
  • Breaking changes: The new warning is on by default, so a project running with warn-as-error over an API that names a filtered symbol will start failing. Setting warn-if-filtered-in-public-api: false restores the old behavior, and marking the symbol @implementationdefined fixes the issue properly.

Testing

Two ctest entries in tests/CMakeLists.txt run the tool over tests/diagnostics/filtered-in-public-api/, an input that names a filtered symbol as a base class and as a return type. mrdocs-warn-filtered-in-public-api runs it with --warn-as-error and expects the failure; mrdocs-quiet-filtered-in-public-api runs the same input with the option off and expects a clean exit. The second is what gives the first its meaning, since it shows nothing else in that input warns.

The two filter fixes are covered by golden fixtures instead, because their effect is in the generated page: tests/golden/fixtures/filters/symbol-type/private-implementation-defined pins the extraction mode of a marked private member, and
tests/golden/fixtures/filters/file/excluded-implementation-defined pins the rendered signature of a marked type in an excluded header.

Documentation

warn-if-filtered-in-public-api joins the warn-* list on the Diagnostics page, with a pointer to @implementationdefined as the way to settle the warning rather than switch it off. Its own entry in the options reference comes from ConfigOptions.json and needs no separate edit.

Closes #337.

The filters that drop whole kinds of symbol - private members, anonymous
namespaces, file-level statics - run before the ones that match names,
so `@implementationdefined` and `@seebelow` on a private member, and the
globs that mirror those commands, were read too late to matter: the
member stayed a dependency and a public signature involving it printed
the name despite the command.

The command is now read when one of those filters rejects a symbol.
Before this fix, a file excluded with `exclude` or `exclude-patterns`
lost every symbol in it, commands and all, so `@implementationdefined`
on a type in an excluded header did nothing. For instance, a function
returning that type was documented with the real type name instead of
the placeholder.

With the fix, the command wins, because it's a statement about how we
want the symbol to appear when something else names it, and that's more
specific than excluding a file.

A file that was never in `input` is another matter, because a command in
a third-party header speaks for that library rather than for the project
being documented, so a symbol from one is still dropped.
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

✨ Highlights

  • 🧪 Existing golden tests changed (behavior likely shifted)

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🛠️ Source 62% 468 398 70 10 4 6 - -
🥇 Golden Tests 27% 201 201 - 7 6 1 - -
📦 Other 9% 70 70 - 6 5 1 - -
📄 Docs 1% 11 11 - 2 - 2 - -
Total 100% 750 680 70 25 15 10 - -

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

🔝 Top Files

  • src/mrdocs/AST/ASTVisitor.cpp (Source): 127 lines Δ (+59 / -68)
  • src/mrdocs/Metadata/Finalizers/FilteredSymbolFinalizer.cpp (Source): 125 lines Δ (+125 / -0)
  • tests/golden/fixtures/filters/symbol-type/private-implementation-defined.xml (Golden Tests): 123 lines Δ (+123 / -0)

Generated by 🚫 dangerJS against 264c2f3

@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.12%. Comparing base (b45d019) to head (264c2f3).
⚠️ Report is 5 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1316   +/-   ##
========================================
  Coverage    83.12%   83.12%           
========================================
  Files           35       35           
  Lines         3662     3662           
  Branches       844      844           
========================================
  Hits          3044     3044           
  Misses         410      410           
  Partials       208      208           
Flag Coverage Δ
bootstrap 83.12% <ø> (ø)

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

☔ View full report in Codecov by Harness.
📢 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.

@gennaroprota
gennaroprota force-pushed the feat/warn_when_a_documented_declaration_names_a_filtered_symbol branch from 67d7bde to 4e976d6 Compare September 22, 2026 07:12
@gennaroprota gennaroprota changed the title Feat: warn when a documented declaration names a filtered symbol feat: warn when a documented declaration names a filtered symbol Sep 22, 2026
@cppalliance-bot

cppalliance-bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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

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

2026-09-23 08:20:47 UTC

This fixes a bug for which the documented accessor `dom::Function::impl`
returned `impl_type const&`, where `impl_type` was a private alias. The
alias has no page, so a reader of the signature met a name that led
nowhere.

Make the alias public and document it, as `dom::Array` and `dom::Object`
already do.
A symbol removed by the filters has no page, so a declaration naming it
sends the reader nowhere. A corpus pass now walks the documented
declarations and reports those names, over return types, parameters,
public bases, aliases and variables, and inside the arguments given to a
template.

Only the project's own symbols are reported. A name that reaches the
symbol through a template specialization is left alone as well, since
the primary template documents it and the reader lands there.
This gives projects that deliberately use filtered symbols in the public
API a way to silence the new warning in one place, instead of e.g.
annotating every symbol with `@implementationdefined`. The default is
`true`, like for the other options of the `warn-*` family.

The golden fixtures set the option to `false`, as several of them exist
exactly to exercise a filtered symbol reached from the documented API.
@gennaroprota
gennaroprota force-pushed the feat/warn_when_a_documented_declaration_names_a_filtered_symbol branch from 4e976d6 to 264c2f3 Compare September 23, 2026 08:14

This branch has not been deployed

No deployments
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.

warning: filtered namespace in public API

2 participants