Skip to content

feat: uniform attribute extraction#1237

Open
alandefreitas wants to merge 1 commit into
cppalliance:developfrom
alandefreitas:feat/document-attributes
Open

feat: uniform attribute extraction#1237
alandefreitas wants to merge 1 commit into
cppalliance:developfrom
alandefreitas:feat/document-attributes

Conversation

@alandefreitas

Copy link
Copy Markdown
Collaborator

Reads attributes for every kind of symbol and shows them in the generated pages. Before, it only read attributes on functions and variables, and a deprecated symbol gave no sign that it was deprecated. For other symbols, it showed nothing. Now every symbol carries its attributes, deprecated symbols get a notice with the message in an admonition, and attributes appear in signatures and member tables.

Fixes #1233.

Changes

In the source code, attributes now live on the common symbol base class. Each attribute now contains its name and all its arguments. The templates render them in each signature, add a deprecation notice, and tag deprecated entries in member tables the same way constructors are tagged. The output schema and the golden tests were updated to match.

Testing

New metadata fixtures cover attribute extraction for each symbol type. A new generator example renders the attributes to AsciiDoc and HTML.

Documentation

The data model reference section now describes the new attribute fields.

@github-actions

github-actions Bot commented Jun 22, 2026

Copy link
Copy Markdown

✨ Highlights

  • 🧪 Existing golden tests changed (behavior likely shifted)

🧾 Changes by Scope

Scope Lines Δ% Lines Δ Lines + Lines - Files Δ Files + Files ~ Files ↔ Files -
🥇 Golden Tests 75% 1093 1082 11 19 14 5 - -
🛠️ Source 21% 305 250 55 16 3 13 - -
📄 Docs 3% 38 22 16 1 - 1 - -
🏗️ Build 1% 16 9 7 1 - 1 - -
🧪 Unit Tests 1% 8 4 4 1 - 1 - -
Total 100% 1460 1367 93 38 17 21 - -

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

🔝 Top Files

  • test-files/golden-tests/generator/hbs/attributes/attributes.adoc (Golden Tests): 307 lines Δ (+307 / -0)
  • test-files/golden-tests/generator/hbs/attributes/attributes.html (Golden Tests): 298 lines Δ (+298 / -0)
  • src/lib/AST/ASTVisitor.cpp (Source): 154 lines Δ (+137 / -17)

Generated by 🚫 dangerJS against 608432a

@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (64cfdbd) to head (608432a).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1237   +/-   ##
========================================
  Coverage    83.16%   83.16%           
========================================
  Files           35       35           
  Lines         3658     3658           
  Branches       843      843           
========================================
  Hits          3042     3042           
  Misses         409      409           
  Partials       207      207           
Flag Coverage Δ
bootstrap 83.16% <ø> (ø)

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b62ee704ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/lib/AST/ASTVisitor.cpp Outdated
@cppalliance-bot

cppalliance-bot commented Jun 22, 2026

Copy link
Copy Markdown

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

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

2026-06-22 04:50:33 UTC

@alandefreitas alandefreitas force-pushed the feat/document-attributes branch from b62ee70 to 608432a Compare June 22, 2026 04:44
@gennaroprota

Copy link
Copy Markdown
Collaborator

Hi Alan, very good PR. I only left some minor comments. The most important one is about the duplication of IsNoReturn.

| `attributes`
| `<<attribute-fields,Attribute Object[]>>`
| The C++ attributes attached to the symbol (e.g., `[[deprecated]]`, `[[nodiscard]]`). Present for every symbol kind; absent when the symbol has no attributes.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Present for every symbol kind" but then "absent when..." sounds strange :-). Perhaps we could say "Applies to every symbol kind"?

// brackets and string/character literals.
std::vector<std::string>
splitAttributeArgs(std::string_view const s)
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we normally use top-level const on function parameters?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😮

| Render the shape&period;
|===


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the extra empty lines?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a template there but handlebars also creates an extra line when the template is empty. Let me see what I can do about that.

IsVariadic, IsDefaulted, IsExplicitlyDefaulted, IsDeleted,
IsDeletedAsWritten, IsNoReturn, HasOverrideAttr, HasTrailingReturn,
IsNodiscard, IsExplicitObjectMemberFunction, Constexpr,
IsExplicitObjectMemberFunction, Constexpr,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to remove IsNoReturn.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return args;
}
} // (anon)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice implementation. It's only con is it doesn't correctly handle raw string literals (very rare, I guess, in an attribute, but I thought to mention that).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This is the literal expression because clang doesn't give us the individual arguments in the general case. 😢

This is literally parsing std::string const text = getSourceCode(attr->getRange());.

On the other hand, I think we need the literal expression anyway. Otherwise, we would have to reconstruct the attribute on the other side.

I'll investigate the actual grammar and come up with something here.

@@ -0,0 +1,6 @@
{{! Deprecation admonition, shown when the symbol carries a [[deprecated]] attribute. }}
{{~#each symbol.attributes}}
{{~#if (eq name "deprecated")}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this won't match [[gnu::deprecated]] (not sure if it will match __declspec(deprecated)).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this one when writing it. I thought the template would become a mess if we tried to detect all kinds here, with little benefit. Because people who don’t use these other deprecated attributes usually do so because they don’t have access to C++20, but MrDocs does.

So if they use [[gnu::deprecated]], they probably are using macros for mrdocs and other C++20 compilers to see and document [[deprecated]] instead. So I thought accepting other kinds was just reinforcing the error somehow. So the template would become giant for very little benefit.

The solution I had in mind for this was to propose an optional feature that normalizes non-standard attributes if people complain. This would happen long before the templates. But I can’t really propose this now because I’m not so sure how that would go and if people actually care.

What do you think?

@gennaroprota gennaroprota Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree, normalization is the way to go; but let's wait to see if people actually care.

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.

[[deprecated]] could be documented

3 participants