Skip to content

Commit 4ae305b

Browse files
committed
fix: missing dependent array bounds in the output
This fixes the rendering of e.g.: template<typename T, std::size_t N> void f(T(&)[N]); which was previously rendered without the bound `N` in all the output formats. For Adoc and HTML, the fix is just to fall back to the written expression when the numeric value is absent. For XML, the fix is adding ExprInfo handling in writeElement, *and* this adds several missing elements in the XML output (e.g. initializers and requires clauses), not just array bounds.
1 parent 757d446 commit 4ae305b

37 files changed

Lines changed: 564 additions & 2 deletions

share/mrdocs/addons/generator/common/partials/type/declarator-suffix.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
{{~>type/declarator-suffix pointeeType link-components-impl=link-components-impl~}}
2424
{{else if (eq kind "array")~}}
2525
{{! Array declarator suffix includes bounds and array element suffix ~}}
26-
[{{boundsValue}}]
26+
[{{or boundsValue boundsExpr}}]
2727
{{~>type/declarator-suffix elementType link-components-impl=link-components-impl~}}
2828
{{else if (eq kind "function")~}}
2929
{{! Function declarator suffix includes parameter types and cv-qualifiers ~}}

src/lib/Gen/xml/XMLWriter.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
//
1414

1515
#include "XMLWriter.hpp"
16+
#include <mrdocs/Metadata/Expression.hpp>
1617
#include <mrdocs/Metadata/Type.hpp>
1718
#include <mrdocs/Metadata/Template.hpp>
1819
#include <mrdocs/Metadata/DocComment.hpp>
@@ -177,9 +178,18 @@ XMLWriter::writeElement(std::string_view tag, T const& value)
177178
{ if (!value) return; }
178179
else if constexpr (is_vector<Type>::value)
179180
{ if (value.empty()) return; }
181+
else if constexpr (std::is_base_of_v<ExprInfo, Type>)
182+
{ if (value.Written.empty()) return; }
180183

181184
// Primitives inline, compounds wrapped.
182-
if constexpr (std::is_same_v<Type, bool> ||
185+
if constexpr (std::is_base_of_v<ExprInfo, Type>)
186+
{
187+
// ExprInfo and ConstantExprInfo: write the Written string.
188+
tags_.indent() << "<" << tag << ">";
189+
os_ << xmlEscape(value.Written);
190+
os_ << "</" << tag << ">\n";
191+
}
192+
else if constexpr (std::is_same_v<Type, bool> ||
183193
std::is_same_v<Type, std::string> ||
184194
std::is_same_v<Type, dom::String> ||
185195
std::is_integral_v<Type> ||

test-files/golden-tests/config/auto-function-objects/no-auto-function-objects.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@
252252
<identifier>auto_fn</identifier>
253253
</name>
254254
</named>
255+
<initializer>{}</initializer>
255256
<is-constexpr>1</is-constexpr>
256257
</variable>
257258
</mrdocs>

test-files/golden-tests/config/sfinae/alias.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<extraction>regular</extraction>
3030
<parent>//////////////////////////8=</parent>
3131
<named>
32+
<constraints>C</constraints>
3233
<name>
3334
<kind>identifier</kind>
3435
<identifier>T</identifier>
@@ -68,6 +69,7 @@
6869
<extraction>regular</extraction>
6970
<parent>//////////////////////////8=</parent>
7071
<named>
72+
<constraints>C</constraints>
7173
<name>
7274
<kind>identifier</kind>
7375
<identifier>T</identifier>
@@ -107,6 +109,7 @@
107109
<extraction>regular</extraction>
108110
<parent>//////////////////////////8=</parent>
109111
<named>
112+
<constraints>std::is_class_v&lt;T&gt;</constraints>
110113
<name>
111114
<kind>identifier</kind>
112115
<identifier>T</identifier>
@@ -120,6 +123,7 @@
120123
</type-tparam>
121124
</template>
122125
<func-class>normal</func-class>
126+
<requires>std::is_class_v&lt;T&gt;</requires>
123127
</function>
124128
<function>
125129
<name>f2</name>
@@ -136,6 +140,7 @@
136140
<extraction>regular</extraction>
137141
<parent>//////////////////////////8=</parent>
138142
<named>
143+
<constraints>std::is_class_v&lt;T&gt;</constraints>
139144
<name>
140145
<kind>identifier</kind>
141146
<identifier>T</identifier>
@@ -149,5 +154,6 @@
149154
</type-tparam>
150155
</template>
151156
<func-class>normal</func-class>
157+
<requires>std::is_class_v&lt;T&gt;</requires>
152158
</function>
153159
</mrdocs>

test-files/golden-tests/config/sfinae/redeclare.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
</named>
4646
<param>
4747
<named>
48+
<constraints>std::is_class_v&lt;T&gt;</constraints>
4849
<name>
4950
<kind>identifier</kind>
5051
<identifier>void</identifier>
@@ -59,5 +60,6 @@
5960
</type-tparam>
6061
</template>
6162
<func-class>normal</func-class>
63+
<requires>std::is_class_v&lt;T&gt;</requires>
6264
</function>
6365
</mrdocs>

test-files/golden-tests/config/sfinae/return-based.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<extraction>regular</extraction>
2727
<parent>//////////////////////////8=</parent>
2828
<named>
29+
<constraints>std::is_class_v&lt;T&gt;</constraints>
2930
<name>
3031
<kind>identifier</kind>
3132
<identifier>int</identifier>
@@ -39,5 +40,6 @@
3940
</type-tparam>
4041
</template>
4142
<func-class>normal</func-class>
43+
<requires>std::is_class_v&lt;T&gt;</requires>
4244
</function>
4345
</mrdocs>

test-files/golden-tests/core/libcxx.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
</throws>
7878
</doc-comment>
7979
<named>
80+
<constraints>std::is_integral_v&lt;T&gt;</constraints>
8081
<name>
8182
<kind>identifier</kind>
8283
<identifier>T</identifier>
@@ -99,5 +100,6 @@
99100
</type-tparam>
100101
</template>
101102
<func-class>normal</func-class>
103+
<requires>std::is_integral_v&lt;T&gt;</requires>
102104
</function>
103105
</mrdocs>

test-files/golden-tests/filters/symbol-name/impl-defined-member.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
</name>
125125
</name>
126126
</named>
127+
<initializer>{}</initializer>
127128
<is-constexpr>1</is-constexpr>
128129
</variable>
129130
<variable>
@@ -152,6 +153,7 @@
152153
</name>
153154
</name>
154155
</named>
156+
<initializer>{}</initializer>
155157
<is-constexpr>1</is-constexpr>
156158
</variable>
157159
</mrdocs>

test-files/golden-tests/filters/symbol-type/nested-private-template.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
</type-targ>
117117
<constant-targ>
118118
<kind>constant</kind>
119+
<value>false</value>
119120
</constant-targ>
120121
<primary>7XlFKPcXRfyYPWc4WPN3PAH+m58=</primary>
121122
</template>

test-files/golden-tests/javadoc/copydoc/param-types.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,7 @@
18631863
</param>
18641864
<param>
18651865
<decltype>
1866+
<operand>a</operand>
18661867
</decltype>
18671868
<name>b</name>
18681869
</param>

0 commit comments

Comments
 (0)