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 support for content-only flag when rendering pages #645

Merged
merged 2 commits into from
Mar 29, 2021
Merged
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
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
33 changes: 21 additions & 12 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,25 +1087,34 @@ 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]

if "content-only" in options:
rst_node = nodes.container()
else:
rst_node = addnodes.desc()

title_signode = addnodes.desc_signature()
title_signode.extend(targets)
# Build targets for linking
targets = []
targets.extend(doxygen_target)

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

contentnode = addnodes.desc_content()
# 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
4 changes: 3 additions & 1 deletion documentation/source/directives.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,15 @@ page. A doxygen page is created for each "key" of every \\xrefitem command used
for markup in the source comments. For more information check the
`doxygen xrefitem documentation`_.

It takes the standard ``project`` and ``path`` options.
It takes the standard ``project`` and ``path`` options and additionally the
``content-only`` option.

::

.. doxygenpage:: <page name>
:project: ...
:path: ...
:content-only:

Checkout the :ref:`doxygenpage documentation <page-example>` for more details
and to see it in action.
Expand Down