Skip to content

Commit 860c3cb

Browse files
committed
documentation/doxygen: added support for C++20 concepts
also: - fixed `static` and `constexpr` leaking into variables (basically the same problem as #228) - fixed a few tests that were broken with Doxygen 1.9.0+ - added support for C++20's `constinit`
1 parent 0da0306 commit 860c3cb

11 files changed

Lines changed: 168 additions & 63 deletions

File tree

documentation/doxygen.py

Lines changed: 92 additions & 48 deletions
Large diffs are not rendered by default.

documentation/templates/doxygen/annotated.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
<h1>Classes</h1>
66
<ul class="m-doc">
77
{% for i in index.symbols recursive %}
8-
{% if i.children %}
8+
{% if i.children and i.has_class_descendents %}
99
<li class="m-doc-collapsible{% if loop.depth > CLASS_INDEX_EXPAND_LEVELS or (i.kind != 'namespace' and not CLASS_INDEX_EXPAND_INNER) %} collapsed{% endif %}">
1010
<a href="#" onclick="return toggle(this)">{{ i.kind }}</a> <a href="{{ i.url }}" class="m-doc">{{ i.name }}</a>{% if i.is_inline %} <span class="m-label m-flat m-info">inline</span>{% endif %}{% if i.is_final %} <span class="m-label m-flat m-warning">final</span>{% endif %}{% if i.deprecated %} <span class="m-label m-danger">{{ i.deprecated }}</span>{% endif %}{% if i.since %} {{ i.since }}{% endif %} <span class="m-doc">{{ i.brief }}</span>
1111
<ul class="m-doc">
1212
{{ loop(i.children)|rtrim|indent(4, true) }}
1313
</ul>
1414
</li>
15-
{% else %}
15+
{% elif i.kind in ('class', 'struct', 'union') %}
1616
<li>{{ i.kind }} <a href="{{ i.url }}" class="m-doc">{{ i.name }}</a>{% if i.is_inline %} <span class="m-label m-flat m-info">inline</span>{% endif %}{% if i.is_final %} <span class="m-label m-flat m-warning">final</span>{% endif %}{% if i.deprecated %} <span class="m-label m-danger">{{ i.deprecated }}</span>{% endif %}{% if i.since %} {{ i.since }}{% endif %} <span class="m-doc">{{ i.brief }}</span></li>
1717
{% endif %}
1818
{% endfor %}

documentation/templates/doxygen/base-class-reference.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{% extends 'base.html' %}
22

33
{% macro entry_class(class) %}{% include 'entry-class.html' %}{% endmacro %}
4+
{% macro entry_concept(concept) %}{% include 'entry-concept.html' %}{% endmacro %}
45
{% macro entry_typedef(typedef, mark_nonpublic=False) %}{% include 'entry-typedef.html' %}{% endmacro %}
56
{% macro entry_enum(enum, mark_nonpublic=False) %}{% include 'entry-enum.html' %}{% endmacro %}
67
{% macro entry_func(func, mark_nonpublic=False) %}{% include 'entry-func.html' %}{% endmacro %}
@@ -166,6 +167,8 @@ <h2><a href="#pub-types">Public types</a></h2>
166167
{% for kind, type in compound.public_types %}
167168
{% if kind == 'class' %}
168169
{{ entry_class(type) }}
170+
{% elif kind == 'concept' %}
171+
{{ entry_concept(type) }}
169172
{% elif kind == 'enum' %}
170173
{{ entry_enum(type) }}
171174
{% elif kind == 'typedef' %}
@@ -252,6 +255,8 @@ <h2><a href="#pro-types">Protected types</a></h2>
252255
{% for kind, type in compound.protected_types %}
253256
{% if kind == 'class' %}
254257
{{ entry_class(type) }}
258+
{% elif kind == 'concept' %}
259+
{{ entry_concept(type) }}
255260
{% elif kind == 'enum' %}
256261
{{ entry_enum(type) }}
257262
{% elif kind == 'typedef' %}

documentation/templates/doxygen/base-reference.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{% macro entry_file(file) %}{% include 'entry-file.html' %}{% endmacro %}
88
{% macro entry_namespace(namespace) %}{% include 'entry-namespace.html' %}{% endmacro %}
99
{% macro entry_class(class) %}{% include 'entry-class.html' %}{% endmacro %}
10+
{% macro entry_concept(concept) %}{% include 'entry-concept.html' %}{% endmacro %}
1011
{% macro entry_enum(enum) %}{% include 'entry-enum.html' %}{% endmacro %}
1112
{% macro entry_typedef(typedef) %}{% include 'entry-typedef.html' %}{% endmacro %}
1213
{% macro entry_func(func) %}{% include 'entry-func.html' %}{% endmacro %}
@@ -25,7 +26,7 @@
2526
{% if compound.brief %}
2627
<p>{{ compound.brief }}</p>
2728
{% endif %}
28-
{% if compound.sections or compound.modules or compound.dirs or compound.files or compound.namespaces or compound.classes or compound.typedefs or compound.funcs or compound.vars or compound.defines or compound.groups %}
29+
{% if compound.sections or compound.modules or compound.dirs or compound.files or compound.namespaces or compound.classes or compound.concepts or compound.typedefs or compound.funcs or compound.vars or compound.defines or compound.groups %}
2930
<nav class="m-block m-default">
3031
<h3>Contents</h3>
3132
<ul>
@@ -41,7 +42,7 @@ <h3>Contents</h3>
4142
<li><a href="#{{ id }}">{{ name }}</a></li>
4243
{% endif %}
4344
{% endfor %}
44-
{% if compound.modules or compound.dirs or compound.files or compound.namespaces or compound.classes or compound.typedefs or compound.funcs or compound.vars or compound.defines or compound.groups %}
45+
{% if compound.modules or compound.dirs or compound.files or compound.namespaces or compound.classes or compound.concepts or compound.typedefs or compound.funcs or compound.vars or compound.defines or compound.groups %}
4546
<li>
4647
Reference
4748
<ul>
@@ -60,6 +61,9 @@ <h3>Contents</h3>
6061
{% if compound.classes %}
6162
<li><a href="#nested-classes">Classes</a></li>
6263
{% endif %}
64+
{% if compound.concepts %}
65+
<li><a href="#nested-concepts">Concepts</a></li>
66+
{% endif %}
6367
{% if compound.enums %}
6468
<li><a href="#enum-members">Enums</a></li>
6569
{% endif %}
@@ -137,6 +141,16 @@ <h2><a href="#nested-classes">Classes</a></h2>
137141
</dl>
138142
</section>
139143
{% endif %}
144+
{% if compound.concepts %}
145+
<section id="nested-concepts">
146+
<h2><a href="#nested-concepts">Concepts</a></h2>
147+
<dl class="m-doc">
148+
{% for concept in compound.concepts %}
149+
{{ entry_concept(concept) }}
150+
{% endfor %}
151+
</dl>
152+
</section>
153+
{% endif %}
140154
{% if compound.enums %}
141155
<section id="enum-members">
142156
<h2><a href="#enum-members">Enums</a></h2>
@@ -199,6 +213,8 @@ <h2><a href="#{{ group.id }}">{{ group.name }}</a></h2>
199213
{{ entry_namespace(member) }}
200214
{% elif kind == 'class' %}
201215
{{ entry_class(member) }}
216+
{% elif kind == 'concept' %}
217+
{{ entry_concept(member) }}
202218
{% elif kind == 'enum' %}
203219
{{ entry_enum(member) }}
204220
{% elif kind == 'typedef' %}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{% extends 'base-class-reference.html' %}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% set navbar_current = 'concepts' %}
2+
{% extends 'base-index.html' %}
3+
4+
{% block main %}
5+
<h1>Concepts</h1>
6+
<ul class="m-doc">
7+
{% for i in index.symbols recursive %}
8+
{% if i.children and i.has_concept_descendents %}
9+
<li class="m-doc-collapsible{% if loop.depth > CLASS_INDEX_EXPAND_LEVELS or (i.kind != 'namespace' and not CLASS_INDEX_EXPAND_INNER) %} collapsed{% endif %}">
10+
<a href="#" onclick="return toggle(this)">{{ i.kind }}</a> <a href="{{ i.url }}" class="m-doc">{{ i.name }}</a>{% if i.deprecated %} <span class="m-label m-danger">{{ i.deprecated }}</span>{% endif %}{% if i.since %} {{ i.since }}{% endif %} <span class="m-doc">{{ i.brief }}</span>
11+
<ul class="m-doc">
12+
{{ loop(i.children)|rtrim|indent(4, true) }}
13+
</ul>
14+
</li>
15+
{% elif i.kind == 'concept' %}
16+
<li>{{ i.kind }} <a href="{{ i.url }}" class="m-doc">{{ i.name }}</a>{% if i.deprecated %} <span class="m-label m-danger">{{ i.deprecated }}</span>{% endif %}{% if i.since %} {{ i.since }}{% endif %} <span class="m-doc">{{ i.brief }}</span></li>
17+
{% endif %}
18+
{% endfor %}
19+
</ul>
20+
{{ super() -}}
21+
{% endblock %}

documentation/templates/doxygen/details-var.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h3>
1515
{% endif %}
1616
</div>
1717
{% endif %}
18-
{%+ if var.is_static %}static {% endif %}{{ var.type }} {{ prefix }}<a href="#{{ var.id }}" class="m-doc-self">{{ var.name }}</a>{% if var.is_protected %} <span class="m-label m-warning">protected</span>{% endif %}{% if var.is_constexpr %} <span class="m-label m-primary">constexpr</span>{% endif %}{% if var.since %} {{ var.since }}{% endif %}
18+
{%+ if var.is_static %}static {% endif %}{{ var.type }} {{ prefix }}<a href="#{{ var.id }}" class="m-doc-self">{{ var.name }}</a>{% if var.is_protected %} <span class="m-label m-warning">protected</span>{% endif %}{% if var.is_constexpr %} <span class="m-label m-primary">constexpr</span>{% endif %}{% if var.is_constinit %} <span class="m-label m-primary">constinit</span>{% endif %}{% if var.since %} {{ var.since }}{% endif %}
1919
{# the empty line needs to be here to prevent the lines from merging #}
2020

2121
{% if var.include and compound.templates == None and var.templates == None %}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<dt>
2+
{% if concept.templates != None %}
3+
{% set j = joiner(', ') %}
4+
<div class="m-doc-template">template&lt;{% for t in concept.templates %}{{ j() }}{{ t.type }}{% if t.name %} {{ t.name }}{% endif %}{% if t.default %} = {{ t.default }}{% endif %}{% endfor %}&gt;</div>
5+
{% endif %}
6+
{{ concept.kind }} <a href="{{ concept.url }}" class="m-doc">{{ concept.name }}</a>{% if concept.is_protected %} <span class="m-label m-flat m-warning">protected</span>{% endif %}{% if concept.deprecated %} <span class="m-label m-danger">{{ concept.deprecated }}</span>{% endif %}{% if concept.since %} {{ concept.since }}{% endif %}
7+
8+
{# the empty line is above to fix spacing #}
9+
</dt>
10+
<dd>{{ concept.brief }}</dd>

documentation/test_doxygen/compound_listing/annotated.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
<div class="m-col-l-10 m-push-l-1">
3838
<h1>Classes</h1>
3939
<ul class="m-doc">
40-
<li>namespace <a href="namespaceAnother.html" class="m-doc">Another</a> <span class="m-doc">Another namespace.</span></li>
4140
<li class="m-doc-collapsible">
4241
<a href="#" onclick="return toggle(this)">namespace</a> <a href="namespaceRoot.html" class="m-doc">Root</a> <span class="m-doc">Root namespace.</span>
4342
<ul class="m-doc">

documentation/test_doxygen/compound_listing/classRoot_1_1Directory_1_1Sub_1_1Class.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ <h2><a href="#pub-types">Public types</a></h2>
9999
<h2><a href="#pub-static-attribs">Public static variables</a></h2>
100100
<dl class="m-doc">
101101
<dt id="a912d8f1390853f90e0a9f19ec98771e6">
102-
static static int <a href="#a912d8f1390853f90e0a9f19ec98771e6" class="m-doc-self">Size</a> <span class="m-label m-flat m-primary">constexpr</span>
102+
static int <a href="#a912d8f1390853f90e0a9f19ec98771e6" class="m-doc-self">Size</a> <span class="m-label m-flat m-primary">constexpr</span>
103103
</dt>
104104
<dd>A public static var.</dd>
105105
</dl>

0 commit comments

Comments
 (0)