Skip to content

Commit 8d9bed7

Browse files
committed
update dev page
1 parent a6a36d2 commit 8d9bed7

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

docs/get-started/dev-prepare.qmd

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,51 @@ assert auto.members == auto_from_yml.members
7676
print(auto)
7777
```
7878

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.
79+
Understanding the `Auto` object is helpful for debugging `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.
8080

81-
## Blueprint: create a renderable doc recipe
81+
## `blueprint`: Parse Metadata From Objects
8282

83-
### From Auto
83+
`blueprint` parses all of the metadata about the python object and stores it in a hierarchal tree structure that is convenient for a renderer to transform into a renderable format like HTML or Markdown. For example, here is the blueprint for the `MdRenderer` class:
8484

8585
```{python}
8686
from quartodoc import blueprint
8787
doc = blueprint(auto)
88-
doc
88+
preview(doc, max_depth=2)
8989
```
9090

91+
To give you a sense of this tree structure, we can look at the `obj.docstring` field of the above blueprint, which contains information about the [Python docstring](https://peps.python.org/pep-0257/):
92+
9193
```{python}
9294
preview(doc.obj.docstring, max_depth=2)
9395
```
9496

97+
We can see from this output that the parser for the docstring is `numpy`, which means the docstring is expected to be in the [numpy style](https://numpydoc.readthedocs.io/en/latest/format.html).
98+
99+
Furthermore, we can see from the tree structure that the `DocstringSectionText` is stored as the first element in a list under the `parsed` attribute:
100+
101+
```{python}
102+
preview(doc.obj.docstring.parsed[0])
103+
```
104+
105+
`DocstringSectionText` stores the "text" field of a [numpy style](https://numpydoc.readthedocs.io/en/latest/format.html) docstring, which is the first line of the docstring, which is otherwise known as the [short summary](https://numpydoc.readthedocs.io/en/latest/format.html#short-summary).
106+
Furthermore, we can see from the output above that the actual text of this short summary is stored in the `value` attribute:
107+
108+
```{python}
109+
docstr_firstln_value = doc.obj.docstring.parsed[0].value
110+
print(docstr_firstln_value)
111+
```
112+
113+
We can check the docstring of `MdRenderer` to see that this is indeed the first line of the docstring:
114+
115+
```{python}
116+
from inspect import getdoc
117+
docstr_firstln = getdoc(MdRenderer).splitlines()[0]
118+
119+
# These are the same
120+
assert docstr_firstln == docstr_firstln_value
121+
print(docstr_firstln)
122+
```
123+
95124
### Layout and Section
96125

97126
```{python}

0 commit comments

Comments
 (0)