Skip to content

Commit 557d4d7

Browse files
glatosinskijbms
authored andcommitted
apidoc: apidoc_formatting: Fixed number references for figures and code listings (#2)
The explicit add_fignumber seems to be excessive - it creates double Fig entries in rendered doc, and also add raw explicit Listing string before code blocks. The add_fignumber is now only called for code listings to add number of listing to code block header Signed-off-by: Grzegorz Latosinski <[email protected]>
1 parent f04bc71 commit 557d4d7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sphinx_immaterial/apidoc/apidoc_formatting.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ def visit_caption(
6161
# This is needed to trigger mkdocs-material CSS rule `.highlight .filename`
6262
self.body.append('<div class="code-block-caption highlight">')
6363
# append a CSS class to trigger mkdocs-material theme's caption CSS style
64-
attributes["class"] += " filename"
64+
# create a span wrapping caption's content and (optionally) number
65+
self.body.append('<span class="filename">')
66+
# append a listing number
67+
self.add_fignumber(node.parent)
68+
self.body.append(self.starttag(node, "span", **attributes))
69+
self.body.append("</span>")
6570
else:
6671
super_func(self, node)
67-
self.add_fignumber(node.parent)
68-
self.body.append(self.starttag(node, "span", **attributes))
72+
self.body.append(self.starttag(node, "span", **attributes))
6973

7074

7175
@html_translator_mixin.override

0 commit comments

Comments
 (0)