Skip to content

Commit

Permalink
abigroup: use <p> instead of <pre>.
Browse files Browse the repository at this point in the history
Use of <pre> can interfere with layout when overflowing, so use a
<p> instead (with the same styles).
  • Loading branch information
jessicah committed Aug 21, 2024
1 parent a26fbc5 commit 74d4469
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions extensions/abigroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run(self):
descriptor.ismethod = descriptor.attributes['desctype'] != 'member' and descriptor.attributes['desctype'] != 'enumerator' and descriptor.attributes['desctype'] != 'var'
descriptor.isenum = descriptor.attributes['desctype'] == 'enumerator'
name = self.search(descriptor, addnodes.desc_name)

assert name, 'abi-group: unable to find a function/member'
ix = name.first_child_matching_class(addnodes.desc_sig_name)
title = ''
Expand Down Expand Up @@ -91,7 +91,7 @@ class CustomHTMLTranslator(HTML5Translator):
def __init__(self, document: nodes.document, builder: Builder) -> None:
super().__init__(document, builder)
self.in_abi_group = False

def visit_document(self, node):
path = node.attributes['source']
if path == '<partial node>':
Expand Down Expand Up @@ -144,21 +144,21 @@ def visit_desc(self, node):
self.body.pop()
self.body.append('<br />')
else:
self.body.append('<pre style="background: #f3f3f3; line-height: 2em">')
self.body.append('<p class="pre" style="background: #f3f3f3; line-height: 2em">')

def depart_desc(self, node):
if 'cpp' in node.attributes['classes'] and 'class' in node.attributes['classes']:
return

self.body.append('</pre>')
self.body.append('</p>')

def visit_desc_signature(self, node: Element) -> None:
if not self.in_abi_group:
super().visit_desc_signature(node)

def depart_desc_signature(self, node):
if not self.in_abi_group:
super().depart_desc_signature(node)
super().depart_desc_signature(node)

def visit_desc_signature_line(self, node):
if not self.in_abi_group:
Expand All @@ -168,6 +168,10 @@ def depart_desc_signature_line(self, node):
if not self.in_abi_group:
super().depart_desc_signature_line(node)

# potentially visit_desc_parameterlist
# or visit_desc_type_parameter_list,
# so can wrap parameters into a non-wrapping span

def visit_desc_content(self, node):
if not self.in_abi_group:
super().visit_desc_content(node)
Expand Down

0 comments on commit 74d4469

Please sign in to comment.