Make docs footer edit links point to actual source files
Merged
MA
3mo ago+154+154+012345678901234567890123456789-12-12-01234567890123456789
Type of change
- New feature (non-breaking change which adds functionality)
- This change requires a documentation update
Description
This PR enhances the documentation footer's "Edit this page" link to point to the actual source file that generates each page, rather than a hardcoded path pattern.
Changes:
-
New
github_edit_url()function indocpage.py: Builds GitHub edit URLs from source file paths, with fallback to the docs tree for files outside the repo checkout or installed in venvs. -
Track source paths through the doc generation pipeline:
docpage()decorator now accepts optionalsource_pathparametermake_docpage()helper passes actual file paths to the decorator- Component docs and library docs now provide their actual source paths
-
Dynamic footer links: The
docpage_footer()component now receives the computed edit URL as a parameter instead of hardcoding it. -
New
doc_edit_hrefsregistry: Maps normalized routes to their GitHub edit URLs for validation and testing. -
Comprehensive test coverage:
test_github_edit_url_points_at_repo_source: Validates URLs for files in the repotest_github_edit_url_falls_back_outside_repo: Ensures fallback for venv/external packagestest_github_edit_url_without_source: Handles pages with no sourcetest_markdown_doc_routes_edit_their_own_source: Integration test verifying all markdown-backed routes have correct edit links
Test Plan
All new tests pass:
- Unit tests for
github_edit_url()with various source path scenarios - Integration test verifying every markdown-backed doc route has a correct edit link pointing to its actual source file
- Existing footer test updated to pass the new
edit_hrefparameter