Skip to content

Commit 4524117

Browse files
Bump version to 2.1.0, update CHANGELOG and docs
- Update VERSION to 2.1.0 - Add CHANGELOG entry for compatibility_check and compatibility_patch features - Document new options in docs/config.md with examples - Add migration section to docs/index.md Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 961cc0a commit 4524117

4 files changed

Lines changed: 94 additions & 2 deletions

File tree

CHANGELOG.md

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

6+
## 2.1.0
7+
8+
* Added `compatibility_check` option to warn or error on cross-reference syntax that
9+
is not supported by the standard mkdocstrings-python handler (#60)
10+
* Added `compatibility_patch` option to generate a patch file converting incompatible
11+
cross-references to standard form (#60)
12+
613
## 2.0.1
714

815
* Fix extended template configuration (#56)

docs/config.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ that the handler name should be `python_xref` instead of `python`. Because
33
this handler extends the standard [mkdocstrings-python][] handler, the same options are
44
available.
55

6-
Additional options are added by this extension. Currently, there are three:
6+
Additional options are added by this extension:
77

88
* **relative_crossrefs**: `bool` - if set to true enables use of relative path syntax in
99
cross-references.
@@ -19,6 +19,18 @@ Additional options are added by this extension. Currently, there are three:
1919
libraries which are very expensive to import without having to disable checking for all
2020
cross-references.
2121

22+
* **compatibility_check**: `false`, `"warn"`, or `"error"` - when set, reports cross-references
23+
that use syntax not supported by the standard [mkdocstrings-python][] handler. This is
24+
useful when planning to migrate away from this extension. The incompatible syntax elements
25+
are: leading `^`, `(c)`, `(m)`, `(p)` specifiers; trailing `.` after a name (which
26+
appends the title); and leading `?` (which suppresses reference checking).
27+
28+
* **compatibility_patch**: `false` or a file path string - when set to a file path, generates
29+
a unified diff patch file that converts incompatible cross-references to the standard
30+
dot-prefix form. The patch file is overwritten on each build. If no incompatibilities are
31+
found, any existing patch file is removed. The generated patch can be applied with
32+
`git apply` or `patch -p0`.
33+
2234
!!! Example "mkdocs.yml plugins specifications using this handler"
2335

2436
=== "Always check"
@@ -80,6 +92,56 @@ Additional options are added by this extension. Currently, there are three:
8092
check_crossrefs: no
8193
```
8294

95+
!!! Example "Compatibility checking for migration"
96+
97+
To check for incompatible syntax before migrating to the standard handler:
98+
99+
=== "Warn on incompatibilities"
100+
101+
```yaml
102+
plugins:
103+
- mkdocstrings:
104+
default_handler: python_xref
105+
handlers:
106+
python_xref:
107+
options:
108+
relative_crossrefs: yes
109+
compatibility_check: warn
110+
```
111+
112+
=== "Error on incompatibilities"
113+
114+
```yaml
115+
plugins:
116+
- mkdocstrings:
117+
default_handler: python_xref
118+
handlers:
119+
python_xref:
120+
options:
121+
relative_crossrefs: yes
122+
compatibility_check: error
123+
```
124+
125+
=== "Generate a patch file"
126+
127+
```yaml
128+
plugins:
129+
- mkdocstrings:
130+
default_handler: python_xref
131+
handlers:
132+
python_xref:
133+
options:
134+
relative_crossrefs: yes
135+
compatibility_check: warn
136+
compatibility_patch: xref-compat.patch
137+
```
138+
139+
Then apply the patch:
140+
141+
```bash
142+
git apply xref-compat.patch
143+
```
144+
83145

84146

85147
[mkdocstrings-python]: https://mkdocstrings.github.io/python/

docs/index.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,29 @@ reference expression with a `?`, for example:
126126
This function returns a [Path][?pathlib.] instance.
127127
```
128128

129+
## Migrating to standard mkdocstrings-python
130+
131+
If you want to migrate from this extension to the standard [mkdocstrings-python][mkdocstrings_python]
132+
handler, you can use the `compatibility_check` and `compatibility_patch` options to help
133+
identify and convert incompatible cross-reference syntax.
134+
135+
The following syntax elements are specific to this extension and not supported by the
136+
standard handler:
137+
138+
| Syntax | Description | Standard equivalent |
139+
|--------|-------------|-------------------|
140+
| `^`, `^^`, ... | Caret parent specifier | `..`, `...`, ... (dot prefix) |
141+
| `(c)` | Class specifier | Equivalent number of leading dots |
142+
| `(m)` | Module specifier | Equivalent number of leading dots |
143+
| `(p)` | Package specifier | Equivalent number of leading dots |
144+
| Trailing `.` after a name | Append title to reference | Expand title inline, e.g. `[foo][bar.]``[foo][bar.foo]` |
145+
| Leading `?` | Suppress reference checking | Remove the `?` |
146+
147+
To check for incompatibilities, set `compatibility_check` to `"warn"` or `"error"` in your
148+
handler options. To generate a patch file that converts all incompatible references to
149+
standard form, set `compatibility_patch` to a file path. See the [configuration](config.md)
150+
page for examples.
151+
129152
[mkdocstrings]: https://mkdocstrings.github.io/
130153
[mkdocstrings_python]: https://mkdocstrings.github.io/python/
131154
[relative-crossref-issue]: https://github.com/mkdocstrings/python/issues/27
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.1
1+
2.1.0

0 commit comments

Comments
 (0)