Skip to content

Commit cb93838

Browse files
author
Gennaro Prota
committed
feat: AsciiDoc and HTML outputs support the final specifier for classes and class templates
This was already supported in XML. In this commit, we also remove the semicolon when that would produce invalid C++ code, e.g. in class A final; or class A : B1, B2; Instead, "{ /* see-below */ }" is now always followed by a semicolon, even if the record is final and/or base classes are present. This closes issue #963.
1 parent 3327505 commit cb93838

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+551
-201
lines changed

docs/modules/ROOT/pages/generators.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ When the symbol kind is `record` (e.g., `class`, `struct`, `union`), the symbol
258258
| `string`
259259
| The default access level of the record members (e.g., `public`, `private`).
260260

261+
| `isFinal`
262+
| `bool`
263+
| Whether the record is final.
264+
261265
| `isTypedef`
262266
| `bool`
263267
| Whether the record is a typedef.

include/mrdocs/Metadata/Info/Record.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ tag_invoke(
353353
tag_invoke(t, io, dynamic_cast<Info const&>(I), domCorpus);
354354
io.map("tag", I.KeyKind);
355355
io.map("defaultAccess", getDefaultAccessString(I.KeyKind));
356+
io.map("isFinal", I.IsFinal);
356357
io.map("isTypedef", I.IsTypeDef);
357358
io.map("bases", dom::LazyArray(I.Bases, domCorpus));
358359
io.map("derived", dom::LazyArray(I.Derived, domCorpus));

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
{{~else~}}
77
{{>symbol/name-text symbol ~}}
88
{{~/if}}
9+
{{~#if isFinal}} final{{/if~}}
910
{{#unless bases~}}
1011
{{else if isFriend~}}
1112
{{else}}
@@ -17,4 +18,11 @@
1718
{{#unless (eq access ../defaultAccess)}} {{access}}{{/unless~}}
1819
{{#if isVirtual}} virtual{{/if}} {{>type/declarator type~}}
1920
{{/each~}}
20-
{{/unless}}{{#isSeeBelow}} { /* see-below */ }{{/isSeeBelow}};
21+
{{/unless}}
22+
{{!-- Unless we are going to show a class body ("{ ... }"), don't add a
23+
semicolon if the record is final, because something like `class A
24+
final;` is ill-formed (`final` can't be used on a non-defining
25+
declaration). Similarly, don't show a semicolon if there are base
26+
classes. --}}
27+
{{~#unless (or isSeeBelow isFinal bases)}};{{/unless~}}
28+
{{~#isSeeBelow}} { /* see-below */ };{{/isSeeBelow~}}

test-files/golden-tests/config/auto-relates/derived.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Declared in `&lt;derived&period;cpp&gt;`
5252
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
5353
----
5454
struct A
55-
: link:#ABase[ABase];
55+
: link:#ABase[ABase]
5656
----
5757

5858
=== Base Classes
@@ -141,7 +141,7 @@ Declared in `&lt;derived&period;cpp&gt;`
141141
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
142142
----
143143
struct AView
144-
: link:#ABase[ABase];
144+
: link:#ABase[ABase]
145145
----
146146

147147
=== Base Classes
@@ -194,7 +194,7 @@ Declared in `&lt;derived&period;cpp&gt;`
194194
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
195195
----
196196
struct AView2
197-
: link:#AView[AView];
197+
: link:#AView[AView]
198198
----
199199

200200
=== Base Classes

test-files/golden-tests/config/auto-relates/derived.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ <h3>Synopsis</h3>
6161
<pre>
6262
<code class="source-code cpp">
6363
struct A
64-
: <a href="#ABase">ABase</a>;
64+
: <a href="#ABase">ABase</a>
6565
</code>
6666
</pre>
6767
</div>
@@ -172,7 +172,7 @@ <h3>Synopsis</h3>
172172
<pre>
173173
<code class="source-code cpp">
174174
struct AView
175-
: <a href="#ABase">ABase</a>;
175+
: <a href="#ABase">ABase</a>
176176
</code>
177177
</pre>
178178
</div>
@@ -241,7 +241,7 @@ <h3>Synopsis</h3>
241241
<pre>
242242
<code class="source-code cpp">
243243
struct AView2
244-
: <a href="#AView">AView</a>;
244+
: <a href="#AView">AView</a>
245245
</code>
246246
</pre>
247247
</div>

test-files/golden-tests/config/extract-implicit-specializations/base.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Declared in `&lt;base&period;cpp&gt;`
2323
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
2424
----
2525
struct A
26-
: link:#B[B];
26+
: link:#B[B]
2727
----
2828

2929
=== Base Classes

test-files/golden-tests/config/extract-implicit-specializations/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h3>Synopsis</h3>
3535
<pre>
3636
<code class="source-code cpp">
3737
struct A
38-
: <a href="#B">B</a>;
38+
: <a href="#B">B</a>
3939
</code>
4040
</pre>
4141
</div>

test-files/golden-tests/config/extract-implicit-specializations/extract-implicit-specializations.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Declared in `&lt;extract&hyphen;implicit&hyphen;specializations&period;cpp&gt;`
2323
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
2424
----
2525
struct A
26-
: link:#B-00[B&lt;int&gt;];
26+
: link:#B-00[B&lt;int&gt;]
2727
----
2828

2929
=== Base Classes

test-files/golden-tests/config/extract-implicit-specializations/extract-implicit-specializations.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h3>Synopsis</h3>
3535
<pre>
3636
<code class="source-code cpp">
3737
struct A
38-
: <a href="#B-00">B&lt;int&gt;</a>;
38+
: <a href="#B-00">B&lt;int&gt;</a>
3939
</code>
4040
</pre>
4141
</div>

test-files/golden-tests/config/extract-implicit-specializations/no-extract-implicit-specializations.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Declared in `&lt;no&hyphen;extract&hyphen;implicit&hyphen;specializations&period
2323
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
2424
----
2525
struct A
26-
: link:#B[B&lt;int&gt;];
26+
: link:#B[B&lt;int&gt;]
2727
----
2828

2929
=== Base Classes

0 commit comments

Comments
 (0)