Skip to content

Commit 830f140

Browse files
authored
Merge pull request #148 from machow/docs-misc-fixes
docs: miscellaneous updates
2 parents 68cef3e + cbfcabb commit 830f140

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

docs/get-started/basic-content.qmd

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ contents:
2929
- render
3030
```
3131

32-
Behind the scenes, quartodoc represents each content entry as a [](`quartodoc.Auto`) element, since it specifies how to automatically document some object.
32+
In the following sections, we'll discuss different options for configuring content.
33+
3334

3435
## Looking up objects
3536

@@ -164,6 +165,7 @@ quartodoc:
164165
# contents with a page grouping ----
165166
contents:
166167
- kind: page
168+
path: some_funcs
167169
contents:
168170
- get_object
169171
- name: MdRenderer
@@ -173,6 +175,15 @@ quartodoc:
173175
:::
174176
::::::
175177

178+
Note these three important pieces of the page entry:
179+
180+
* `kind: page` - indicates that we are creating a page
181+
* `path:` - specifies what the name of the page will be in the generated docs.
182+
For example, `path: some_funcs` in the config above produces a file called
183+
`some_funcs.qmd` in the API reference folder.
184+
* `contents:` - lists out the contents of the page.
185+
186+
176187

177188
## Setting default package path
178189

@@ -204,6 +215,10 @@ quartodoc:
204215
package: pandas
205216
contents:
206217
- DataFrame # pandas.DataFrame
218+
219+
# (4) package set on individual content entry
220+
- package: pandas
221+
name: Series
207222
```
208223

209224
Use `package: null` to unset the package option. This enables you to specify objects using their full name.
@@ -232,4 +247,4 @@ In this case, you can set the dynamic option on a piece of content.
232247
contents:
233248
- name: get_object
234249
dynamic: true
235-
```
250+
```

docs/get-started/overview.qmd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@ First, create a `_quarto.yml` file with the following:
4646
project:
4747
type: website
4848

49+
# tell quarto to read the generated sidebar
50+
metadata-files:
51+
- _sidebar.yml
52+
53+
4954
quartodoc:
5055
# the name used to import the package
5156
package: quartodoc
57+
58+
# write sidebar data to this file
59+
sidebar: _sidebar.yml
60+
5261
sections:
5362
- title: Some functions
5463
desc: Functions to inspect docstrings.

quartodoc/ast.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,17 @@ def tuple_to_data(el: "tuple[ds.DocstringSectionKind, str]"):
160160

161161
@dispatch
162162
def fields(el: BaseModel):
163+
# TODO: this is the only quartodoc specific code.
164+
# pydantic seems to copy MISSING() when it's a default, so we can't
165+
# whether a MISSING() is the default MISSING(). Instead, we'll just
166+
# use isinstance for this particular class
167+
from .layout import MISSING
168+
163169
# return fields whose values were not set to the default
164170
field_defaults = {mf.name: mf.default for mf in el.__fields__.values()}
165-
return [k for k, v in el if field_defaults[k] is not v]
171+
return [
172+
k for k, v in el if field_defaults[k] is not v if not isinstance(v, MISSING)
173+
]
166174

167175

168176
@dispatch

quartodoc/layout.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@ class Auto(_Base):
203203
to return an alias for that object.
204204
children:
205205
Style for presenting members. Either separate, embedded, or flat.
206+
package:
207+
If specified, object lookup will be relative to this path.
208+
206209
207210
"""
208211

@@ -214,6 +217,7 @@ class Auto(_Base):
214217
exclude: Optional[str] = None
215218
dynamic: Union[bool, str] = False
216219
children: ChoicesChildren = ChoicesChildren.embedded
220+
package: Union[str, None, MISSING] = MISSING()
217221

218222

219223
# TODO: rename to Default or something

quartodoc/renderers/md_renderer.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,12 @@ def render(self, el: ds.DocstringSectionAttributes):
426426
@dispatch
427427
def render(self, el: ds.DocstringAttribute):
428428
annotation = self.render_annotation(el.annotation)
429-
return el.name, self.render_annotation(annotation), el.description
429+
row = [
430+
sanitize(el.name),
431+
self.render_annotation(annotation),
432+
sanitize(el.description or "")
433+
]
434+
return row
430435

431436
# warnings ----
432437

quartodoc/tests/test_builder_blueprint.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,12 @@ def test_blueprint_visit_module(bp, dynamic):
7070
assert len(res.members) == 1
7171
assert res.members[0].name == "a_func"
7272
assert res.members[0].obj.path == path.replace(":", ".") + ".a_func"
73+
74+
75+
def test_blueprint_auto_package(bp):
76+
auto = lo.Auto(name="a_func", package="quartodoc.tests.example")
77+
res = bp.visit(auto)
78+
79+
assert isinstance(res, lo.DocFunction)
80+
assert res.name == "a_func"
81+
assert res.anchor == "quartodoc.tests.example.a_func"

0 commit comments

Comments
 (0)