Skip to content

Commit fc564ec

Browse files
anevolbapclaude
andcommitted
docs: strip citekey labels from references page with post-transform
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 150f546 commit fc564ec

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Strip citation labels ([Aba21]) from bibliography entries."""
2+
3+
import docutils.nodes
4+
from sphinx.transforms.post_transforms import SphinxPostTransform
5+
6+
7+
class StripCitationLabels(SphinxPostTransform):
8+
default_priority = 6 # runs right after BibliographyTransform (priority 5)
9+
10+
def run(self):
11+
for node in self.document.findall(docutils.nodes.citation):
12+
for label in node.findall(docutils.nodes.label):
13+
label.parent.remove(label)
14+
for para in node.findall(docutils.nodes.paragraph):
15+
para.insert(0, docutils.nodes.Text("\u2022 "))
16+
break
17+
18+
19+
def setup(app):
20+
app.add_post_transform(StripCitationLabels)
21+
return {"version": "0.1", "parallel_read_safe": True, "parallel_write_safe": True}

docs/source/_static/custom.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Hanging indent for bibliography entries with bullet markers */
2+
.citation[role="doc-biblioentry"] p {
3+
padding-left: 1em;
4+
text-indent: -1em;
5+
}

docs/source/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from causalpy.version import __version__
1616

1717
sys.path.insert(0, os.path.abspath("../"))
18+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "_extensions"))
1819

1920
# autodoc_mock_imports
2021
# This avoids autodoc breaking when it can't find packages imported in the code.
@@ -74,6 +75,7 @@
7475
"sphinx_design",
7576
"sphinx_sitemap",
7677
"sphinx_togglebutton",
78+
"strip_citation_labels",
7779
]
7880

7981
nb_execution_mode = "off"
@@ -154,6 +156,7 @@
154156

155157
html_theme = "labs_sphinx_theme"
156158
html_static_path = ["_static"]
159+
html_css_files = ["custom.css"]
157160
html_extra_path = ["robots.txt"]
158161
html_favicon = "_static/favicon_logo.png"
159162
# Theme options are theme-specific and customize the look and feel of a theme

0 commit comments

Comments
 (0)