Repository navigation
fix: resolve Sphinx diagram zoom links relative to the current page - #650
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #650 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 52 52
Lines 5572 5597 +25
Branches 879 886 +7
=========================================
+ Hits 5572 5597 +25
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hi @rastagan-git, welcome, and thank you for your first contribution to python-statemachine! I appreciate the time you put into this: the reproduction, the before/after tests on both html and dirhtml, and the clear write-up made the review quick.
One change request inline about the singlehtml builder, plus a follow-up idea. I pushed the fix myself in 9ac68e0 to get this merged quickly; see the thread for details.
The href was computed in the read phase, where `singlehtml` does not yet know the document and returns a per-file URI, so nested pages ended up with `../_images/...` from `index.html`. Keep the root-relative href on the raw node and rewrite it in a `doctree-resolved` handler, once the builder knows the page's final URI. Covers html, dirhtml and singlehtml. Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
|
Fix pushed in 9ac68e0 on the contributor's branch.
Open the notes with a summary and a list of the behavior changes to check when upgrading, group the fixes by theme, and cite the issue and the PR of every entry. Add the missing entries for #650 and the GraphvizError exception change, the rejection of nested callbacks named like an event, and the events dropped after a top-level final state. Document Event(delay=..., internal=...) in the events page, the declared delay in the delayed events section, and the queue being discarded on termination in the processing model. Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>
Open the notes with a summary and a list of the behavior changes to check when upgrading, group the fixes by theme, and cite the issue and the PR of every entry. Add the missing entries for #650 and the GraphvizError exception change, the rejection of nested callbacks named like an event, and the events dropped after a top-level final state. Document Event(delay=..., internal=...) in the events page, the declared delay in the delayed events section, and the queue being discarded on termination in the processing model. Signed-off-by: Fernando Macedo <fgmacedo@gmail.com>



Problem
An empty
:target:onstatemachine-diagramwrites a standalone SVG to the build's_imagesdirectory, but links to it with a leading slash. When the documentation is hosted below a URL prefix, clicking the diagram navigates outside the documentation deployment.For example, a page at
https://example.com/project/en/stable/guide/overview.htmlcurrently links tohttps://example.com/_images/statemachine-<digest>.svg, although the file belongs under/project/en/stable/_images/.To reproduce, add this directive to a Sphinx document and build it with
htmlordirhtml:Resolve the generated link as if the output were served below
/project/en/stable/. The link loses that prefix on the currentdevelopbranch.Changes
relative_urihelper to link to the generated SVG.htmlanddirhtml, each with a root index, a nested document, and a nested index. Assert that the link resolves inside the deployment prefix and that the generated SVG exists.generate-imagespre-commit hook; the states, transitions, and labels are unchanged.Validation
Ubuntu / Python 3.14.7 / Sphinx 9.1.0 / pydot 4.0.1 / Graphviz 2.43.0:
uv run pytest tests/test_contrib_diagram.py --timeout=30 -q --tb=short --cov=statemachine.contrib.diagram.sphinx_ext --cov-report=term-missing --cov-fail-under=100: 149 passed, affected-module line/branch coverage 100%.uv run pytest -n 4 --timeout=30 --cov --cov-report=term-missing --tb=short: 2147 passed, 1 skipped, 44 xfailed, overall line/branch coverage 100%.The real Sphinx builds emit deprecation warnings for
BuildEnvironment.app, which this extension already uses; migrating that API is outside this patch. Windows / Python 3.14.4 / Graphviz 16.1.0 also passes the six new builds, but two existing SVG-prefix assertions fail on Graphviz's CRLF output (147 passed, 2 failed in the full diagram file). The Linux run above passes those assertions. The complete supported Python-version matrix remains for CI.Prepared with AI assistance; reproduction, before/after tests, and scope are documented above.