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

Fix for admonitions being displayed out of their original context. #910

Open
wants to merge 6 commits 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
1 change: 1 addition & 0 deletions breathe/directives/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def set_temp_data(
app.add_config_value("breathe_use_project_refids", False, "env")
app.add_config_value("breathe_order_parameters_first", False, "env")
app.add_config_value("breathe_separate_member_pages", False, "env")
app.add_config_value("breathe_detaileddesc_pullup_types", {}, True)

breathe_css = "breathe.css"
if os.path.exists(os.path.join(app.confdir, "_static", breathe_css)):
Expand Down
15 changes: 12 additions & 3 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ def description(self, node) -> List[Node]:
return brief + detailed

def detaileddescription(self, node) -> List[Node]:
self.context = cast(RenderContext, self.context)
detailedCand = self.render_optional(node.detaileddescription)
# all field_lists must be at the top-level of the desc_content, so pull them up
fieldLists: List[nodes.field_list] = []
Expand All @@ -885,9 +886,17 @@ def pullup(node, typ, dest):

detailed = []
for candNode in detailedCand:
pullup(candNode, nodes.field_list, fieldLists)
pullup(candNode, nodes.note, admonitions)
pullup(candNode, nodes.warning, admonitions)
breathe_directive_name = self.context.directive_args[0]
pullup_types = self.app.config.breathe_detaileddesc_pullup_types
if breathe_directive_name in pullup_types:
for nodeTypeString in pullup_types[breathe_directive_name]:
if nodeTypeString == "note":
pullup(candNode, nodes.note, admonitions)
elif nodeTypeString == "warning":
pullup(candNode, nodes.warning, admonitions)
elif nodeTypeString == "fieldlist":
pullup(candNode, nodes.field_list, fieldLists)

# and collapse paragraphs
for para in candNode.traverse(nodes.paragraph):
if (
Expand Down
Loading