Skip to content

Commit a6a36d2

Browse files
committed
elaborate on programming docs
1 parent 72a8251 commit a6a36d2

File tree

1 file changed

+54
-7
lines changed

1 file changed

+54
-7
lines changed

docs/get-started/dev-prepare.qmd

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: "Prep: Auto, blueprint, collect"
2+
title: "Components: Auto, blueprint, collect"
33
jupyter:
44
jupytext:
55
text_representation:
@@ -14,29 +14,76 @@ jupyter:
1414
---
1515

1616
```{python}
17-
from quartodoc import Auto, blueprint, collect, preview
17+
from quartodoc import collect, preview
1818
from quartodoc import MdRenderer
1919
from quartodoc import layout
2020
import yaml
2121
```
2222

23+
### `Auto`: Config Options
2324

24-
### Auto discovery of functions, classes, and more
25+
The `Auto` class contains data about how you wish to render a specific Python object, which you typically set in configuration options via the `quartodoc` section of your `_quarto.yml` file. In other words, `Auto` is a data structure that represents the configuration options for a specific Python object.
2526

27+
In the [previous](dev-big-picture.qmd) section, be demonstrated how we can find the `Auto` object corresponding to the `MdRenderer` class from our yaml configuration:
28+
29+
We can find the `Auto` object corresponding to the python object from our yaml configuration like this:
30+
31+
```{python}
32+
import yaml
33+
from quartodoc import Builder
34+
35+
cfg = yaml.safe_load("""
36+
quartodoc:
37+
package: quartodoc
38+
style: pkgdown
39+
sections:
40+
- title: "Some section"
41+
desc: "Some description"
42+
contents:
43+
- name: MdRenderer
44+
members: ["render", "summarize"]
45+
children: separate
46+
""")
47+
48+
builder = Builder.from_quarto_config(cfg)
49+
auto_from_yml = builder.layout.sections[0].contents[0]
50+
print(auto_from_yml)
51+
```
52+
53+
We can see many of the configuration options such as `members`, `name` and `children` as well as other options we didn't specify but are set to their default values. For example, we didn't set the option for [`dynamic`](basic-content.qmd#dynamic-lookup) but it is set to `false` by default.
54+
55+
However, we don't have to start with `yaml` files to create an `Auto` object. We can also create an `Auto` object with the fully qualified name of any Python object. For example, we can create an `Auto` object for the `MdRenderer` class like this:
2656
```{python}
27-
auto = Auto(name = "quartodoc.get_object")
28-
auto
57+
from quartodoc import Auto
58+
auto = Auto(name = "quartodoc.MdRenderer", signature_name = 'short')
59+
print(auto)
2960
```
3061

31-
* auto just represents what we want to do, blueprint has all the logic.
32-
* explain options like dynamic, show them in blueprint section
62+
However, since we didn't specify any options, this is not the same `Auto` that we got from the yaml. For example, the `members` option is not set to `["render", "summarize"]` as it was in the yaml. Instead, it is set to `None` which means that all members will be included. We can see this by looking at the `obj` attribute of the `Auto` object:
63+
64+
```{python}
65+
print(auto.members)
66+
```
67+
68+
To set this option, we can pass it to the `Auto` constructor:
69+
70+
```{python}
71+
auto = Auto(name = "quartodoc.MdRenderer",
72+
members = ["render", "summarize"]
73+
)
74+
75+
assert auto.members == auto_from_yml.members
76+
print(auto)
77+
```
3378

79+
Understanding how `Auto` an object created is helpful in case you need to debug `quartodoc`. If you find that a configuration option is not being set as you expect, you can create an `Auto` object for the Python object in question and compare it to the `Auto` object that you expect to be created from your yaml configuration.
3480

3581
## Blueprint: create a renderable doc recipe
3682

3783
### From Auto
3884

3985
```{python}
86+
from quartodoc import blueprint
4087
doc = blueprint(auto)
4188
doc
4289
```

0 commit comments

Comments
 (0)