Skip to content

Commit 5c9dec2

Browse files
committed
Add a fullyQualifiedTitles option (#187)
By default, the behavior is unchanged, however when set to True, all page titles for structures, unions, classes etc include the namespace as a prefix.
1 parent ebad897 commit 5c9dec2

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

docs/reference/configs.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ something like this, where special treatment is given to File pages specifically
500500
501501
.. autodata:: exhale.configs.includeTemplateParamOrderList
502502

503+
.. autodata:: exhale.configs.fullyQualifiedTitles
504+
503505
.. autodata:: exhale.configs.pageLevelConfigMeta
504506

505507
.. autodata:: exhale.configs.repoRedirectURL

exhale/configs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,23 @@ class and file hierarchies.
840840
other items being documented **only** work in HTML.
841841
'''
842842

843+
fullyQualifiedTitles = False
844+
'''
845+
**Optional**
846+
For Classes, Structs, Enum, Variables, Typedefs, Unions: everything except Functions.
847+
Exhale can generate a fully qualified title on the item page, that is, it will
848+
include the namespace as a prefix to the function. This will thus be reflected
849+
in the table of contents.
850+
851+
**Value in** ``exhale_args`` (bool)
852+
This feature can be useful when you have different items with the same name but
853+
in different namespace, e.g. ``server_side::error`` and ``client_side::error``.
854+
By default, Exhale will generate a page title with the item name only (e.g.
855+
``error``), which might look confusing as there would be multiple entries with the
856+
same name. By setting this to ``True``, all titles and ToC entries will be
857+
qualified with the corresponding namespace.
858+
'''
859+
843860
pageLevelConfigMeta = None
844861
'''
845862
**Optional**
@@ -1505,6 +1522,7 @@ def apply_sphinx_configurations(app):
15051522
("treeViewBootstrapLevels", int),
15061523
# Page Level Customization
15071524
("includeTemplateParamOrderList", bool),
1525+
("fullyQualifiedTitles", bool),
15081526
("pageLevelConfigMeta", six.string_types),
15091527
("repoRedirectURL", six.string_types),
15101528
("contentsDirectives", bool),

exhale/graph.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,24 +2495,28 @@ class view hierarchy (<a href="..."> for the ``createTreeView = True`` option).
24952495
utils.fancyError(
24962496
f"Exhale does not know how to process {node.name}, "
24972497
f"tokenized to {template_tokens}. Please report this bug.")
2498-
class_name = class_name.split("::")[-1]
2498+
if not configs.fullyQualifiedTitles:
2499+
class_name = class_name.split("::")[-1]
24992500

25002501
# Join up the final class name and any potentially skipped templates.
25012502
title = utils.join_template_tokens([class_name] + skipped)
2502-
else:
2503+
elif not configs.fullyQualifiedTitles:
25032504
title = node.name.split("::")[-1]
2505+
else:
2506+
title = node.name
25042507

25052508
# additionally, I feel that nested classes should have their fully qualified
2506-
# name without namespaces for clarity
2507-
prepend_parent = False
2508-
if node.kind in ["class", "struct", "enum", "union"]:
2509-
if node.parent is not None and node.parent.kind in ["class", "struct"]:
2510-
prepend_parent = True
2511-
if prepend_parent:
2512-
title = "{parent}::{child}".format(
2513-
parent=node.parent.name.split("::")[-1],
2514-
child=title
2515-
)
2509+
# name without namespaces for clarity even if the titles are not fully qualified
2510+
if not configs.fullyQualifiedTitles:
2511+
prepend_parent = False
2512+
if node.kind in ["class", "struct", "enum", "union"]:
2513+
if node.parent is not None and node.parent.kind in ["class", "struct"]:
2514+
prepend_parent = True
2515+
if prepend_parent:
2516+
title = "{parent}::{child}".format(
2517+
parent=node.parent.name.split("::")[-1],
2518+
child=title
2519+
)
25162520

25172521
# `unique_id` and `title` should be set approriately for all nodes by this point
25182522
if node.kind in SPECIAL_CASES:

0 commit comments

Comments
 (0)