From 06d1f00fa1a683f18469582e0580b2d510749c94 Mon Sep 17 00:00:00 2001 From: Fabio Utzig Date: Mon, 15 Feb 2021 20:27:08 -0300 Subject: [PATCH] Add table parsing fixup to merge row types "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 --- breathe/renderer/sphinxrenderer.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/breathe/renderer/sphinxrenderer.py b/breathe/renderer/sphinxrenderer.py index 60dcfb3e..05382a22 100644 --- a/breathe/renderer/sphinxrenderer.py +++ b/breathe/renderer/sphinxrenderer.py @@ -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]: