@@ -3,7 +3,7 @@ that the handler name should be `python_xref` instead of `python`. Because
33this handler extends the standard [ mkdocstrings-python] [ ] handler, the same options are
44available.
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 <patch-file> ` or ` patch -p1 -i <patch-file> ` .
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/
0 commit comments