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

Keep templates on adjacent lines #300

Merged
Merged
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
16 changes: 7 additions & 9 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,17 +235,19 @@ def get_fully_qualified_name(self):

return '::'.join(names)

def create_template_node(self, decl):
def insert_template_node(self, signature, decl):
"""Creates a node for the ``template <...>`` part of the declaration."""
if not decl.templateparamlist:
return None
template = 'template '
nodes = [self.node_factory.desc_annotation(template, template), self.node_factory.Text('<')]
nodes.extend(self.render(decl.templateparamlist))
nodes.append(self.node_factory.Text(">"))
signode = self.node_factory.desc_signature()

signode = type(signature)()
signode.extend(nodes)
return signode

signature.parent.insert(0, signode)

def run_domain_directive(self, kind, names):
domain_directive = DomainDirectiveFactory.create(
Expand Down Expand Up @@ -377,9 +379,7 @@ def render_signature(file_data, doxygen_target, name, kind):
finder.declarator[0] = self.node_factory.desc_annotation(kind + ' ', kind + ' ')

# Check if there is template information and format it as desired
template_signode = self.create_template_node(file_data.compounddef)
if template_signode:
rst_node.insert(0, template_signode)
self.insert_template_node(finder.declarator, file_data.compounddef)
rst_node.children[0].insert(0, doxygen_target)
return nodes, finder.content

Expand Down Expand Up @@ -892,9 +892,7 @@ def visit_function(self, node):

finder.content.extend(self.description(node))

template_node = self.create_template_node(node)
if template_node:
rst_node.insert(0, template_node)
self.insert_template_node(finder.declarator, node)
return nodes

def visit_define(self, node):
Expand Down