Skip to content

Commit 4633c9b

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. Note that, since in AsciiDoc and HTML we emit non-defining declarations, where `final` is illegal, we emit it inside a comment (this makes the emitted code snippet valid code, regardless). This closes issue #963.
1 parent 3327505 commit 4633c9b

File tree

7 files changed

+141
-1
lines changed

7 files changed

+141
-1
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
{{#unless (eq access ../defaultAccess)}} {{access}}{{/unless~}}
1818
{{#if isVirtual}} virtual{{/if}} {{>type/declarator type~}}
1919
{{/each~}}
20-
{{/unless}}{{#isSeeBelow}} { /* see-below */ }{{/isSeeBelow}};
20+
{{/unless}}{{#isSeeBelow}} { /* see-below */ }{{/isSeeBelow}};{{#if isFinal}} /* final */{{/if}}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
= Reference
2+
:mrdocs:
3+
4+
[#index]
5+
== Global namespace
6+
7+
=== Types
8+
9+
[cols=1]
10+
|===
11+
| Name
12+
| link:#A[`A`]
13+
| link:#B[`B`]
14+
|===
15+
16+
[#A]
17+
== A
18+
19+
=== Synopsis
20+
21+
Declared in `&lt;final&lowbar;class&period;cpp&gt;`
22+
23+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
24+
----
25+
class A; /* final */
26+
----
27+
28+
[#B]
29+
== B
30+
31+
=== Synopsis
32+
33+
Declared in `&lt;final&lowbar;class&period;cpp&gt;`
34+
35+
[source,cpp,subs="verbatim,replacements,macros,-callouts"]
36+
----
37+
template&lt;typename T&gt;
38+
class B; /* final */
39+
----
40+
41+
42+
[.small]#Created with https://www.mrdocs.com[MrDocs]#
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class A final
2+
{
3+
};
4+
5+
template< typename T >
6+
class B final
7+
{
8+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<html lang="en">
2+
<head>
3+
<title>Reference</title>
4+
</head>
5+
<body>
6+
<div>
7+
<h1>Reference</h1>
8+
<div>
9+
<div>
10+
<h2 id="index"><a href="#index"></a></h2>
11+
</div>
12+
<h2>Types</h2>
13+
<table style="table-layout: fixed; width: 100%;">
14+
<thead>
15+
<tr>
16+
<th>Name</th>
17+
</tr>
18+
</thead>
19+
<tbody>
20+
<tr>
21+
<td><a href="#A"><code>A</code></a> </td></tr><tr>
22+
<td><a href="#B"><code>B</code></a> </td></tr>
23+
</tbody>
24+
</table>
25+
26+
</div>
27+
<div>
28+
<div>
29+
<h2 id="A"><a href="#A">A</a></h2>
30+
</div>
31+
<div>
32+
<h3>Synopsis</h3>
33+
<div>
34+
Declared in <code>&lt;final_class.cpp&gt;</code></div>
35+
<pre>
36+
<code class="source-code cpp">
37+
class A; /* final */
38+
</code>
39+
</pre>
40+
</div>
41+
42+
43+
</div>
44+
<div>
45+
<div>
46+
<h2 id="B"><a href="#B">B</a></h2>
47+
</div>
48+
<div>
49+
<h3>Synopsis</h3>
50+
<div>
51+
Declared in <code>&lt;final_class.cpp&gt;</code></div>
52+
<pre>
53+
<code class="source-code cpp">
54+
template&lt;typename T&gt;
55+
class B; /* final */
56+
</code>
57+
</pre>
58+
</div>
59+
60+
61+
</div>
62+
63+
</div>
64+
<div>
65+
<h4>Created with <a href="https://www.mrdocs.com">MrDocs</a></h4>
66+
</div>
67+
</body>
68+
</html>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<mrdocs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://github.com/cppalliance/mrdocs/raw/develop/mrdocs.rnc">
4+
<namespace id="//////////////////////////8=">
5+
<class name="A" id="YrPSaKAbmXgzCAX5WByx4eVoqBM=">
6+
<file short-path="final_class.cpp" source-path="final_class.cpp" line="1" class="def"/>
7+
<attr id="is-final"/>
8+
</class>
9+
<template>
10+
<tparam name="T" class="type"/>
11+
<class name="B" id="Bu/3QcmNOdsc7RSM3OKHnuCxGPU=">
12+
<file short-path="final_class.cpp" source-path="final_class.cpp" line="5" class="def"/>
13+
<attr id="is-final"/>
14+
</class>
15+
</template>
16+
</namespace>
17+
</mrdocs>

0 commit comments

Comments
 (0)