Skip to content

Commit d940074

Browse files
committed
feat: support the final specifier for classes and class templates, in AsciiDoc and HTML
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 d66da79 commit d940074

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+
{{~#isSeeBelow}} { /* see-below */ }{{/isSeeBelow~}}
28+
{{#if (or isSeeBelow (and (not isFinal) (eq (len bases) 0)))}};{{/if}}

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
@@ -60,7 +60,7 @@ <h3>Synopsis</h3>
6060
Declared in <code>&lt;derived.cpp&gt;</code></div>
6161
<pre>
6262
<code class="source-code cpp">struct A
63-
: <a href="#ABase">ABase</a>;
63+
: <a href="#ABase">ABase</a>
6464

6565
</code>
6666
</pre>
@@ -171,7 +171,7 @@ <h3>Synopsis</h3>
171171
Declared in <code>&lt;derived.cpp&gt;</code></div>
172172
<pre>
173173
<code class="source-code cpp">struct AView
174-
: <a href="#ABase">ABase</a>;
174+
: <a href="#ABase">ABase</a>
175175

176176
</code>
177177
</pre>
@@ -240,7 +240,7 @@ <h3>Synopsis</h3>
240240
Declared in <code>&lt;derived.cpp&gt;</code></div>
241241
<pre>
242242
<code class="source-code cpp">struct AView2
243-
: <a href="#AView">AView</a>;
243+
: <a href="#AView">AView</a>
244244

245245
</code>
246246
</pre>

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
@@ -34,7 +34,7 @@ <h3>Synopsis</h3>
3434
Declared in <code>&lt;base.cpp&gt;</code></div>
3535
<pre>
3636
<code class="source-code cpp">struct A
37-
: <a href="#B">B</a>;
37+
: <a href="#B">B</a>
3838

3939
</code>
4040
</pre>

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
@@ -34,7 +34,7 @@ <h3>Synopsis</h3>
3434
Declared in <code>&lt;extract-implicit-specializations.cpp&gt;</code></div>
3535
<pre>
3636
<code class="source-code cpp">struct A
37-
: <a href="#B-00">B&lt;int&gt;</a>;
37+
: <a href="#B-00">B&lt;int&gt;</a>
3838

3939
</code>
4040
</pre>

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)