8000 Render fields with multiple names instead of crashing by jakobandersen · Pull Request #685 · breathe-doc/breathe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Render fields with multiple names instead of crashing #685

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

Merged
merged 1 commit into from
Apr 30, 2021
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
44 changes: 28 additions & 16 deletions breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2105,26 +2105,38 @@ def visit_docparamlist(self, node) -> List[Node]:
for item in node.parameteritem:
# TODO: does item.parameternamelist really have more than 1 parametername?
assert len(item.parameternamelist) <= 1, item.parameternamelist
nameNodes = []
nameNodes: List[Node] = []
parameterDirectionNodes = []
if len(item.parameternamelist) != 0:
paramNameNodes = item.parameternamelist[0].parametername
# TODO: how many elements can paramNameNodes have?
assert len(paramNameNodes) <= 1, paramNameNodes
if len(paramNameNodes) != 0:
content = paramNameNodes[0].content_
# this is really a list of MixedContainer objects, i.e., a generic object
# we assume there is either 1 or 2 elements, if there is 2 the first is the
# parameter direction
assert len(content) == 1 or len(content) == 2, content
nameNodes = self.render(content[-1])
if len(content) == 2:
dir = ''.join(n.astext() for n in self.render(content[0])).strip()
assert dir in ('[in]', '[out]', '[inout]'), ">" + dir + "<"
parameterDirectionNodes = [
nodes.strong(dir, dir),
nodes.Text(' ', ' ')
]
nameNodes = []
for paramName in paramNameNodes:
content = paramName.content_
# this is really a list of MixedContainer objects, i.e., a generic object
# we assume there is either 1 or 2 elements, if there is 2 the first is the
# parameter direction
assert len(content) == 1 or len(content) == 2, content
thisName = self.render(content[-1])
if len(nameNodes) != 0:
if node.kind == 'exception':
msg = "Doxygen \\exception commands with multiple names can not be"
msg += " converted to a single :throws: field in Sphinx."
msg += " Exception '{}' suppresed from output.".format(
''.join(n.astext() for n in thisName))
self.state.document.reporter.warning(msg)
continue
nameNodes.append(nodes.Text(", "))
nameNodes.extend(thisName)
if len(content) == 2:
# note, each paramName node seems to have the same direction,
# so just use the last one
dir = ''.join(n.astext() for n in self.render(content[0])).strip()
assert dir in ('[in]', '[out]', '[inout]'), ">" + dir + "<"
parameterDirectionNodes = [
nodes.strong(dir, dir),
nodes.Text(' ', ' ')
]

name = nodes.field_name(
'', nodes.Text(fieldListName[node.kind] + ' '),
Expand Down
0