Fix internal links in the documentation #4659
Merged
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.
When Sphinx encounter links to neighbor files using
.html
extension, it consider it as a section reference to the same file. For example, doc/endpoint/schemas.md contains:Sphinx compiles the link to:
In practice, when visiting
https://tapir.softwaremill.com/en/latest/endpoint/schemas.html and clicking on "newtype", the browser goes to
https://tapir.softwaremill.com/en/latest/endpoint/schemas.html#integrations.html#newtype-integration instead of
https://tapir.softwaremill.com/en/latest/endpoint/integrations.html#newtype-integration
Using
integrations.md
in the Markdown link makes Sphinx understand the link is referencing another file. The generated HTML code contains the right link tointegrations.html
:Fix this issue every place it occurs in the documentation pages.
Also replace absolute links to https://tapir.softwaremill.com/en/latest/ with relative ones. This makes it easier to generate self-contained documentation of past releases (where links do not target "latest").
Some links triggered
myst.xref_missing
errors. For example:The generated HTML of
doc/endpoint/schemas.md
correctly defined the anchorsealed-traits-coproducts
:However MyST generates slightly different slugs:
Using
schema.md#sealed-traits--coproducts
inoneof.md
fixed the issue and correctly generated a link toschemas.html#sealed-traits-coproducts
.By the way, generating MyST identifiers for Markdown sections requires setting
myst_heading_anchors = 3
in the Sphinx configuration, cf. https://myst-parser.readthedocs.io/en/latest/syntax/cross-referencing.html#implicit-targetsTo test building the documentation, I used a clean Ubuntu 24.04 container where I ran:
After this, I browser
target/tapir-doc/_build/html/index.html
and checked the links were fixed.