Skip to content

Commit bd6f6cf

Browse files
DOC: Shrink sphinx extension output
1 parent 79016d9 commit bd6f6cf

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

docs/conf.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,22 @@ def run(self) -> list[nodes.Node]:
198198
heading_text: str = self.options.get("title")
199199
base_repo = f"https://github.com/{this_example['user']}/{this_example['repo']}"
200200
repo_ref = nodes.reference(
201-
name="Source repo", refuri=f"{base_repo}/tree/{this_example['ref']}"
201+
name="Source repo",
202+
text=" Source repo",
203+
refuri=f"{base_repo}/tree/{this_example['ref']}",
202204
)
203-
ref_text = nodes.Text("Source repo")
204-
repo_ref += ref_text
205-
repo_par = nodes.paragraph()
206-
repo_par += repo_ref
207205
normalized_text = re.sub(r"\s", "_", heading_text)
208206
tgt_node = nodes.target(refid=normalized_text)
209207
title_node = nodes.title()
210208
title_text = self.parse_inline(heading_text)[0]
211209
title_node += [*title_text, tgt_node]
212210
content_nodes = self.parse_content_to_nodes()
211+
if isinstance(content_nodes[-1], nodes.paragraph):
212+
repo_par = content_nodes[-1]
213+
else:
214+
repo_par = nodes.paragraph()
215+
content_nodes += [repo_par]
216+
repo_par += repo_ref
213217
toc_items = []
214218
for name, relpath in EXTERNAL_EXAMPLES[key]:
215219
if name:
@@ -229,7 +233,7 @@ def run(self) -> list[nodes.Node]:
229233
state_machine=self.state_machine,
230234
).run()
231235
section_node = nodes.section(ids=[heading_text], names=[heading_text])
232-
section_node += [title_node, *content_nodes, *toc_nodes, repo_par]
236+
section_node += [title_node, *content_nodes, *toc_nodes]
233237
# We need to find section level 1, and be it's child.
234238
parent = self.state.parent
235239
# If section level 1 or 2 haven't been created yet, just insert in position

0 commit comments

Comments
 (0)