Make docs footer edit links point to actual source files

Merged
MA
3mo ago
+154-12

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:

  1. New github_edit_url() function in docpage.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.

  2. Track source paths through the doc generation pipeline:

    • docpage() decorator now accepts optional source_path parameter
    • make_docpage() helper passes actual file paths to the decorator
    • Component docs and library docs now provide their actual source paths
  3. Dynamic footer links: The docpage_footer() component now receives the computed edit URL as a parameter instead of hardcoding it.

  4. New doc_edit_hrefs registry: Maps normalized routes to their GitHub edit URLs for validation and testing.

  5. Comprehensive test coverage:

    • test_github_edit_url_points_at_repo_source: Validates URLs for files in the repo
    • test_github_edit_url_falls_back_outside_repo: Ensures fallback for venv/external packages
    • test_github_edit_url_without_source: Handles pages with no source
    • test_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_href parameter

https://claude.ai/code/session_01RPzeJWdX5rxpTmDJhXhkaa