feat: Add comprehensive cross-reference resolution system to FernRenderer #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: Add comprehensive cross-reference resolution system to FernRenderer
Summary
This PR implements a complete cross-reference resolution system for the FernRenderer to achieve parity with the MyST renderer's cross-referencing capabilities. The implementation adds automatic link generation for code references in docstrings, Anchor components for non-heading items, and infrastructure for deep linking support in code blocks.
Key Changes:
Reference Discovery Phase: Added
_build_reference_map()that runs during initialization to build a complete mapping of all documented items to their slugs and anchors, enabling efficient cross-reference lookups.Cross-Reference Resolution: Implemented
_resolve_cross_reference()with multiple fallback strategies (exact match, child, sibling, module child) to resolve backtick-enclosed identifiers like`ClassName`or`function_name()`to proper Fern links.Docstring Processing: Integrated
_process_docstring_references()into the docstring formatting pipeline to automatically convert code references in descriptions, parameter docs, return values, and exception descriptions into clickable links.Anchor Components: Added
<Anchor id="...">components to function, class, property, and data rendering methods to enable proper cross-referencing for items that don't have their own headings.Deep Linking Infrastructure: Implemented
_extract_code_references()to extract identifiers from code blocks and map them to documentation URLs (for Fern's deep linking feature).Note: The deep linking method (
_extract_code_references()) is implemented but not yet integrated into the rendering pipeline - this will need to be added in a follow-up if needed.Review & Testing Checklist for Human
`ClassName`actually become clickable links to the correct documentation pages<Anchor id="...">syntax and that it creates properly linkable anchors (check Fern docs at https://buildwithfern.com/learn/docs/writing-content/components/anchor)#anchorformat and cross-page links use/slug#anchorformat correctlyTest Plan Recommendation
<Anchor>components at the top of function/class/property definitions[`ClassName]patterns)Notes
overhaulbranch (PR feat: removed all sphinx and kept it more related to Fern #6)_extract_code_references()method exists but isn't called anywhere - if deep linking in code blocks is needed, this will require additional integration work