Skip to content

Commit d629160

Browse files
committed
docs: preload cross-package alias targets in the compact index stub
Rendering the stub resolves its cross-package aliases in mkdocstrings' own collection. On a warm incremental rebuild the target package's pages can all be cache hits, so nothing loads it and rendering the changed index crashes with AliasResolutionError — breaking the serve/edit loop for any src change that alters the generated index. Cold builds were unaffected. preload_modules pins the targets into the collection.
1 parent 878e21e commit d629160

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

scripts/docs/gen_ref_pages.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ def _compact_index(package: griffe.Module, documented: set[str]) -> str | None:
106106
entry += f" — {summary}"
107107
sections.setdefault(_KIND_SECTIONS[target.kind], []).append(entry)
108108

109+
# Rendering the stub resolves the cross-package aliases again, in
110+
# mkdocstrings' own collection. On a warm incremental rebuild the target
111+
# package's pages can all be cache hits, so nothing else loads it and the
112+
# resolution crashes (AliasResolutionError); preloading pins it.
113+
preload = sorted(
114+
{member.target_path.split(".")[0] for member in exports.values() if member.is_alias} - {package.path}
115+
)
109116
body = [f"::: {package.path}", " options:"]
117+
body += [" preload_modules:", *(f" - {module}" for module in preload)]
110118
if inline:
111119
body += [" members:", *(f" - {name}" for name in inline)]
112120
else:

0 commit comments

Comments
 (0)