Skip to content

Commit 8efcda7

Browse files
authored
Merge pull request #35 from machow/docs-extend
docs: page on extending
2 parents 65cd666 + e6629f6 commit 8efcda7

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

docs/_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ website:
8383
- get-started/crossrefs.qmd
8484
- get-started/interlinks.qmd
8585
- get-started/sidebar.qmd
86+
- get-started/extending.qmd
8687
- section: "Advanced"
8788
contents:
8889
- get-started/docstrings.qmd

docs/get-started/extending.qmd

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: More Customization
3+
---
4+
5+
This page details 3 common aspects of quartodoc you can extend:
6+
7+
* The reference index page generated (which lists all your functions).
8+
* The way docstrings are renderered.
9+
* The overall building process.
10+
11+
12+
## Using a custom index page
13+
14+
Use a custom index page to add content before or after the automatically generated
15+
API index.
16+
17+
You can do this by setting quartodoc's `out_index` to be something other than `index.qmd`,
18+
and then including it in a custom `index.qmd` file.
19+
20+
First, set `out_index` in your `_quarto.yml`:
21+
22+
```yaml
23+
website:
24+
navbar:
25+
left:
26+
- file: reference/index.qmd
27+
text: Reference
28+
29+
quartodoc:
30+
dir: reference
31+
out_index: reference/_api_index.qmd
32+
```
33+
34+
Then, create the file `reference/index.qmd` to have the form:
35+
36+
```bash
37+
---
38+
---
39+
40+
Some custom content.
41+
42+
43+
{{< include /reference/_api_index.qmd >}}
44+
45+
46+
More content stuff.
47+
```
48+
49+
Notice that the shortcode `{{< include ... >}}` is used to insert the index file generated
50+
by quartodoc (`_api_index.qmd`).
51+
52+
53+
## Using a custom Renderer
54+
55+
Use a custom renderer to add custom content after a renderered docstring, or
56+
to change the rendering process in general.
57+
58+
You can do this by creating a custom file for your renderer in your docs folder, like `_renderer.py`,
59+
and then referencing it in your `_quarto.yml`.
60+
61+
```yaml
62+
quartodoc:
63+
renderer:
64+
style: _renderer.py
65+
```
66+
67+
See the [shiny example docs](https://github.com/machow/quartodoc/tree/main/examples/shiny), which contains a custom renderer.
68+
69+
70+
## Using a custom Builder
71+
72+
Since the Builder controls the full quartodoc build process, using a custom builder
73+
provides total flexibility. This option currently isn't available, but would be easy
74+
to enable.
75+
76+
Please leave a note on [this issue](https://github.com/machow/quartodoc/issues/34) if you
77+
need to use a custom builder.

0 commit comments

Comments
 (0)