Summary
Enum constants in the mrdocs DOM only expose initializer as written in the source. For enum constants with no explicit initializer, nothing is available at all.
Motivation
Consider:
#define BASE_VALUE 0x02000000
enum MyEnum {
FirstValue = BASE_VALUE, // initializer = "BASE_VALUE" (macro name, not resolved)
SecondValue, // no initializer at all
ThirdValue, // no initializer at all
};
The documentation generated for this enum shows (with a template modification):
| Name |
Value |
| FirstValue |
BASE_VALUE |
| SecondValue |
(empty) |
| ThirdValue |
(empty) |
What I would need:
| Name |
Value |
| FirstValue |
33554432 |
| SecondValue |
33554433 |
| ThirdValue |
33554434 |
For protocol or wire-format enums where the numeric value is the essential piece of information, the unresolved macro name and missing implicit values are not useful.
Proposed change
Add a value field to enum-constant DOM objects containing the evaluated integer as a decimal string. The existing initializer field (source text) should remain for cases where showing the expression is preferred.
Example DOM (XML):
<enum-constant>
<name>FirstValue</name>
<initializer>BASE_VALUE</initializer>
<value>33554432</value>
</enum-constant>
<enum-constant>
<name>SecondValue</name>
<value>33554433</value>
</enum-constant>
The Handlebars template could then use {{value}} (or fall back to {{initializer}}) to show the number.
Note: most of this ticket is generated using AI.
Summary
Enum constants in the mrdocs DOM only expose
initializeras written in the source. For enum constants with no explicit initializer, nothing is available at all.Motivation
Consider:
The documentation generated for this enum shows (with a template modification):
BASE_VALUEWhat I would need:
335544323355443333554434For protocol or wire-format enums where the numeric value is the essential piece of information, the unresolved macro name and missing implicit values are not useful.
Proposed change
Add a
valuefield to enum-constant DOM objects containing the evaluated integer as a decimal string. The existinginitializerfield (source text) should remain for cases where showing the expression is preferred.Example DOM (XML):
The Handlebars template could then use
{{value}}(or fall back to{{initializer}}) to show the number.Note: most of this ticket is generated using AI.