Skip to content

Commit

Permalink
Add support for doxygen with interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lacey committed Sep 30, 2013
1 parent 0f7a639 commit 92ea1d0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
6 changes: 6 additions & 0 deletions xsphinx/breathe/breathe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class DoxygenDirectiveFactory(object):
"doxygenfunction" : DoxygenFunctionDirective,
"doxygenstruct" : DoxygenStructDirective,
"doxygenclass" : DoxygenClassDirective,
"doxygeninterface" : DoxygenClassDirective,
"doxygenenum" : DoxygenEnumDirective,
"doxygentypedef" : DoxygenTypedefDirective,
"doxygendefine" : DoxygenDefineDirective,
Expand Down Expand Up @@ -387,6 +388,11 @@ def setup(app):
directive_factory.create_class_directive_container(),
)

app.add_directive(
"doxygeninterface",
directive_factory.create_class_directive_container(),
)

app.add_config_value("breathe_projects", {}, True)
app.add_config_value("breathe_default_project", "", True)

Expand Down
24 changes: 19 additions & 5 deletions xsphinx/breathe/breathe/renderer/rst/doxygen/xmosbreathe.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ def render_content(data_object, tab):
"?",
args)

s = ".. c:function:: " + data_object.definition + args + "\n" + add_indent(s)
args = re.sub("class",
"interface",
args)

fname = data_object.definition
fname = re.sub("[^ ]*::","",fname)
s = ".. c:function:: " + fname + args + "\n" + add_indent(s)
print "Rendering Doxygen function " + data_object.definition
elif data_object.kind == "typedef":
s = ".. c:type:: " + data_object.name + "\n" + add_indent(s)
Expand Down Expand Up @@ -159,6 +165,7 @@ def render_content(data_object, tab):


s = s.replace("___port___port___","port:")
s = re.sub(r'__attribute__(\w*)','[[\\1]]', s)

if s.find('__multret__') != -1:
mult_ret_subs = [ ('{','obrace'),
Expand All @@ -178,7 +185,14 @@ def render_content(data_object, tab):

def render_compoundtype(type_data_object, data_object, state, content, content_offset):

s = ".. c:type:: %s\n" % (type_data_object.name)
is_interface = (type_data_object.get_kind() == 'class')

if is_interface:
name = "interface " + type_data_object.name
else:
name = type_data_object.name

s = ".. c:type:: %s\n" % name

print "Rendering Doxygen struct " + type_data_object.name

Expand All @@ -193,12 +207,12 @@ def render_compoundtype(type_data_object, data_object, state, content, content_o
if sectiondef.kind == "public-attrib":
s += add_indent("**Structure Members:**\n\n")
s += add_indent(render_content(sectiondef,''))

if sectiondef.kind == "private-func":
s += add_indent(render_content(sectiondef,''))

content.data = s.split("\n")

# print str.join("\n",content.data)

#print str.join("\n",content.data)

term = nodes.Element()
state.nested_parse(content, content_offset,term)
Expand Down
20 changes: 16 additions & 4 deletions xsphinx/writers/xlatex.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ def __init__(self, document, builder):
self.in_options = False
self.in_cmd = False
self.in_list_item = False
self.desc_level = 0

def astext(self):
text = HEADER0 % self.elements
Expand Down Expand Up @@ -929,7 +930,13 @@ def visit_desc(self, node):
node['long_params'] = long_params
for x in node.traverse(addnodes.desc_parameter):
x['long_params'] = long_params
if long_params:
#print node.parent.parent
#print node.parent
first_in_section = \
isinstance(node.parent.parent, nodes.section) and \
node.parent.parent.children[1] == node.parent
#print node.parent.parent.children[1]
if long_params and not first_in_section:
self.body.append('\n\\vspace{-1.5\\baselineskip}')
self.body.append('\n\n\\texttt{')
if long_params:
Expand Down Expand Up @@ -958,11 +965,11 @@ def depart_desc_signature(self, node):
self.in_sig = False

def visit_desc_addname(self, node):
self.body.append(r'\optemph{')
#self.body.append(r'\optemph{')
self.literal_whitespace += 1

def depart_desc_addname(self, node):
self.body.append('}')
#self.body.append('}')
self.literal_whitespace -= 1

def visit_desc_type(self, node):
Expand Down Expand Up @@ -1020,15 +1027,19 @@ def depart_desc_annotation(self, node):

def visit_desc_content(self, node):
if node.parent['desctype'] in toplevel_desc:
self.desc_level += 1
if node.parent['long_params']:
self.body.append('\n\\end{tabbing}')
if len(node.children) == 0:
self.body.append('\\vspace{-3mm}\n')

if self.fullwidth:
if self.desc_level > 1:
indent ='0.5\\blockindentlen'
elif self.fullwidth:
indent = '\\blockindentlen'
else:
indent = '\\blockindentlen'

self.body.append('}\n\n')

self.body.append('\\vspace{-2mm}\n')
Expand All @@ -1049,6 +1060,7 @@ def visit_desc_content(self, node):

def depart_desc_content(self, node):
if node.parent['desctype'] in toplevel_desc:
self.desc_level -= 1
if len(node.children) != 0:
self.body.append('\n\\end{indentation*}\n')
#self.body.append('\\vspace{u3mm}\n')
Expand Down
4 changes: 3 additions & 1 deletion xsphinx/xc_prefilter.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import sys, re

# A list of regex substitutions to make
substs = [ ('port:(\d+)','___port___port___\\1')]
substs = [ ('port:(\d+)','___port___port___\\1') ,
('interface', 'class'),
('\[\[(.*)\]\]', '__attribute__\\1') ]


mult_ret_subs = [ ('\{','obrace'),
Expand Down

0 comments on commit 92ea1d0

Please sign in to comment.