Skip to content

Commit

Permalink
Add table parsing fixup to merge row types
Browse files Browse the repository at this point in the history
"rowspan" is unable to span across different "thead", and "tbody"
elements which make it not useful with the standard row parsing
routines. This commit adds a final step when parsing a table to join all
"thead" and "tbody" rows into just two set of elements.

This still has the limitation that a rowspan from a header won't
span to body elements, but this is not the most usual situation.

Signed-off-by: Fabio Utzig <[email protected]>
  • Loading branch information
utzig committed Feb 16, 2021
1 parent f5e9703 commit 937cbf2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion breathe/renderer/sphinxrenderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,26 @@ def visit_doctable(self, node) -> List[Node]:
colspec.attributes['colwidth'] = 'auto'
tgroup += colspec
table += tgroup
tgroup += self.render_iterable(node.row)
rows = self.render_iterable(node.row)

# this code depends on visit_docrow(), and expects the same elements used to
# "envelop" rows there, namely thead and tbody (eg it will need to be updated
# if Doxygen one day adds support for tfoot)

tags = {row.starttag(): [] for row in rows} # type: Dict[str, List]
for row in rows:
tags[row.starttag()].append(row.next_node())

def merge_row_types(root, elem, elems):
for node in elems:
elem += node
root += elem

for klass in [nodes.thead, nodes.tbody]:
obj = klass()
if obj.starttag() in tags:
merge_row_types(tgroup, obj, tags[obj.starttag()])

return [table]

def visit_mixedcontainer(self, node) -> List[Node]:
Expand Down

0 comments on commit 937cbf2

Please sign in to comment.