Skip to content

Commit d8a434d

Browse files
committed
Move to mkdocstrings-python-xref
1 parent 2916edf commit d8a434d

File tree

4 files changed

+45
-19
lines changed

4 files changed

+45
-19
lines changed

docs/contributing/guides/docstrings-and-reference.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,22 @@ def foo():
144144
bar(custom_object)
145145
```
146146

147-
The references need to point to an object that is included in the docs (documented in API reference pages). **You will
148-
need to use the fully qualified name**. (You can't just use `[bar][bar]`, even if `bar` is defined in the same scope
149-
within the code. You will still need `[bar][mcproto.module_b.bar]`.) Sadly, while relative cross-references are
150-
supported, [mkdocstrings gates them for sponsors
147+
The references need to point to an object that is included in the docs (documented in API reference pages).
148+
149+
### Relative Cross-References
150+
151+
While relative cross-references are supported by mkdocstrings, they are [gated for sponsors
151152
only](https://mkdocstrings.github.io/python/usage/configuration/docstrings/#relative_crossrefs), at least until a
152153
funding goal is reached.
153154

155+
For that reason, we're using an alternative handler to `mkdocstrings-python`:
156+
[`mkdocstrings-python-xref`](https://github.com/analog-garage/mkdocstrings-python-xref). This handler uses
157+
`mkdocstrings-python` internally, while extending it to provide support for relative cross-references. It is expected
158+
that once relative cross-refs come to mainline `mkdocstrings-python`, this alternative handler will be dropped.
159+
160+
To use relative cross-references, check the [mkdocstrings-python-xref
161+
documentation](https://analog-garage.github.io/mkdocstrings-python-xref).
162+
154163
## Writing API Reference
155164

156165
On top of just learning about how to write docstrings, you will need to understand how to write the docs for the API

mkdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ plugins:
135135
version_selector: true
136136
- mkdocstrings:
137137
enable_inventory: true
138-
default_handler: python
138+
default_handler: python_xref
139139
handlers:
140-
python:
140+
python_xref:
141141
options:
142142
docstring_options:
143143
ignore_init_summary: true

poetry.lock

Lines changed: 26 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,10 @@ mkdocs = "^1.6.0"
6767
mkdocs-material = "^9.5.30"
6868
mike = "^2.1.2"
6969
markdown-exec = { extras = ["ansi"], version = "^1.9.3" }
70-
towncrier = ">=23,<24.7" # temporary pin, as 24.7 is incompatible with sphinxcontrib-towncrier
71-
mkdocstrings-python = { version = "^1.12.1", python = ">3.9,<4" }
70+
towncrier = ">=23,<24.7" # temporary pin, as 24.7 is incompatible with sphinxcontrib-towncrier
71+
mkdocstrings = "0.27.0"
72+
mkdocstrings-python = "1.13.0"
73+
mkdocstrings-python-xref = "^1.6.2"
7274

7375
[tool.poetry.group.docs-ci]
7476
optional = true

0 commit comments

Comments
 (0)