Skip to content

Commit ed9d27e

Browse files
PyCharm settings
- Check compatability for Python 3.8 through 3.12 - Added project icon
1 parent ab6d250 commit ed9d27e

File tree

6 files changed

+59
-18
lines changed

6 files changed

+59
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mkdocstring-python-xref changes
22

3-
## 1.6.2
3+
## 1.5.3
44

55
First public release
66

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ Python handler for [mkdocstrings] supporting relative cross-references.
1010
[![CI](https://github.com/analog-garage/mkdocstrings-python-xref/actions/workflows/main.yml/badge.svg)](https://github.com/analog-garage/mkdocstrings-python-xref/actions/workflows/main.yml)
1111
![GitHub issues](https://img.shields.io/github/issues/analog-garage/mkdocstrings-python-xref)
1212

13+
[mkdocstrings] is an awesome plugin for [MkDocs] that can generate Markdown API documentation
14+
from comments in code. The standard [python handler][mkdocstrings-python] allows you to
15+
create cross-reference links using the syntax `[<title>][<path>]` where the path must
16+
either be the fully qualified name of the referent or is empty, in which case the path
17+
is taken from the title. This works well when the names are short, but can be burdensome
18+
in larger codebases with deeply nested package structures.
1319

20+
This package extends [mkdocstrings-python] to support a relative cross-reference syntax,
21+
that allows you to write doc-strings with cross-references like:
22+
23+
```python
24+
class MyClass:
25+
def this_method(self):
26+
"""
27+
See [other_method][..] from [MyClass][(c)]
28+
"""
29+
```
30+
rather than:
31+
32+
```python
33+
class MyClass:
34+
def this_method(self):
35+
"""
36+
See [other_method][mypkg.mymod.MyClass.other_method]
37+
from [MyClass][mypkg.mymod.Myclass]
38+
"""
39+
```
40+
41+
For further details, please see the [Documentation](https://analog-garage.github.io/mkdocstrings-python-xref/)
42+
43+
[MkDocs]: https://mkdocs.readthedocs.io/
1444
[mkdocstrings]: https://github.com/mkdocstrings/mkdocstrings
15-
[mkdocstrings_python]: https://github.com/mkdocstrings/python
45+
[mkdocstrings-python]: https://github.com/mkdocstrings/python

docs/install.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
```
44
pip install mkdocstrings-python-xref
55
```
6+
### Using conda
7+
8+
*coming soon...*
69

710

811

docs/relative-crossref.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ will support more compact relative syntax:
1515
class MyClass:
1616
def this_method(self):
1717
"""
18-
See [other_function][mypkg.mymod.MyClass.other_function]
18+
See [other_method][mypkg.mymod.MyClass.other_method]
1919
from [MyClass][mypkg.mymod.Myclass]
2020
"""
2121
```
@@ -26,7 +26,7 @@ will support more compact relative syntax:
2626
class MyClass:
2727
def this_method(self):
2828
"""
29-
See [other_function][.] from [MyClass][^]
29+
See [other_method][..] from [MyClass][(c)]
3030
"""
3131
```
3232

@@ -38,11 +38,6 @@ The relative path specifier has the following form:
3838
* If the path begins with a single `.` then it will be expanded relative to the path
3939
of the doc-string in which it occurs.
4040

41-
As a deprecated special case, if the current
42-
doc-string is for a function or method, then `.` will instead be
43-
expanded relative to the function's parent (i.e. the same as `^.`).
44-
This will turn into an error in a future version.
45-
4641
* If the path begins with `(c)`, that will be replaced by the path of the
4742
class that contains the doc-string
4843

@@ -53,10 +48,17 @@ The relative path specifier has the following form:
5348
package that contains the doc-string. If there is only one module in the
5449
system it will be treated as a package.
5550

56-
* If the path begins with one or more `^` characters, then that will go
57-
up one level in the path of the current doc string for each `^`. Additionally,
58-
if the path begins with two or more `.` characters, then that will go
59-
up on level for each `.` after the first.
51+
* If the path begins with one or more `^` characters, then will be replaced
52+
by the path of the parent element. For example, when used in a doc-string
53+
for a method, `^` would get replaced with the class and `^^` would get
54+
replaced with the module.
55+
56+
* Similarly, if the path begins with two or more `.` characters, then all but
57+
the last `.` will be replaced by the parent element, and if nothing follows
58+
the last `.`, the title text will be appended according to the first rule.
59+
60+
*NOTE: When using either `^` or `..` we have found that going up more than one
61+
or two levels makes cross-references difficult to read and should be avoided*
6062

6163
These are demonstrated here:
6264

@@ -66,7 +68,10 @@ These are demonstrated here:
6668
class MyClass:
6769
def this_method(self):
6870
"""
69-
[`that_method`][.]
71+
[MyClass][^]
72+
Also [MyClass][(c)]
73+
[`that_method`][^.]
74+
Also [`that_method`][..]
7075
[init method][(c).__init__]
7176
[this module][(m)]
7277
[this package][(p)]
@@ -81,7 +86,10 @@ These are demonstrated here:
8186
class MyClass:
8287
def this_method(self):
8388
"""
89+
[MyClass][mypkg.mymod.MyClass]
90+
Also [MyClass][mypkg.mymod.MyClass]
8491
[`that_method`][mypkg.mymod.MyClass.that_method]
92+
Also [`that_method`][mypkg.mymod.MyClass.that_method]
8593
[init method][mypkg.mymod.MyClass.__init__]
8694
[this module][mypkg.mymod]
8795
[this package][mypkg]

docs/support.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
You can file bug reports or feature requests
2-
[on GitHub](https://github.com/analog-garage/mkdocstrings-python-xref/issues).
2+
[on GitHub](https://github.com/analog-garage/mkdocstrings-python-xref/issues) or if you just want to ask
3+
a question on the [project's discussions board](https://github.com/analog-garage/mkdocstrings-python-xref/discussions)
4+

mkdocs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ watch:
1111
- src/mkdocstrings_handlers
1212

1313
nav:
14-
- User Guide:
15-
- Overview: index.md
16-
- Relative cross-references: relative-crossref.md
14+
- User Guide: relative-crossref.md
1715
- Setup:
1816
- Installation: install.md
1917
- Configuration: config.md

0 commit comments

Comments
 (0)