Skip to content

Commit 019d019

Browse files
committed
refactor: drop Symbol's isXxx booleans
`Symbol`'s `tag_invoke` overload added four convenience booleans -- `isRegular`, `isSeeBelow`, `isImplementationDefined`, `isDependency` -- outside the described struct. Because reflection couldn't see them, the JSON schema writer had to mirror the same hardcoded list. This removes those booleans and lets templates compare the described enum directly; e.g.: {{#if isRegular}} -> {{#if (eq extraction "regular")}} For the two `filter_by` / `any_of_by` sites that previously keyed on the booleans, the helper family gains variadic siblings `filter_by_eq` and `any_of_by_eq` -- signature `(container, key, value1, value2, ...)`. This addresses review feedback on PR #1178.
1 parent 6ce122b commit 019d019

12 files changed

Lines changed: 137 additions & 215 deletions

File tree

docs/mrdocs-dom-schema.json

Lines changed: 12 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,6 @@
131131
"const": "symbol",
132132
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
133133
},
134-
"isRegular": {
135-
"type": "boolean",
136-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
137-
},
138-
"isSeeBelow": "{recursive}",
139-
"isImplementationDefined": "{recursive}",
140-
"isDependency": "{recursive}",
141134
"$meta": {
142135
"type": "object",
143136
"properties": {
@@ -165,11 +158,7 @@
165158
"isAnonymous",
166159
"usingDirectives",
167160
"members",
168-
"class",
169-
"isRegular",
170-
"isSeeBelow",
171-
"isImplementationDefined",
172-
"isDependency"
161+
"class"
173162
]
174163
},
175164
"RecordSymbol": {
@@ -294,13 +283,6 @@
294283
"const": "symbol",
295284
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
296285
},
297-
"isRegular": {
298-
"type": "boolean",
299-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
300-
},
301-
"isSeeBelow": "{recursive}",
302-
"isImplementationDefined": "{recursive}",
303-
"isDependency": "{recursive}",
304286
"$meta": {
305287
"type": "object",
306288
"properties": {
@@ -332,11 +314,7 @@
332314
"derived",
333315
"interface",
334316
"friends",
335-
"class",
336-
"isRegular",
337-
"isSeeBelow",
338-
"isImplementationDefined",
339-
"isDependency"
317+
"class"
340318
]
341319
},
342320
"FunctionSymbol": {
@@ -554,13 +532,6 @@
554532
"const": "symbol",
555533
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
556534
},
557-
"isRegular": {
558-
"type": "boolean",
559-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
560-
},
561-
"isSeeBelow": "{recursive}",
562-
"isImplementationDefined": "{recursive}",
563-
"isDependency": "{recursive}",
564535
"$meta": {
565536
"type": "object",
566537
"properties": {
@@ -608,11 +579,7 @@
608579
"isFinal",
609580
"explicit",
610581
"attributes",
611-
"class",
612-
"isRegular",
613-
"isSeeBelow",
614-
"isImplementationDefined",
615-
"isDependency"
582+
"class"
616583
]
617584
},
618585
"OverloadsSymbol": {
@@ -712,13 +679,6 @@
712679
"const": "symbol",
713680
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
714681
},
715-
"isRegular": {
716-
"type": "boolean",
717-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
718-
},
719-
"isSeeBelow": "{recursive}",
720-
"isImplementationDefined": "{recursive}",
721-
"isDependency": "{recursive}",
722682
"$meta": {
723683
"type": "object",
724684
"properties": {
@@ -746,11 +706,7 @@
746706
"overloadedOperator",
747707
"members",
748708
"returnType",
749-
"class",
750-
"isRegular",
751-
"isSeeBelow",
752-
"isImplementationDefined",
753-
"isDependency"
709+
"class"
754710
]
755711
},
756712
"EnumSymbol": {
@@ -840,13 +796,6 @@
840796
"const": "symbol",
841797
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
842798
},
843-
"isRegular": {
844-
"type": "boolean",
845-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
846-
},
847-
"isSeeBelow": "{recursive}",
848-
"isImplementationDefined": "{recursive}",
849-
"isDependency": "{recursive}",
850799
"$meta": {
851800
"type": "object",
852801
"properties": {
@@ -872,11 +821,7 @@
872821
"parent",
873822
"scoped",
874823
"constants",
875-
"class",
876-
"isRegular",
877-
"isSeeBelow",
878-
"isImplementationDefined",
879-
"isDependency"
824+
"class"
880825
]
881826
},
882827
"EnumConstantSymbol": {
@@ -954,13 +899,6 @@
954899
"const": "symbol",
955900
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
956901
},
957-
"isRegular": {
958-
"type": "boolean",
959-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
960-
},
961-
"isSeeBelow": "{recursive}",
962-
"isImplementationDefined": "{recursive}",
963-
"isDependency": "{recursive}",
964902
"$meta": {
965903
"type": "object",
966904
"properties": {
@@ -984,11 +922,7 @@
984922
"extraction",
985923
"isCopyFromInherited",
986924
"parent",
987-
"class",
988-
"isRegular",
989-
"isSeeBelow",
990-
"isImplementationDefined",
991-
"isDependency"
925+
"class"
992926
]
993927
},
994928
"TypedefSymbol": {
@@ -1074,13 +1008,6 @@
10741008
"const": "symbol",
10751009
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
10761010
},
1077-
"isRegular": {
1078-
"type": "boolean",
1079-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
1080-
},
1081-
"isSeeBelow": "{recursive}",
1082-
"isImplementationDefined": "{recursive}",
1083-
"isDependency": "{recursive}",
10841011
"$meta": {
10851012
"type": "object",
10861013
"properties": {
@@ -1106,11 +1033,7 @@
11061033
"parent",
11071034
"type",
11081035
"isUsing",
1109-
"class",
1110-
"isRegular",
1111-
"isSeeBelow",
1112-
"isImplementationDefined",
1113-
"isDependency"
1036+
"class"
11141037
]
11151038
},
11161039
"VariableSymbol": {
@@ -1262,13 +1185,6 @@
12621185
"const": "symbol",
12631186
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
12641187
},
1265-
"isRegular": {
1266-
"type": "boolean",
1267-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
1268-
},
1269-
"isSeeBelow": "{recursive}",
1270-
"isImplementationDefined": "{recursive}",
1271-
"isDependency": "{recursive}",
12721188
"$meta": {
12731189
"type": "object",
12741190
"properties": {
@@ -1305,11 +1221,7 @@
13051221
"isMutable",
13061222
"isVariant",
13071223
"isBitfield",
1308-
"class",
1309-
"isRegular",
1310-
"isSeeBelow",
1311-
"isImplementationDefined",
1312-
"isDependency"
1224+
"class"
13131225
]
13141226
},
13151227
"GuideSymbol": {
@@ -1402,13 +1314,6 @@
14021314
"const": "symbol",
14031315
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
14041316
},
1405-
"isRegular": {
1406-
"type": "boolean",
1407-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
1408-
},
1409-
"isSeeBelow": "{recursive}",
1410-
"isImplementationDefined": "{recursive}",
1411-
"isDependency": "{recursive}",
14121317
"$meta": {
14131318
"type": "object",
14141319
"properties": {
@@ -1435,11 +1340,7 @@
14351340
"deduced",
14361341
"params",
14371342
"explicit",
1438-
"class",
1439-
"isRegular",
1440-
"isSeeBelow",
1441-
"isImplementationDefined",
1442-
"isDependency"
1343+
"class"
14431344
]
14441345
},
14451346
"NamespaceAliasSymbol": {
@@ -1517,13 +1418,6 @@
15171418
"const": "symbol",
15181419
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
15191420
},
1520-
"isRegular": {
1521-
"type": "boolean",
1522-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
1523-
},
1524-
"isSeeBelow": "{recursive}",
1525-
"isImplementationDefined": "{recursive}",
1526-
"isDependency": "{recursive}",
15271421
"$meta": {
15281422
"type": "object",
15291423
"properties": {
@@ -1548,11 +1442,7 @@
15481442
"isCopyFromInherited",
15491443
"parent",
15501444
"aliasedSymbol",
1551-
"class",
1552-
"isRegular",
1553-
"isSeeBelow",
1554-
"isImplementationDefined",
1555-
"isDependency"
1445+
"class"
15561446
]
15571447
},
15581448
"UsingSymbol": {
@@ -1638,13 +1528,6 @@
16381528
},
16391529
"description": "Symbols brought into scope by the using-declaration."
16401530
},
1641-
"isRegular": {
1642-
"type": "boolean",
1643-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
1644-
},
1645-
"isSeeBelow": "{recursive}",
1646-
"isImplementationDefined": "{recursive}",
1647-
"isDependency": "{recursive}",
16481531
"$meta": {
16491532
"type": "object",
16501533
"properties": {
@@ -1671,11 +1554,7 @@
16711554
"class",
16721555
"introducedName",
16731556
"shadowDeclarations",
1674-
"class",
1675-
"isRegular",
1676-
"isSeeBelow",
1677-
"isImplementationDefined",
1678-
"isDependency"
1557+
"class"
16791558
]
16801559
},
16811560
"ConceptSymbol": {
@@ -1757,13 +1636,6 @@
17571636
"const": "symbol",
17581637
"description": "Tag set to the literal `\"symbol\"`. Lets templates discriminate symbol DOM objects from auxiliary types (`type`, `name`, etc.) without inspecting `kind`."
17591638
},
1760-
"isRegular": {
1761-
"type": "boolean",
1762-
"description": "Convenience boolean equivalent to `extraction === \"dependency\"`."
1763-
},
1764-
"isSeeBelow": "{recursive}",
1765-
"isImplementationDefined": "{recursive}",
1766-
"isDependency": "{recursive}",
17671639
"$meta": {
17681640
"type": "object",
17691641
"properties": {
@@ -1787,11 +1659,7 @@
17871659
"extraction",
17881660
"isCopyFromInherited",
17891661
"parent",
1790-
"class",
1791-
"isRegular",
1792-
"isSeeBelow",
1793-
"isImplementationDefined",
1794-
"isDependency"
1662+
"class"
17951663
]
17961664
},
17971665
"NamedType": {

include/mrdocs/Metadata/Symbol/SymbolBase.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,15 @@ MRDOCS_DESCRIBE_STRUCT(
180180
Extraction, IsCopyFromInherited, Parent, doc)
181181
)
182182

183-
/** Map a Symbol to a dom::Object with computed extraction properties.
183+
/** Map a Symbol to a dom::Object plus a `class` discriminator.
184+
185+
The `class` field is the only synthesized member here: templates
186+
that consume a mixed array of DOM objects use it to tell Symbol
187+
entries apart from Type or Name entries. Everything else comes
188+
from reflection over the described struct, including the
189+
`extraction` enum that templates compare with `(eq extraction
190+
"regular")` etc.
191+
184192
@param io The IO object to map into.
185193
@param I The Symbol to map.
186194
@param domCorpus The DomCorpus context.
@@ -196,10 +204,6 @@ tag_invoke(
196204
MRDOCS_ASSERT(domCorpus);
197205
mapReflectedType<false>(io, I, domCorpus);
198206
io.map("class", std::string("symbol"));
199-
io.map("isRegular", I.Extraction == ExtractionMode::Regular);
200-
io.map("isSeeBelow", I.Extraction == ExtractionMode::SeeBelow);
201-
io.map("isImplementationDefined", I.Extraction == ExtractionMode::ImplementationDefined);
202-
io.map("isDependency", I.Extraction == ExtractionMode::Dependency);
203207
}
204208

205209
//------------------------------------------------

share/mrdocs/addons/generator/adoc/partials/symbol.adoc.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@
249249
{{! Recursive index for multipage global namespace }}
250250
{{#if (and (eq symbol.kind "namespace") @root.config.multipage @root.config.global-namespace-index (eq @root.symbol.kind "namespace") (not @root.symbol.name) (not @root.symbol.parent)) }}
251251
{{#each symbol.members.namespaces}}
252-
{{#if isRegular}}
252+
{{#if (eq extraction "regular")}}
253253
{{#> markup/dynamic-level-h id=null }}{{> symbol/qualified-name . }} namespace{{/markup/dynamic-level-h~}}
254254
{{> symbol symbol=. id=null traversing-global-namespace=true }}
255255
{{/if}}

share/mrdocs/addons/generator/common/partials/symbol/detail/members-table-impl.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{{> symbol/detail/members-table-row . includeBrief=false isName=true}}
1111
{{/each}}
1212
{{ else }}
13-
{{#each (filter_by members "isRegular" "isSeeBelow")}}
13+
{{#each (filter_by_eq members "extraction" "regular" "see-below")}}
1414
{{> symbol/detail/members-table-row . includeBrief=../includeBrief isName=false}}
1515
{{/each}}
1616
{{/if}}

share/mrdocs/addons/generator/common/partials/symbol/members-table.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
1616
--}}
1717
{{#if members}}
18-
{{#if (or (eq members.[0].$meta.type "Name") (any_of_by members "isRegular" "isSeeBelow"))}}
18+
{{#if (or (eq members.[0].$meta.type "Name") (any_of_by_eq members "extraction" "regular" "see-below"))}}
1919
{{#>markup/h level=(select @root.config.multipage (select traversing-global-namespace 2 1) 2)}}{{title}}{{/markup/h}}
2020
{{~>symbol/detail/members-table-impl members=members isName=(eq members.[0].$meta.type "Name") includeBrief=(select (any_of_by members "doc.brief") true false) title=title}}
2121

share/mrdocs/addons/generator/common/partials/symbol/signature/record.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424
final;` is ill-formed (`final` can't be used on a non-defining
2525
declaration). Similarly, don't show a semicolon if there are base
2626
classes. --}}
27-
{{~#isSeeBelow}} { /* see-below */ }{{/isSeeBelow~}}
28-
{{#if (or isSeeBelow (and (not isFinal) (eq (len bases) 0)))}};{{/if}}
27+
{{~#if (eq extraction "see-below")}} { /* see-below */ }{{/if~}}
28+
{{#if (or (eq extraction "see-below") (and (not isFinal) (eq (len bases) 0)))}};{{/if}}

share/mrdocs/addons/generator/common/partials/type/name-infos.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
See: https://mrdocs.com/docs/mrdocs/develop/generators.html#dom_reference
1414
--}}
15-
{{#if id.isImplementationDefined~}}
15+
{{#if (eq id.extraction "implementation-defined")~}}
1616
{{! The name refers to a symbol that's implementation defined. These are special names that should not be linked. ~}}
1717
{{ str '/* '}}implementation-defined{{ str ' */'~}}
1818
{{else~}}

0 commit comments

Comments
 (0)