Skip to content

Commit 00a0fb9

Browse files
committed
invert rendering of name and object
1 parent 215a326 commit 00a0fb9

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/sphinx_fortran_domain/directives.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ def _append_object_description(
524524
signode = addnodes.desc_signature()
525525
# Keep signature rendering simple and stable: show the parsed signature text
526526
# as a literal inside the signature node.
527-
text = signature if signature else f"{objtype} {name}"
527+
text = signature if signature else f"{name} ({objtype})"
528528
signode += nodes.literal(text=str(text))
529529
desc += signode
530530

@@ -609,7 +609,7 @@ def run(self):
609609
anchor = nodes.make_id(f"f-program-{progname}")
610610
index = addnodes.index(entries=[("single", f"{progname} (program)", anchor, "", None)])
611611
section = nodes.section(ids=[anchor])
612-
section += nodes.title(text=f"Program {progname}")
612+
section += nodes.title(text=f"{progname} (program)")
613613
getattr(domain, "note_object")(name=progname, objtype="program", anchor=anchor)
614614

615615
if program is None:
@@ -661,7 +661,7 @@ def run(self):
661661
index["entries"].append(("single", f"{p.name} ({kind})", obj_anchor, "", None))
662662

663663
sub = nodes.section(ids=[obj_anchor])
664-
sub += nodes.title(text=f"{kind.capitalize()} {p.name}")
664+
sub += nodes.title(text=f"{p.name} ({kind})")
665665
_append_object_description(
666666
sub,
667667
domain="f",
@@ -690,7 +690,7 @@ def run(self):
690690
anchor = nodes.make_id(f"f-module-{modname}")
691691
index = addnodes.index(entries=[("single", f"{modname} (module)", anchor, "", None)])
692692
section = nodes.section(ids=[anchor])
693-
section += nodes.title(text=f"Module {modname}")
693+
section += nodes.title(text=f"{modname} (module)")
694694
getattr(domain, "note_object")(name=modname, objtype="module", anchor=anchor)
695695

696696
if module is None:
@@ -707,7 +707,7 @@ def run(self):
707707
index["entries"].append(("single", f"{t.name} (type)", obj_anchor, "", None))
708708

709709
sub = nodes.section(ids=[obj_anchor])
710-
sub += nodes.title(text=f"Type {t.name}")
710+
sub += nodes.title(text=f"{t.name} (type)")
711711
_append_object_description(
712712
sub,
713713
domain="f",
@@ -732,7 +732,7 @@ def run(self):
732732
index["entries"].append(("single", f"{p.name} ({kind})", obj_anchor, "", None))
733733

734734
sub = nodes.section(ids=[obj_anchor])
735-
sub += nodes.title(text=f"{kind.capitalize()} {p.name}")
735+
sub += nodes.title(text=f"{p.name} ({kind})")
736736
_append_object_description(
737737
sub,
738738
domain="f",
@@ -755,7 +755,7 @@ def run(self):
755755
index["entries"].append(("single", f"{g.name} (interface)", obj_anchor, "", None))
756756

757757
sub = nodes.section(ids=[obj_anchor])
758-
sub += nodes.title(text=f"Interface {g.name}")
758+
sub += nodes.title(text=f"{g.name} (interface)")
759759
_append_doc(sub, getattr(g, "doc", None), self.state)
760760
section += sub
761761

@@ -773,7 +773,7 @@ def run(self):
773773
anchor = nodes.make_id(f"f-submodule-{submodname}")
774774
index = addnodes.index(entries=[("single", f"{submodname} (submodule)", anchor, "", None)])
775775
section = nodes.section(ids=[anchor])
776-
section += nodes.title(text=f"Submodule {submodname}")
776+
section += nodes.title(text=f"{submodname} (submodule)")
777777
getattr(domain, "note_object")(name=submodname, objtype="submodule", anchor=anchor)
778778

779779
if submodule is None:
@@ -790,7 +790,7 @@ def run(self):
790790
index["entries"].append(("single", f"{t.name} (type)", obj_anchor, "", None))
791791

792792
sub = nodes.section(ids=[obj_anchor])
793-
sub += nodes.title(text=f"Type {t.name}")
793+
sub += nodes.title(text=f"{t.name} (type)")
794794
_append_object_description(
795795
sub,
796796
domain="f",
@@ -815,7 +815,7 @@ def run(self):
815815
index["entries"].append(("single", f"{p.name} ({kind})", obj_anchor, "", None))
816816

817817
sub = nodes.section(ids=[obj_anchor])
818-
sub += nodes.title(text=f"{kind.capitalize()} {p.name}")
818+
sub += nodes.title(text=f"{p.name} ({kind})")
819819
_append_object_description(
820820
sub,
821821
domain="f",
@@ -838,7 +838,7 @@ def run(self):
838838
index["entries"].append(("single", f"{g.name} (interface)", obj_anchor, "", None))
839839

840840
sub = nodes.section(ids=[obj_anchor])
841-
sub += nodes.title(text=f"Interface {g.name}")
841+
sub += nodes.title(text=f"{g.name} (interface)")
842842
_append_doc(sub, getattr(g, "doc", None), self.state)
843843
section += sub
844844

tests/test_reference_plugin_integration.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ def test_reference_lexer_plugin_end_to_end(tmp_path: Path) -> None:
102102

103103
# Sanity check: the module page should have rendered.
104104
index_html = (out_dir / "index.html").read_text(encoding="utf-8", errors="replace")
105-
assert "Module mymod" in index_html
105+
assert "mymod (module)" in index_html
106106
assert "This is a test module" in index_html
107107
# Our module should include a type and a procedure.
108-
assert "Type vec" in index_html
108+
assert "vec (type)" in index_html
109109
assert "x" in index_html
110110
assert "x component docs" in index_html.lower()
111-
assert "Function add_one" in index_html
111+
assert "add_one (function)" in index_html
112112
assert "Add one to x" in index_html

0 commit comments

Comments
 (0)