-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add $meta.type and $meta.bases to all DOM objects #1153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: add $meta.type and $meta.bases to all DOM objects #1153
Conversation
|
| Scope | Lines Δ | Lines + | Lines - | Files Δ | Files + | Files ~ | Files ↔ | Files - |
|---|---|---|---|---|---|---|---|---|
| 🛠️ Source | 250 | 193 | 57 | 9 | - | 9 | - | - |
| Total | 250 | 193 | 57 | 9 | - | 9 | - | - |
Legend: Files + (added), Files ~ (modified), Files ↔ (renamed), Files - (removed)
🔝 Top Files
- src/lib/Support/Reflection/MapReflectedType.hpp (Source): 181 lines Δ (+152 / -29)
- src/lib/Support/Reflection/Reflection.cpp (Source): 39 lines Δ (+24 / -15)
- share/mrdocs/addons/generator/common/partials/symbol/signature/function.hbs (Source): 10 lines Δ (+5 / -5)
|
An automated preview of the documentation is available at https://1153.mrdocs.prtest2.cppalliance.org/index.html If more commits are pushed to the pull request, the docs will rebuild at the same URL. 2026-01-23 17:33:43 UTC |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #1153 +/- ##
===========================================
- Coverage 86.49% 86.48% -0.01%
===========================================
Files 326 326
Lines 23828 23839 +11
===========================================
+ Hits 20609 20618 +9
- Misses 3219 3221 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
alandefreitas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
What was the process to get to this _meta key?
| */ | ||
| template <typename T> | ||
| constexpr std::string_view | ||
| readableTypeName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this information already boost described?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS, Boost.Describe cannot provide the type name. However, we could use Boost.Core:
template <typename T>
std::string
readableTypeName()
{
return std::string(removeNamespaceQualifiers(boost::core::type_name<T>()));
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is Boost.Core already available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we'd have to add the (private) dependency.
| DomCorpus const* domCorpus) | ||
| { | ||
| // Add _meta only for the most-derived type. | ||
| if constexpr (isMostDerived) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... I never thought about this problem. There are some cases where the templates are worried about the base class. For instance, some fields return whether something is a symbol, and the templates often query that, but the derived class would just be a record, a function or something like that. I don't know what the best solution for that would be. Maybe we just include the metadata for the superclass inside the metadata for the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... if there are already templates that do that, why didn't the golden tests fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be clear we're not misunderstanting each other, what I meant in practice is that templates often need to do something like {{#if (eq symbol.type "symbol")}}do this{{ else if (eq symbol.type "name")}}do that{{else}}error!{{/if}} because we have two ways to talk about identifiers (Symbol and Name) and we want the template to work for both of them.
- https://github.com/cppalliance/mrdocs/blob/develop/include/mrdocs/Metadata/Symbol.hpp
- https://github.com/cppalliance/mrdocs/blob/develop/include/mrdocs/Metadata/Name.hpp
So the problem is the current model doesn't give us the parent class. So both conditions would return false here and we would get into error. I don't know about how to fix that. But only representing the most derived type would fail.
Hmm... if there are already templates that do that, why didn't the golden tests fail?
Because the previous code wasn't broken and the new code is not relying on $meta for this distinction yet? So it's still using the previous workaround, which doesn't need $meta. Probably the type is represented with "type" and the parent type is represented with "kind" or something. Whatever the describe function does for Symbol and Name.
You mean what led to choosing the underscore as prefix? |
I mean the whole thing. This combination of prefix + keyword. Did we compare it with existing practices for that anywhere? Or the set of valid chars that could go there? Getting this convention wrong now could be annoying later. |
I was going with
|
97424a4 to
bcda061
Compare
44b7447 to
2b8e5c1
Compare
This enables the Handlebars templates to identify object types and base classes at runtime. The '$' prefix follows the JSON Schema conventions for system metadata. Closes issue cppalliance#1148.
We renamed some members into different Handlebars key names. But there's no particular reason to do that. So we switch to use the canonical names everywhere.
2b8e5c1 to
12c2666
Compare
Closes issue #1148.