Skip to content

Commit

Permalink
Add support for content-only flag when rendering pages
Browse files Browse the repository at this point in the history
Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
  • Loading branch information
gmarull committed Feb 22, 2021
1 parent 4ce8c7a commit 2072d4c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
4 changes: 2 additions & 2 deletions breathe/directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,11 @@ def run(self) -> List[Node]:
kind=self.kind)
return warning.warn('doxygen{kind}: Cannot find {kind} "{name}" {tail}')

if 'content-only' in self.options:
if 'content-only' in self.options and self.kind != "page":
# Unpack the single entry in the matches list
(node_stack,) = matches

filter_ = self.filter_factory.create_content_filter(self.kind, self.options)

# Having found the compound node for the namespace or group in the index we want to grab
# the contents of it which match the filter
contents_finder = self.finder_factory.create_finder_from_root(node_stack[0],
Expand Down Expand Up @@ -404,6 +403,7 @@ class DoxygenPageDirective(_DoxygenContentBlockDirective):
option_spec = {
"path": unchanged_required,
"project": unchanged_required,
"content-only": flag,
}


Expand Down
39 changes: 27 additions & 12 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,25 +1087,40 @@ def render_signature(file_data, doxygen_target, name, kind):

def visit_file(self, node) -> List[Node]:
def render_signature(file_data, doxygen_target, name, kind):
# Build targets for linking
targets = []
targets.extend(doxygen_target)
self.context = cast(RenderContext, self.context)
options = self.context.directive_args[2]

title_signode = addnodes.desc_signature()
title_signode.extend(targets)
if "content-only" in options:
file_data = self.compound_parser.parse(node.refid)
compounddef = file_data.compounddef

# Set up the title
title_signode.append(nodes.emphasis(text=kind))
title_signode.append(nodes.Text(" "))
title_signode.append(addnodes.desc_name(text=name))
# Render title
rst_node = nodes.section()
rst_node['ids'].append(self.get_refid(compounddef.id))
rst_node += nodes.title(compounddef.title.valueOf_, compounddef.title.valueOf_)
else:
rst_node = addnodes.desc()

contentnode = addnodes.desc_content()
# Build targets for linking
targets = []
targets.extend(doxygen_target)

title_signode = addnodes.desc_signature()
title_signode.extend(targets)

# Set up the title
title_signode.append(nodes.emphasis(text=kind))
title_signode.append(nodes.Text(" "))
title_signode.append(addnodes.desc_name(text=name))

rst_node.append(title_signode)

rst_node = addnodes.desc()
rst_node.document = self.state.document
rst_node['objtype'] = kind
rst_node.append(title_signode)

contentnode = addnodes.desc_content()
rst_node.append(contentnode)

return [rst_node], contentnode
return self.visit_compound(node, render_signature=render_signature)

Expand Down

0 comments on commit 2072d4c

Please sign in to comment.