Skip to content

Commit bad8ad1

Browse files
committed
translator: simplify v2 autodocs renderings
The following commit simplifies the markup content generated for autodocs related nodes. Attempts to gracefully format with various workarounds (e.g. nesting with panels and layouts) seems to constantly change as Confluence updates its ADF processing. There does not appear to be a perfect way to layout autodocs content -- so we will no longer try (that much). We will rely on panels for now (since it appears the only way to do some level of block indentation of content without borders/colors), and all other field entries will be just added into simple paragraphs. This allows the content to be somewhat readable for users and does not add a lot of tags that makes the viewing experience slow on v2 editors. We can look at this in the future if there are either alternative ways to render autodocs, or get to a point where we may not even bother. Signed-off-by: James Knight <[email protected]>
1 parent c01af01 commit bad8ad1

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

sphinxcontrib/confluencebuilder/storage/translator.py

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -575,32 +575,16 @@ def depart_field_list(self, node):
575575
self.body.append(self.context.pop()) # table
576576

577577
def visit_field(self, node):
578-
if self.v2:
579-
self.body.append(self._start_tag(node, 'ac:layout'))
580-
self.context.append(self._end_tag(node, suffix=''))
581-
582-
self.body.append(self._start_tag(node, 'ac:layout-section',
583-
**{
584-
'ac:type': 'two_left_sidebar',
585-
'ac:breakout-mode': 'default',
586-
}))
587-
self.context.append(self._end_tag(node))
588-
else:
578+
if not self.v2:
589579
self.body.append(self._start_tag(node, 'tr', suffix=self.nl))
590580
self.context.append(self._end_tag(node))
591581

592582
def depart_field(self, node):
593-
if self.v2:
594-
self.body.append(self.context.pop()) # ac:layout-section
595-
self.body.append(self.context.pop()) # ac:layout
596-
else:
583+
if not self.v2:
597584
self.body.append(self.context.pop()) # tr
598585

599586
def visit_field_name(self, node):
600-
if self.v2:
601-
self.body.append(self._start_tag(node, 'ac:layout-cell'))
602-
self.context.append(self._end_tag(node))
603-
else:
587+
if not self.v2:
604588
self.body.append(self._start_tag(node, 'td',
605589
**{'style': 'border: none'}))
606590
self.context.append(self._end_tag(node))
@@ -612,22 +596,18 @@ def depart_field_name(self, node):
612596
self.body.append(':')
613597
self.body.append(self.context.pop()) # strong
614598

615-
if self.v2:
616-
self.body.append(self.context.pop()) # ac:layout-cell
617-
else:
599+
if not self.v2:
618600
self.body.append(self.context.pop()) # td
619601

620602
def visit_field_body(self, node):
621-
if self.v2:
622-
self.body.append(self._start_tag(node, 'ac:layout-cell'))
623-
else:
603+
if not self.v2:
624604
self.body.append(self._start_tag(node, 'td',
625605
**{'style': 'border: none'}))
626-
627-
self.context.append(self._end_tag(node))
606+
self.context.append(self._end_tag(node))
628607

629608
def depart_field_body(self, node):
630-
self.body.append(self.context.pop()) # td/ac:layout-cell
609+
if not self.v2:
610+
self.body.append(self.context.pop()) # td
631611

632612
# -----------------------------
633613
# body elements -- option lists

0 commit comments

Comments
 (0)