Skip to content

Commit 1bc2a0e

Browse files
committed
docs: more get-started docs
1 parent a324941 commit 1bc2a0e

File tree

8 files changed

+293
-109
lines changed

8 files changed

+293
-109
lines changed

docs/_quarto.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ website:
4242
- section: "Basic Use"
4343
contents:
4444
- get-started/basic-docs.qmd
45+
- get-started/basic-content.qmd
4546
- get-started/basic-building.qmd
4647
- get-started/crossrefs.qmd
4748
- get-started/interlinks.qmd
@@ -55,6 +56,7 @@ website:
5556
- get-started/dev-prepare.qmd
5657
- get-started/docstrings.qmd
5758
- get-started/renderers.qmd
59+
- get-started/dev-dataclasses.qmd
5860
- section: "Extra Topics"
5961
contents:
6062
- get-started/extra-build-sequence.qmd
@@ -156,7 +158,7 @@ quartodoc:
156158
- layout.Link
157159
- layout.Item
158160
- layout.ChoicesChildren
159-
- title: "Data models: AST patches"
161+
- title: "Data models: docstring patches"
160162
desc: |
161163
Most of the classes for representing python objects live
162164
in [](`griffe.dataclasses`) or [](`griffe.docstrings.dataclasses`).

docs/examples/index.qmd

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1+
### Demo sites
2+
13
| style | source | layout |
24
| ----- | ------ | ------ |
35
| [pkgdown] | [github][pkgdown-code] | Index page with a title and short description for functions listed in each section. Each function gets its own documentation page. |
46
| [single-page] | [github][sp-code] | Index page has function documentation embedded on it. |
5-
| [shiny] | private repository | The shiny docs translated to quartodoc, using a custom renderer. |
7+
8+
### Packages using quartodoc
9+
10+
11+
| package | source | about |
12+
| ----- | ------ | ------ |
13+
| [siuba] | [github][sb-code] | Data analysis library. |
14+
| [shiny][shiny] | | Dashboarding framework. |
15+
| [vetiver][vetiver] | [github][vt-code] | A tool to version, share, deploy and monitor ML models. |
616

717
: {tbl-colwidths="[20, 20, 60]"}
818

@@ -11,3 +21,7 @@
1121
[single-page]: /examples/single-page/reference
1222
[sp-code]: https://github.com/machow/quartodoc/tree/main/examples/single-page
1323
[shiny]: https://shiny.rstudio.com/py/api/
24+
[vetiver]: https://rstudio.github.io/vetiver-python/stable/reference/
25+
[vt-code]: https://github.com/rstudio/vetiver-python
26+
[siuba]: https://siuba.org/api/
27+
[sb-code]: https://github.com/machow/siuba.org

docs/get-started/basic-building.qmd

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,25 @@ jupyter:
77
name: python3
88
---
99

10-
Basic commands:
10+
**tl;dr**: Once you've configured quartodoc in your `_quarto.yml` file, use the following commands to build and preview a documentation site.
1111

12-
* quartodoc build --verbose
13-
* quartodoc interlinks
14-
* quarto preview
12+
```bash
13+
# Create the documentation files. These are written
14+
# by default to the reference/ folder in your docs.
15+
quartodoc build --verbose
1516

16-
Extra
17+
# Create optional inventory files, which allow you to
18+
# link to API doc pages within and across documentation
19+
# sites. These are put in the _inv folder in your docs.
20+
quartodoc interlinks
1721

18-
* note the write only on change option
19-
* if in trouble, point to advanced section for loading things in python
20-
* what if my docstring looks weird? (style vs renderer etc..)
22+
# Preview the documentation site.
23+
# Use quarto render to generate the final site.
24+
quarto preview
25+
```
26+
27+
## Rebuilding doc pages
28+
29+
```bash
30+
quartodoc build --verbose
31+
```

docs/get-started/basic-content.qmd

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
title: Configuring content
3+
jupyter:
4+
kernelspec:
5+
display_name: Python 3 (ipykernel)
6+
language: python
7+
name: python3
8+
---
9+
10+
Individual content entries (e.g. a function to be documented) can also be customized.
11+
For example, if you are documenting a python class, you may want to include or exclude
12+
documentation on specific methods on that class.
13+
14+
Specify content options by setting `name: <content name>`, along with any additional options.
15+
16+
For example, below is a piece of content, MdRenderer, specified without options.
17+
18+
```yaml
19+
contents:
20+
- MdRenderer
21+
```
22+
23+
We set it to only document its render method, by setting `name: MdRenderer` followed by the
24+
`members` option.
25+
26+
```yaml
27+
contents:
28+
- name: MdRenderer
29+
members:
30+
- render
31+
```
32+
33+
Behind the scenes, quartodoc represents each content entry as a [](`quartodoc.Auto`) element, since it specifies how to automatically document some object.
34+
35+
## Looking up objects
36+
37+
Finding python objects to document involves two pieces of configuration:
38+
39+
* the package name.
40+
* a list of objects for content.
41+
42+
Note that quartodoc can look up anything---whether functions, modules, classes, attributes, or methods.
43+
44+
```yaml
45+
quartodoc:
46+
package: quartodoc
47+
sections:
48+
- title: Some section
49+
desc: ""
50+
contents:
51+
- get_object # function: quartodoc.get_object
52+
- ast.preview # submodule func: quartodoc.ast.preview
53+
- MdRenderer # class: quartodoc.MdRenderer
54+
- MdRenderer.render # method: quartodoc.MDRenderer.render
55+
- renderers # module: quartodoc.renderers
56+
```
57+
58+
The functions listed in `contents` are assumed to be imported from the package.
59+
60+
## Module and class members
61+
62+
Documentation for modules and classes can automatically include their members (e.g. class methods and attributes; everything defined inside a module).
63+
64+
There are four styles for presenting child members:
65+
66+
```{python}
67+
#| echo: false
68+
#| output: asis
69+
70+
# print out the attributes table of ChoicesChildren
71+
# this is overkill, but maybe a nice case of dogfooding
72+
from quartodoc import get_object, MdRenderer
73+
from quartodoc.builder.utils import extract_type
74+
from griffe.docstrings.dataclasses import DocstringSectionAttributes
75+
76+
renderer = MdRenderer()
77+
choices = get_object("quartodoc.layout.ChoicesChildren")
78+
res = extract_type(DocstringSectionAttributes, choices.docstring.parsed)[0]
79+
80+
print(renderer.render(res))
81+
```
82+
83+
You can specify a style by setting the `children` option in the config:
84+
85+
```yaml
86+
quartodoc:
87+
package: quartodoc
88+
sections:
89+
- title: Some section
90+
desc: ""
91+
contents:
92+
93+
# set the children option, so that methods get documented
94+
# on separate pages. MdRenderer's docs will include a summary
95+
# table that links to each page.
96+
- name: quartodoc.MdRenderer
97+
children: separate
98+
```
99+
100+
## Grouping on a page
101+
102+
By default, content in each section gets included in the same index table,
103+
with each piece of content documented on its own page.
104+
105+
For example, consider the config below.
106+
107+
```yaml
108+
quartodoc:
109+
package: quartodoc
110+
sections:
111+
- title: Cool functions
112+
desc: ""
113+
contents:
114+
- get_object
115+
- name: MdRenderer
116+
members: ["render"]
117+
```
118+
119+
Both `get_object` and `MdRenderer` will be:
120+
121+
* summarized and linked to in the "Cool functions" section of the index.
122+
* documented on their own, separate pages.
123+
124+
### Page layout element
125+
126+
Use a custom page element to group object documentation on the same page.
127+
128+
Custom page elements are specified by including a `kind: <element name>` field.
129+
130+
:::::: {.columns}
131+
132+
133+
::: {.column}
134+
135+
**Separate**
136+
137+
```yaml
138+
quartodoc:
139+
package: quartodoc
140+
sections:
141+
- title: Cool functions
142+
desc: ""
143+
144+
# normal contents setup ----
145+
contents:
146+
- get_object
147+
- name: MdRenderer
148+
members: ["render"]
149+
```
150+
151+
:::
152+
::: {.column}
153+
154+
**Grouped on same page**
155+
156+
```yaml
157+
quartodoc:
158+
package: quartodoc
159+
sections:
160+
- title: Cool functions
161+
desc: ""
162+
163+
# contents with a page grouping ----
164+
contents:
165+
- kind: page
166+
contents:
167+
- get_object
168+
- name: MdRenderer
169+
members: ["render"]
170+
```
171+
172+
:::
173+
::::::

docs/get-started/basic-docs.qmd

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Configuring docs
2+
title: Configuring site
33
jupyter:
44
kernelspec:
55
display_name: Python 3 (ipykernel)
@@ -52,94 +52,3 @@ It requires three pieces of configuration:
5252
* desc: a description for the section
5353
* contents: a list of functions to document
5454

55-
## Content configuration
56-
57-
Individual content entries (e.g. a function to be documented) can also be customized.
58-
For example, if you are documenting a python class, you may want to include or exclude
59-
documentation on specific methods on that class.
60-
61-
Specify content options by setting `name: <content name>`, along with any additional options.
62-
63-
For example, below is a piece of content, MdRenderer, specified without options.
64-
65-
```yaml
66-
contents:
67-
- MdRenderer
68-
```
69-
70-
We set it to only document its render method, by setting `name: MdRenderer` followed by the
71-
`members` option.
72-
73-
```yaml
74-
contents:
75-
- name: MdRenderer
76-
members:
77-
- render
78-
```
79-
80-
TODO: kinds of content, link to advanced layouts
81-
82-
## Looking up objects
83-
84-
Finding python objects to document involves two pieces of configuration:
85-
86-
* the package name.
87-
* a list of objects for content.
88-
89-
Note that quartodoc can look up anything---whether functions, modules, classes, attributes, or methods.
90-
91-
```yaml
92-
quartodoc:
93-
package: quartodoc
94-
sections:
95-
- title: Some section
96-
desc: ""
97-
contents:
98-
- get_object # function: quartodoc.get_object
99-
- ast.preview # submodule func: quartodoc.ast.preview
100-
- MdRenderer # class: quartodoc.MdRenderer
101-
- MdRenderer.render # method: quartodoc.MDRenderer.render
102-
- renderers # module: quartodoc.renderers
103-
```
104-
105-
The functions listed in `contents` are assumed to be imported from the package.
106-
107-
## Module and class members
108-
109-
Documentation for modules and classes can automatically include their members (e.g. class methods and attributes; everything defined inside a module).
110-
111-
There are four styles for presenting child members:
112-
113-
```{python}
114-
#| echo: false
115-
#| output: asis
116-
117-
# print out the attributes table of ChoicesChildren
118-
# this is overkill, but maybe a nice case of dogfooding
119-
from quartodoc import get_object, MdRenderer
120-
from quartodoc.builder.utils import extract_type
121-
from griffe.docstrings.dataclasses import DocstringSectionAttributes
122-
123-
renderer = MdRenderer()
124-
choices = get_object("quartodoc.layout.ChoicesChildren")
125-
res = extract_type(DocstringSectionAttributes, choices.docstring.parsed)[0]
126-
127-
print(renderer.render(res))
128-
```
129-
130-
You can specify a style by setting the `children` option in the config:
131-
132-
```yaml
133-
quartodoc:
134-
package: quartodoc
135-
sections:
136-
- title: Some section
137-
desc: ""
138-
contents:
139-
140-
# set the children option, so that methods get documented
141-
# on separate pages. MdRenderer's docs will include a summary
142-
# table that links to each page.
143-
- name: quartodoc.MdRenderer
144-
children: separate
145-
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: "Which dataclass do I need?"
3+
jupyter:
4+
kernelspec:
5+
display_name: Python 3 (ipykernel)
6+
language: python
7+
name: python3
8+
---
9+
10+
Choosing between all the dataclasses
11+
12+
* `griffe.dataclasses`
13+
* `griffe.docstrings.dataclasses`
14+
* `quartodoc.ast`
15+
* `quartodoc.layout`

0 commit comments

Comments
 (0)