Skip to content

Commit 7ca758c

Browse files
authored
Merge pull request #18 from machow/feat-builder
Feat builder
2 parents 67eb185 + 8b622e7 commit 7ca758c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+1626
-2168
lines changed

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
README.md: README.qmd
22
quarto render $<
33

4-
docs-build:
4+
examples/%/_site: examples/%/_quarto.yml
5+
python -m quartodoc $<
6+
quarto render $(dir $<)
7+
8+
docs/examples/%: examples/%/_site
9+
rm -rf docs/examples/$*
10+
cp -rv $< $@
11+
12+
docs-build-examples: docs/examples/single-page docs/examples/pkgdown
13+
14+
docs-build: docs-build-examples
515
cd docs && quarto add --no-prompt ..
16+
cd docs && python -m quartodoc
617
quarto render docs
718

819
requirements-dev.txt:

README.qmd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ python3 -m pip install -e git+https://github.com/machow/quartodoc.git#egg=quarto
3131

3232
## Basic use
3333

34+
### Render a docstring
35+
3436
```{python}
3537
#| output: false
3638
@@ -68,6 +70,27 @@ print(
6870
<Function('get_function', ...
6971
```
7072

73+
### Build an index page
74+
75+
```{python}
76+
#| output: false
77+
78+
from quartodoc.autosummary import BuilderPkgdown
79+
80+
builder = BuilderPkgdown(
81+
[
82+
{"title": "first", "desc": "section 1", "contents": ["get_object", "get_function"]},
83+
{"title": "2nd", "desc": "section 2", "contents": ["MdRenderer"]}
84+
],
85+
"quartodoc"
86+
)
87+
88+
print(
89+
builder.render_index()
90+
)
91+
92+
```
93+
7194

7295

7396
## How it works

_extensions/interlinks/interlinks.lua

Lines changed: 0 additions & 84 deletions
This file was deleted.

_extensions/interlinks/interlinks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ def ref_to_anchor(ref: str, text: "str | pf.ListContainer | None"):
4848
except KeyError:
4949
raise KeyError(f"Cross reference not found in an inventory file: {stripped}")
5050

51+
pf.debug(f"TEXT IS: {text}")
5152
if not text:
53+
name = entry["name"] if entry["dispname"] == "-" else entry["dispname"]
5254
if is_shortened:
5355
# shorten names from module.sub_module.func_name -> func_name
54-
name = pf.Str(entry["name"].split(".")[-1])
56+
name = pf.Str(name.split(".")[-1])
5557
else:
56-
name = pf.Str(entry["name"])
58+
name = pf.Str(name)
5759
else:
5860
# when the element is an Link, content is a ListContainer, but it has to be
5961
# *splatted back into Link?

docs/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
/.quarto/
22
_site
3+
reference
4+
5+
examples/pkgdown
6+
examples/single-page

docs/1_generate_api.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

docs/_quarto.yml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,66 @@ project:
33
output-dir: _build
44
resources:
55
- objects.json
6+
- examples/single-page
7+
- examples/pkgdown
8+
#pre-render: "python -m quartodoc _quarto.yml"
69

710
filters:
811
- "interlinks"
912

1013
interlinks:
1114
sources:
1215
quartodoc:
13-
# TODO: how to have it be "site root"?
16+
# TODO: add note that this works as the site root
1417
url: "/"
1518
inv: null
1619
fallback: objects.json
1720

21+
quartodoc:
22+
style: pkgdown
23+
dir: api
24+
package: quartodoc
25+
sections:
26+
- title: API Builders
27+
desc: |
28+
Builders are responsible for building documentation. They tie all the pieces
29+
of quartodoc together, and can be defined in your _quarto.yml config.
30+
contents:
31+
- Builder
32+
- BuilderPkgdown
33+
- BuilderSinglePage
34+
35+
- title: Docstring Renderers
36+
desc: |
37+
Renderers convert parsed docstrings into a target format, like markdown.
38+
contents:
39+
- MdRenderer
40+
41+
- title: Inspection
42+
desc: |
43+
These functions Fetch and analyze python objects, including parsing docstrings.
44+
contents:
45+
- get_object
46+
- preview
47+
48+
- title: Inventory links
49+
desc: |
50+
Inventory files map a functions name to its corresponding url in your docs.
51+
These functions allow you to create and transform inventory files.
52+
contents:
53+
- create_inventory
54+
- convert_inventory
55+
56+
1857
website:
1958
title: "quartodoc"
59+
page-navigation: true
2060
navbar:
2161
left:
2262
- file: get-started/overview.qmd
2363
text: Get Started
64+
- file: examples/
65+
text: Examples
2466
- href: api/
2567
text: Reference
2668
right:
@@ -32,15 +74,20 @@ website:
3274
style: floating
3375
align: left
3476
contents:
77+
- get-started/overview.qmd
3578
- section: "Basics"
3679
contents:
37-
- get-started/overview.qmd
3880
- get-started/basic-docs.qmd
3981
- get-started/crossrefs.qmd
82+
- get-started/sidebar.qmd
4083
- section: "Advanced"
4184
contents:
4285
- get-started/docstrings.qmd
86+
- get-started/renderers.qmd
4387
- get-started/interlinks.qmd
88+
- section: "Extra Topics"
89+
contents:
90+
- get-started/architecture.qmd
4491
- id: dummy
4592

4693

0 commit comments

Comments
 (0)