Skip to content

Commit 393de6f

Browse files
committed
update docs
1 parent ccdab89 commit 393de6f

File tree

1 file changed

+68
-25
lines changed

1 file changed

+68
-25
lines changed

docs/get-started/dev-prepare.qmd

Lines changed: 68 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ jupyter:
1616
```{python}
1717
from quartodoc import collect, preview
1818
from quartodoc import MdRenderer
19-
from quartodoc import layout
2019
import yaml
2120
```
2221

@@ -55,7 +54,8 @@ We can see many of the configuration options such as `members`, `name` and `chil
5554
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:
5655
```{python}
5756
from quartodoc import Auto
58-
auto = Auto(name = "quartodoc.MdRenderer", signature_name = 'short')
57+
auto = Auto(name = "quartodoc.MdRenderer",
58+
signature_name = 'short')
5959
print(auto)
6060
```
6161

@@ -121,59 +121,102 @@ assert docstr_firstln == docstr_firstln_value
121121
print(docstr_firstln)
122122
```
123123

124-
### Layout and Section
124+
## Layout & Sections
125+
126+
The [](`~quartodoc.layout.Layout`) class stores how you wish to organize your documentation. For example, you may wish to organize your documentation into sections, where each section contains a title, description, and a list of objects to document. You can create a layout like this:
125127

126128
```{python}
129+
import yaml
130+
from quartodoc import Builder
131+
132+
cfg = yaml.safe_load("""
133+
quartodoc:
134+
package: quartodoc
135+
sections:
136+
- title: "Some section"
137+
desc: "Some description"
138+
contents:
139+
- name: MdRenderer
140+
- title: "Another section"
141+
desc: "Another description"
142+
contents:
143+
- Auto
144+
- blueprint
145+
""")
146+
147+
builder = Builder.from_quarto_config(cfg)
148+
auto_from_yml = builder.layout.sections[0].contents[0]
149+
preview(builder.layout, max_depth=3)
150+
```
151+
152+
As you can see, the `Layout` stores the sections, which are stored in the `sections` attribute. Each section contains a `title`, `desc`, and `contents` attribute and is stored in a [](`~quartodoc.layout.Section`) class.
153+
154+
The `contents` attribute is a list of objects to document. In this case, the first section contains a single object, the `MdRenderer` class, while the second section contains two objects. You can read more about Section options [here](basic-docs.qmd#section-options).
155+
156+
In addition to building a layout from a yaml file, you can also build a layout in Python by instantiating the `Layout` class like so:
157+
158+
```{python}
159+
from quartodoc import Auto, layout
160+
161+
auto = Auto(name = "quartodoc.MdRenderer",
162+
signature_name = 'short')
163+
127164
lay = layout.Layout(
128165
sections = [
129-
layout.Section(title = "A section", desc = "A description", contents = [auto])
166+
layout.Section(title = "A section",
167+
desc = "A description",
168+
contents = [auto])
130169
]
131170
)
132171
```
133172

134-
135-
:::::: {.columns}
136-
137-
::: {.column}
173+
We can view the layout by calling the `preview` function:
138174

139175
```{python}
140-
# raw layout
141-
preview(lay, compact=True)
176+
preview(lay,
177+
max_depth=8,
178+
compact=True)
142179
```
143180

144-
:::
145-
::: {.column}
146-
181+
Recall that the `blueprint` function parses all of the metadata about the Python object. We can see how a blueprint adds additional data pertaining to `MdRenderer`, that wasn't present in the layout above:
147182
```{python}
148-
bp_layout = blueprint(lay)
149-
preview(bp_layout, max_depth=5, compact=True)
183+
bp_layout = blueprint(lay)
184+
preview(bp_layout,
185+
max_depth=8,
186+
compact=True)
150187
```
151188

152-
:::
153189

154-
::::::
190+
### Grouping docs on a page
155191

156-
### Grouping docs on single Page
192+
The Layout also calculates how to split your sections into pages based on the options you set in your yaml configuration. For example, if you set the `children` option to `separate`, then each object in a section will be placed on its own page.
157193

158-
### Class members
194+
Let's see the difference between the `separate` and `embedded` options by creating two `Auto` objects for the `MdRenderer` class, one with `children` set to `separate` and the other with `children` set to `embedded`:
159195

160196
```{python}
161-
auto_separate = layout.Auto(name = "quartodoc.MdRenderer", children = "separate")
162-
auto_embedded = layout.Auto(name = "quartodoc.MdRenderer", children = "embedded")
197+
auto_sep = layout.Auto(name = "quartodoc.MdRenderer",
198+
children = "separate")
199+
auto_emb = layout.Auto(name = "quartodoc.MdRenderer",
200+
children = "embedded")
163201
```
164202

203+
165204
:::::: {.columns}
166205

167206
::: {.column}
168207
```{python}
169-
bp_embedded = blueprint(auto_embedded)
170-
preview(bp_embedded, max_depth=2)
208+
bp_emb = blueprint(auto_emb)
209+
preview(bp_emb,
210+
max_depth=2,
211+
compact=True)
171212
```
172213
:::
173214
::: {.column}
174215
```{python}
175-
bp_separate = blueprint(auto_separate)
176-
preview(bp_separate, max_depth=2)
216+
bp_sep = blueprint(auto_sep)
217+
preview(bp_sep,
218+
max_depth=2,
219+
compact=True)
177220
```
178221
:::
179222

0 commit comments

Comments
 (0)