Skip to content

Commit e5af4aa

Browse files
committed
docs: Document full annotation paths
1 parent 9b8e1b1 commit e5af4aa

File tree

1 file changed

+63
-5
lines changed

1 file changed

+63
-5
lines changed

docs/usage/configuration/signatures.md

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Possible values:
1616
- `source`: render annotations as written in the source. For example if you imported `typing` as `t`,
1717
it will render `typing.Sequence` as `t.Sequence`. Each part will cross-reference the relevant object:
1818
`t` will link to the `typing` module and `Sequence` will link to the `Sequence` type.
19+
- `full`: render annotations with their full path (the opposite of brief).
20+
For example if you import `Sequence` and `Pattern` from `typing` and annoate something using
21+
`Sequence[Pattern]`, it will render as `typing.Sequence[typing.Pattern]`, with each part
22+
cross-referencing the corresponding object.
1923

2024
```yaml title="in mkdocs.yml (global configuration)"
2125
plugins:
@@ -32,6 +36,11 @@ plugins:
3236
annotations_path: source
3337
```
3438
39+
40+
/// admonition | Preview
41+
type: preview
42+
43+
//// tab | Brief annotations
3544
```python
3645
import markdown
3746
import markupsafe
@@ -47,13 +56,9 @@ def convert(text: str, md: markdown.Markdown) -> markupsafe.Markup:
4756
Returns:
4857
Converted markup.
4958
"""
50-
return Markup(md.convert(text))
59+
return markupsafe.Markup(md.convert(text))
5160
```
5261
53-
/// admonition | Preview
54-
type: preview
55-
56-
//// tab | Brief annotations
5762
<h2><code>convert(text, md)</code></h2>
5863
<p>Convert text to Markdown.</p>
5964
<p><b>Parameters:</b></p>
@@ -71,6 +76,59 @@ def convert(text: str, md: markdown.Markdown) -> markupsafe.Markup:
7176
////
7277

7378
//// tab | Source annotations
79+
```python
80+
import markdown
81+
from markupsafe import Markup
82+
83+
84+
def convert(text: str, md: markdown.Markdown) -> Markup:
85+
"""Convert text to Markdown.
86+
87+
Parameters:
88+
text: The text to convert.
89+
md: A Markdown instance.
90+
91+
Returns:
92+
Converted markup.
93+
"""
94+
return Markup(md.convert(text))
95+
```
96+
97+
<h2><code>convert(text, md)</code></h2>
98+
<p>Convert text to Markdown.</p>
99+
<p><b>Parameters:</b></p>
100+
101+
**Type** | **Description** | **Default**
102+
---------- | ------------------------ | -----------
103+
[`str`][] | The text to convert. | *required*
104+
<code><a class="external" href="#ref-to-markdown">markdown</a>.<a class="external" href="#ref-to-Markdown" title="markdown.Markdown">Markdown</a></code> | A Markdown instance. | *required*
105+
106+
<p><b>Returns:</b></p>
107+
108+
**Type** | **Name** | **Description**
109+
---------- | ----------- | ---------------
110+
[`Markup`](#ref-to-markup){ .external title="markupsafe.Markup" } | `text` | Converted markup.
111+
////
112+
113+
//// tab | Full annotations
114+
```python
115+
from markdown import Markdown
116+
from markupsafe import Markup
117+
118+
119+
def convert(text: str, md: Markdown) -> Markup:
120+
"""Convert text to Markdown.
121+
122+
Parameters:
123+
text: The text to convert.
124+
md: A Markdown instance.
125+
126+
Returns:
127+
Converted markup.
128+
"""
129+
return Markup(md.convert(text))
130+
```
131+
74132
<h2><code>convert(text, md)</code></h2>
75133
<p>Convert text to Markdown.</p>
76134
<p><b>Parameters:</b></p>

0 commit comments

Comments
 (0)