Skip to content

Commit 153d384

Browse files
committed
docs: give generated API stubs explicit page titles
The stubs have no H1 of their own, so their pages fell back to the title Index — which is what navigation.prune shows on collapsed nav rows (every collapsed API subtree rendered as 'Index'), and what browser tabs and search results display.
1 parent e927853 commit 153d384

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

scripts/docs/gen_ref_pages.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def generate() -> list[NavItem]:
153153

154154
ident = ".".join(parts)
155155
documented.add(ident)
156-
stubs[API_DIR / doc_path] = f"::: {ident}\n"
156+
# Explicit titles: the stubs have no H1 of their own, and a
157+
# title-less page falls back to "Index"/the filename — which is
158+
# what pruned nav rows, browser tabs, and search results show.
159+
stubs[API_DIR / doc_path] = f"---\ntitle: {parts[-1]}\n---\n\n::: {ident}\n"
157160
if len(parts) == 1:
158161
package_index[ident] = API_DIR / doc_path
159162

@@ -170,7 +173,7 @@ def generate() -> list[NavItem]:
170173
module = modules[ident]
171174
assert isinstance(module, griffe.Module)
172175
if body := _compact_index(module, documented):
173-
stubs[doc_path] = body
176+
stubs[doc_path] = f"---\ntitle: {ident}\n---\n\n{body}"
174177

175178
for full_doc_path, stub in stubs.items():
176179
full_doc_path.parent.mkdir(parents=True, exist_ok=True)

0 commit comments

Comments
 (0)