Skip to content

Commit 4ffe287

Browse files
Merge pull request #58 from analog-garage/fix-templates
Fix handling of extended template paths (#56)
2 parents 16d42a1 + 9c911ea commit 4ffe287

6 files changed

Lines changed: 22 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
*Note that versions roughly correspond to the version of mkdocstrings-python that they
44
are compatible with.*
55

6+
## 2.0.1
7+
8+
* Fix extended template configuration (#56)
9+
610
## 2.0.0
711

812
* Depends on mkdocstrings-python >=2.0 and mkdocstrings >=1.0

docs/index.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ fully qualified or is empty, in which case it is taken from the title.
55
If you work with long package and class names or with namespace packages, this can result in a lot
66
of extra typing and harder to read doc-strings.
77

8+
9+
!!! note "Difference with mkdocstrings-python"
10+
11+
[mkdoctrings-python release 1.19](https://github.com/mkdocstrings/python/releases/tag/1.19.0)
12+
introduced support for relative (and also scoped) cross-references, but does not
13+
support the full range of relative syntax supported by this handler. Specifically,
14+
the standard handler only supports the leading `.` syntax described here.
15+
816
If you enable the `relative_crossrefs` option in the `python_xref` handler options
917
in your mkdocs.yml file ([see configuration](config.md) for an example), then the handler
1018
will support more compact relative syntax:

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ markdown_extensions:
5454
- admonition
5555
- pymdownx.snippets:
5656
check_paths: true
57+
- pymdownx.details
5758
- pymdownx.superfences
5859
- pymdownx.tabbed:
5960
alternate_style: true

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.0
1+
2.0.1

src/mkdocstrings_handlers/python_xref/handler.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,17 @@ def render(self, data: CollectorItem, options: PythonOptions, locale: str | None
9595

9696
def get_templates_dir(self, handler: Optional[str] = None) -> Path:
9797
"""See [render][.barf]"""
98+
# use same templates as standard python handler
9899
if handler == self.name:
99100
handler = 'python'
100101
return super().get_templates_dir(handler)
101102

103+
def get_extended_templates_dirs(self, handler: str) -> list[Path]:
104+
# use same templates as standard python handler
105+
if handler == self.name:
106+
handler = 'python'
107+
return super().get_extended_templates_dirs(handler)
108+
102109
def _check_ref(self, ref : str, exclude: list[str | re.Pattern] = []) -> bool:
103110
"""Check for existence of reference"""
104111
for ex in exclude:

0 commit comments

Comments
 (0)