@@ -7,13 +7,13 @@ jupyter:
7
7
name : python3
8
8
---
9
9
10
- ## Adding configuration
10
+ ## Site configuration
11
11
12
12
quartodoc is configured by adding a ` quartodoc ` section to your ` _quarto.yml ` :
13
13
14
14
``` yaml
15
15
quartodoc :
16
- style : single-page
16
+ style : pkgdown
17
17
dir : reference
18
18
package : quartodoc
19
19
sections :
@@ -24,7 +24,7 @@ quartodoc:
24
24
- preview
25
25
` ` `
26
26
27
- ## Top-level options
27
+ ### Top-level options
28
28
29
29
The ` quartodoc` section takes a `style` field, specifying which [](`quartodoc.Builder`)
30
30
to use (currently "pkgdown" or "single-page"; see [Examples](/examples/)).
@@ -42,41 +42,104 @@ doc_params = [entry for entry in doc_parts if entry.kind.name == "parameters"][0
42
42
print(renderer.render(doc_params))
43
43
` ` `
44
44
45
- # # Section options
45
+ # ## Section options
46
46
47
47
The `sections` field defines which functions to document.
48
48
49
- | Name | Type | Description |
50
- | ---- | ---- | ----------- |
51
- | title | str | A title for the section |
52
- | desc | str | A description for the section |
53
- | contents | list[str] | A list of functions to document |
49
+ It requires three pieces of configuration :
54
50
51
+ * title: a title for the section
52
+ * desc: a description for the section
53
+ * contents: a list of functions to document
55
54
56
- # # Looking up functions
55
+ # # Content configuration
57
56
58
- Finding functions to document involves two pieces of configuration :
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 :
59
85
60
86
* the package name.
61
- * a list of functions for content.
87
+ * a list of objects for content.
88
+
89
+ Note that quartodoc can look up anything---whether functions, modules, classes, attributes, or methods.
62
90
63
91
` ` ` yaml
64
92
quartodoc:
65
93
package: quartodoc
66
94
sections:
67
- - contents:
68
- # top-level function: quartodoc.get_object
69
- - get_object
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).
70
110
71
- # top-level class: quartodoc.MdRenderer
72
- - MdRenderer
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
73
122
74
- # submodule function: quartodoc.ast.preview
75
- - ast.preview
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))
76
128
` ` `
77
129
78
- The functions listed in `contents` are assumed to be imported from the package.
130
+ You can specify a style by setting the `children` option in the config :
79
131
80
- # ## Class methods
132
+ ` ` ` yaml
133
+ quartodoc:
134
+ package: quartodoc
135
+ sections:
136
+ - title: Some section
137
+ desc: ""
138
+ contents:
81
139
82
- Currently, quartodoc can't look up class methods. (Though this would be quick to implement!).
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
+ ` ` `
0 commit comments