Sphinx¶
Cross-referencing symbols¶
Sphinx provides several roles to create cross-references to Python symbols in the extra_platforms module. These roles work in both MyST Markdown and reStructuredText formats.
Available roles¶
{func}— Reference a function (e.g.,is_linux(),current_traits()){data}— Reference a module-level constant (e.g.,UBUNTU,skip_linux){class}— Reference a class (e.g.,Platform,Architecture,Group)
Note
Pytest decorators like skip_linux are MarkDecorator objects. Use {data} for inline cross-references. For API documentation, the built-in autodecorator directive renders them with the @ prefix (see pytest.md).
Syntax¶
Use curly braces and backticks:
Check the current platform with {func}`~extra_platforms.is_linux`.
The {class}`~extra_platforms.Platform` class represents operating systems.
Pre-defined platforms like {data}`~extra_platforms.UBUNTU` are available.
See the {mod}`extra_platforms.detection` module for detection functions.
Use colons and backticks:
Check the current platform with :func:`~extra_platforms.is_linux`.
The :class:`~extra_platforms.Platform` class represents operating systems.
Pre-defined platforms like :data:`~extra_platforms.UBUNTU` are available.
See the :mod:`extra_platforms.detection` module for detection functions.
Which renders as:
Check the current platform with
is_linux().The
Platformclass represents operating systems.Pre-defined platforms like
UBUNTUare available.See the
extra_platforms.detectionmodule for detection functions.
The tilde (~) prefix displays only the symbol name without the full module path:
`{func}`~extra_platforms.is_linux`renders asis_linux()`{func}`extra_platforms.is_linux`renders asextra_platforms.is_linux()
Setting a default module¶
To avoid repeating the module name, use the currentmodule directive:
```{py:currentmodule} extra_platforms
```
Use {func}`is_linux` or {func}`is_windows` to check platforms.
.. py:currentmodule:: extra_platforms
Use :func:`is_linux` or :func:`is_windows` to check platforms.
Which renders as:
Use
is_linux()oris_windows()to check platforms.
Cross-reference resolution¶
Symbols exposed at the root extra_platforms module automatically link to their actual definition location:
current_traits()links todetection.htmlPlatformlinks totrait.htmlUBUNTUlinks toplatform_data.html
This ensures documentation remains accurate even when symbols are re-exported from submodules.
Reference matrix¶
This section demonstrates all syntax variations for referencing different object types in the extra_platforms module. All examples use the short-path format with the currentmodule directive.
MyST syntax |
Rendering |
Description |
|---|---|---|
Traits |
||
|
Platform trait symbol |
|
|
Platform trait detection function |
|
|
Platform trait skip decorator |
|
|
Platform trait unless decorator |
|
|
Architecture trait symbol |
|
|
Architecture trait detection function |
|
|
Architecture trait skip decorator |
|
|
Architecture trait unless decorator |
|
|
CI trait symbol |
|
|
CI trait detection function |
|
|
CI trait skip decorator |
|
|
CI trait unless decorator |
|
Groups |
||
|
Regular group symbol |
|
|
Regular group detection function |
|
|
Regular group skip decorator |
|
|
Regular group unless decorator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Unknown platform symbol |
|
|
Unknown platform detection function |
|
|
Unknown platform skip decorator |
|
|
Unknown platform unless decorator |
|
|
Unknown architecture symbol |
|
|
Unknown architecture detection function |
|
|
Unknown architecture skip decorator |
|
|
Unknown architecture unless decorator |
|
|
Unknown CI symbol |
|
|
Unknown CI detection function |
|
|
Unknown CI skip decorator |
|
|
Unknown CI unless decorator |
|
|
Group with |
|
|
Group function with |
|
Detection Methods |
||
|
Current platform detection function |
|
|
Current architecture detection function |
|
|
Current CI detection function |
|
|
All current traits detection function |
|
Classes |
||
|
Platform trait class |
|
|
Architecture trait class |
|
|
CI trait class |
|
|
Group class |
|
Utilities |
||
|
Reduce utility function |
|
|
Cache invalidation utility function |
Tip
All the examples in this reference matrix are tested in tests/test_sphinx_crossrefs.py to ensure cross-references resolve correctly in the built documentation.