Fix mkdocstrings cross-references not resolving to links in Zensical-built docs#4
Fix mkdocstrings cross-references not resolving to links in Zensical-built docs#4
Conversation
|
Would like to add details:
|
Agent-Logs-Url: https://github.com/OutSquareCapital/pyochain/sessions/ae1f437f-4e75-4afb-a797-a5d4be62346e Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
…on, and docs updates Agent-Logs-Url: https://github.com/OutSquareCapital/pyochain/sessions/ae1f437f-4e75-4afb-a797-a5d4be62346e Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
…ed ref handling, simplify rebuild script Agent-Logs-Url: https://github.com/OutSquareCapital/pyochain/sessions/ae1f437f-4e75-4afb-a797-a5d4be62346e Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OutSquareCapital/pyochain/sessions/ae1f437f-4e75-4afb-a797-a5d4be62346e Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
docs/getting-started.md
Outdated
| - [Interoperability](interoperability.md): convert between types with various methods | ||
| - [Examples & Cookbook](examples.md): practical patterns and concrete examples | ||
|
|
||
| ## Cross-references |
There was a problem hiding this comment.
This whole section is irrelevant. Getting started is for end users, not for internal devs
There was a problem hiding this comment.
Removed in 2ec6231 — getting-started.md is back to its original state.
| @@ -0,0 +1,309 @@ | |||
| """Post-process the built site to resolve mkdocstrings cross-reference tags. | |||
|
|
|||
| Zensical does not call ``fix_refs`` from ``mkdocs-autorefs``, so the | |||
There was a problem hiding this comment.
This whole file need to follow pyochain patterns for iterations, just like the other scripts
There was a problem hiding this comment.
Rewritten in 2ec6231 using the same patterns as the other scripts (generate_docs.py, check_docstrings.py). Key changes:
import pyochain as pc+import rich/rich.text_file_anchors()and_module_aliases()returnpc.Iter[...]_class_alias()and_try_import_module()returnpc.Option- All manual loops replaced with
pc.Iter(...).flat_map(...),.filter_map(...),.filter_star(...),.map_star(...),.for_each_star(...),.collect(),.sum(),.length()
| @@ -83,3 +83,5 @@ | |||
| custom_fences = [ | |||
| { name = "mermaid", class = "mermaid", format = "pymdownx.superfences.fence_code_format" }, | |||
There was a problem hiding this comment.
Why has this change been made?
There was a problem hiding this comment.
The AutorefsExtension enables [text][identifier] and [identifier][] cross-reference syntax in regular markdown pages (like api-reference.md). Without it, [``Iter[T]``][pyochain._iter.Iter] in a .md file would be treated as a broken markdown reference link and rendered as plain text. With the extension, zensical's markdown processing converts these into <autoref> tags, which fix_autorefs.py then resolves to proper <a> links.
If you'd prefer not to use this syntax in the markdown docs, the extension can be removed and api-reference.md can be reverted to plain links — let me know.
|
@copilot act on my review comments |
…py with pyochain patterns Agent-Logs-Url: https://github.com/OutSquareCapital/pyochain/sessions/22463733-e40a-47a5-9090-ca23ca661686 Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
…f syntax, improve lambda readability, rename counts variable Agent-Logs-Url: https://github.com/OutSquareCapital/pyochain/sessions/22463733-e40a-47a5-9090-ca23ca661686 Co-authored-by: OutSquareCapital <166045166+OutSquareCapital@users.noreply.github.com>
Zensical never calls
fix_refs()frommkdocs-autorefs, so every<autoref>tag emitted by mkdocstrings (type signatures, base classes, return types, user-written[identifier][]refs) was left as raw, unlinked HTML in the built site.Changes
scripts/fix_autorefs.py— New post-build script that resolves all<autoref>tags, written using pyochain iteration patterns (consistent with the other scripts in this folder):site/HTML to build an anchor-ID → absolute-URL map usingpc.Iter(...).flat_map(...).for_each_star(...)pyochain.traits.PyoIterator→ canonicalpyochain.traits._iterable.PyoIterator), usingfilter_map,flat_map,filter_star, andfor_each_star<autoref>to<a class="autorefs autorefs-internal">with a correct relative URL; falls back to the parent class anchor for attribute refs (Err.error→Err); emits arichwarning (with page URL) for non-optional unresolved refsrich/rich.textfor all output, consistent with other scriptszensical.toml— Registersmkdocs_autorefs._internal.references:AutorefsExtensionas a markdown extension, enabling[identifier][]/[label][identifier]cross-reference syntax in plain.mdpages, not just inside:::docstring blocks.github/workflows/docs.yml— Runsfix_autorefs.pybetweenzensical buildand the GitHub Pages deploy stepscripts/rebuild-docs.ps1— Updated to runfix_autorefs.pyafter the builddocs/api-reference.md— Migrated all type links to cross-reference syntax (e.g.[`Iter[T]`][pyochain._iter.Iter])Usage example
Both forms now resolve to clickable links after
zensical build && uv run scripts/fix_autorefs.py.