You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/get-started/docstrings.qmd
+42-6Lines changed: 42 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -9,13 +9,25 @@ jupyter:
9
9
10
10
quartodoc uses the library [griffe](https://github.com/mkdocstrings/griffe) to load and parse docstrings.
11
11
12
+
## Docstring structure
13
+
14
+
quartodoc currently expects docstrings to be in the [numpydocstring](https://numpydoc.readthedocs.io/en/latest/format.html) format.
15
+
16
+
Docstrings are loaded and parsed using [griffe](https://mkdocstrings.github.io/griffe),
17
+
which uses custom data classes to represent the structure of a program:
18
+
19
+
-[griffe.dataclasses](https://mkdocstrings.github.io/griffe/reference/griffe/dataclasses/#griffe.dataclasses) - represent the structure of python objects.
20
+
-[griffe.docstrings.dataclasses](https://mkdocstrings.github.io/griffe/reference/griffe/docstrings/dataclasses/#griffe.docstrings.dataclasses) - represent the structure of parsed docstrings.
21
+
22
+
23
+
12
24
## Reading docstrings
13
25
14
26
Use the function [get_object](/api/#get_object) to read in a docstring from a module.
15
27
16
28
17
29
```{python}
18
-
from quartodoc import get_object
30
+
from quartodoc import get_object, preview
19
31
20
32
f_obj = get_object("quartodoc", "get_object")
21
33
f_obj
@@ -56,13 +68,29 @@ f_obj.docstring.parsed
56
68
The docstring into a tree lets us define visitors, which can visit each element and
57
69
do useful things. For example, print a high-level overview of its structure, or render it to markdown.
58
70
59
-
## Parsed docstring structure
71
+
## Previewing docstrings
72
+
73
+
Use the preview function to see the overall structure of a parsed docstring.
74
+
75
+
```{python}
76
+
from quartodoc import get_object, preview
77
+
78
+
f_obj = get_object("quartodoc", "get_object")
79
+
```
80
+
81
+
### Raw docstring
82
+
83
+
84
+
```{python}
85
+
print(f_obj.docstring.value)
86
+
```
87
+
88
+
### Preview
60
89
61
-
*[numpydocstring](https://numpydoc.readthedocs.io/en/latest/format.html) - defines the numpydoc format for writing docstrings.
***Tree walking**: `visit` methods often call `visit` again on sub elements.
111
139
112
140
141
+
## Parsing other docstring formats
142
+
143
+
Currently, quartodoc expects docstrings in the numpydoc format.
144
+
However, the tool it uses under the hood (griffe) is easy to customize, and supports multiple formats.
145
+
146
+
See the griffe [loading docs](https://mkdocstrings.github.io/griffe/loading/) for instructions.
147
+
Specifically, the [GriffeLoader](https://mkdocstrings.github.io/griffe/reference/griffe/loader/#griffe.loader.GriffeLoader) takes options for customizing docstring parsing.
0 commit comments