Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to change subclasses output #966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion breathe/directives/class_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from breathe.renderer.target import create_target_handler

from docutils.nodes import Node
from docutils.parsers.rst.directives import unchanged_required, unchanged, flag
from docutils.parsers.rst.directives import unchanged_required, unchanged, flag, choice

from typing import Any, List

Expand All @@ -27,6 +27,7 @@ class _DoxygenClassLikeDirective(BaseDirective):
"outline": flag,
"no-link": flag,
"allow-dot-graphs": flag,
"subclasses": lambda arg: choice(arg, ["none", "list", "paragraph"]),
}
has_content = False

Expand Down
25 changes: 19 additions & 6 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,13 +1335,26 @@ def render_derivedcompoundref(node):
if node is None:
return []
output = self.render_iterable(node)
if not output:
subclasses = options.get("subclasses", "paragraph")
if not output or subclasses == "none":
return []
return [
nodes.paragraph(
"", "", nodes.Text("Subclassed by "), *intersperse(output, nodes.Text(", "))
)
]
if subclasses == "paragraph":
return [
nodes.paragraph(
"", "", nodes.Text("Subclassed by "), *intersperse(output, nodes.Text(", "))
)
]
if subclasses == "list":
body = nodes.bullet_list()
for o in output:
body.append(nodes.list_item("", nodes.paragraph("", "", o)))
return [
nodes.paragraph(
"", "", nodes.Text("Subclassed by:")
),
body
]
raise RuntimeError(f'Unrecognized "subclasses" option: {options["inheritance"]}')

addnode(
"derivedcompoundref", lambda: render_derivedcompoundref(node.derivedcompoundref)
Expand Down