Skip to content

Commit 0293d36

Browse files
committed
docs: more examples, more content config sections
1 parent bd54720 commit 0293d36

File tree

2 files changed

+120
-9
lines changed

2 files changed

+120
-9
lines changed

docs/get-started/basic-content.qmd

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ contents:
2020
- MdRenderer
2121
```
2222
23-
We set it to only document its render method, by setting `name: MdRenderer` followed by the
24-
`members` option.
23+
We set it to only document its render method, by setting `name: MdRenderer` followed by the `members` option.
2524

2625
```yaml
2726
contents:
@@ -175,6 +174,51 @@ quartodoc:
175174
::::::
176175

177176

177+
## Setting default package path
178+
179+
Different levels of configuration let you set the `package` option.
180+
This controls the package path that quartodoc will try to import control content from.
181+
182+
The example below shows three different places it can be set:
183+
top-level site config, section config, or in a page element.
184+
185+
```yaml
186+
# (1) package set on top-level site config
187+
quartodoc:
188+
package: quartodoc
189+
sections:
190+
- title: ""
191+
desc: ""
192+
contents:
193+
- get_object # quartodoc.get_object
194+
195+
# (2) package set on a section
196+
- title: ""
197+
desc: ""
198+
package: quartodoc.ast
199+
contents:
200+
- preview # quartodoc.ast.preview
201+
202+
# (3) package set on a page
203+
- kind: page
204+
package: pandas
205+
contents:
206+
- DataFrame # pandas.DataFrame
207+
```
208+
209+
Use `package: null` to unset the package option. This enables you to specify objects using their full name.
210+
211+
```yaml
212+
quartodoc:
213+
package: quartodoc
214+
sections:
215+
- title: ""
216+
desc: ""
217+
package: null
218+
contents:
219+
- quartodoc.get_object
220+
```
221+
178222
## Dynamic lookup
179223

180224
By default, quartodoc uses static analysis to look up objects.

docs/get-started/docstring-examples.qmd

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,86 @@
11
---
2-
title: 🚧 Examples
2+
title: Common issues and examples
33
jupyter:
44
kernelspec:
55
display_name: Python 3 (ipykernel)
66
language: python
77
name: python3
88
---
99

10-
```{python}
11-
from quartodoc import MdRenderer, preview
10+
This page provides examples for commonly encountered situations (and some funky ones).
11+
12+
See the [numpydoc sections guide][numpydoc] for more information and examples.
13+
14+
[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html#sections
15+
16+
## Examples: using code blocks
17+
18+
Often, the Examples section of docstrings contain code examples.
19+
20+
The Examples section supports two formats for code examples:
21+
22+
* **doctest syntax** - code starts with `>>>`.
23+
* **markdown syntax** - surrounding code with three backticks (```` ``` ````)
24+
* **quarto syntax** - similar to markdown syntax (e.g. ```` ```{python} ````), but will execute code in the docs.
25+
26+
Below is an example including each.
27+
1228

13-
renderer = MdRenderer()
1429
```
30+
Examples
31+
--------
32+
33+
doctest syntax:
34+
35+
>>> 1 + 1
36+
2
37+
38+
markdown syntax:
39+
40+
```python
41+
1 + 1
42+
```
43+
44+
quarto syntax:
45+
note that the "\" should be removed.
46+
47+
```\{python}
48+
1 + 1
49+
```
50+
```
51+
52+
53+
## Examples, etc..: the "s" matters
54+
55+
The numpydoc spec pluralizes section most names.
56+
If you leave off the "s", then they may be misparsed.
57+
58+
For example, the docstring below erroneously has a "Return" section:
59+
60+
```
61+
Return
62+
------
63+
64+
some_name: int
65+
a description of the return result
66+
```
67+
68+
In this case, the section won't be parsed, but written directly into the doc page.
69+
This means that "Return" would show up as a level 2 header.
70+
71+
Here is a list of pluralized section names:
72+
73+
* Parameters
74+
* Returns
75+
* Yields
76+
* Receives
77+
* Other Parameters
78+
* Raises
79+
* Warns
80+
* Warnings
81+
* Notes
82+
* References
83+
* Examples
1584

1685
## Returns: using type annotation
1786

@@ -36,6 +105,4 @@ def f() -> int:
36105
A number
37106
"""
38107
39-
```
40-
41-
TODO: need to load as a griffe object somehow.
108+
```

0 commit comments

Comments
 (0)