Skip to content

Commit

Permalink
Merge pull request #300 from eric-wieser/multiline-template-signature
Browse files Browse the repository at this point in the history
Keep templates on adjacent lines
  • Loading branch information
vermeeren committed May 16, 2018
2 parents 554ddb5 + eda04e8 commit f4f7a71
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,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 @@ -425,9 +427,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 @@ -949,9 +949,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

0 comments on commit f4f7a71

Please sign in to comment.