Skip to content

Commit b5a9518

Browse files
authored
Merge pull request #385 from machow/fix-intro-snippet
docs: regenerate gh readme
2 parents d998394 + c0e2b6d commit b5a9518

File tree

5 files changed

+62
-13
lines changed

5 files changed

+62
-13
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ jobs:
9898
python -m pip install shiny shinylive
9999
python -m pip install --no-deps dascore==0.0.8
100100
- uses: quarto-dev/quarto-actions/setup@v2
101+
- name: Test building starter template
102+
run: |
103+
make test-overview-template
101104
- name: Build docs
102105
run: |
103106
make docs-build

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,7 @@ docs-build: docs-build-examples
5050
cd docs && quarto add --no-prompt ..
5151
quarto render docs
5252

53+
test-overview-template:
54+
python scripts/build_tmp_starter.py
55+
5356
test-interlinks: quartodoc/tests/example_interlinks/test.md

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Overview
22

3+
34
[![CI](https://github.com/machow/quartodoc/actions/workflows/ci.yml/badge.svg)](https://github.com/machow/quartodoc/actions/workflows/ci.yml)
45

56
**quartodoc** lets you quickly generate Python package API reference
@@ -11,6 +12,7 @@ Check out the below screencast for a walkthrough of creating a
1112
documentation site, or read on for instructions.
1213

1314
<p align="center">
15+
1416
<a href="https://www.loom.com/share/fb4eb736848e470b8409ba46b514e2ed">
1517
<img src="https://cdn.loom.com/sessions/thumbnails/fb4eb736848e470b8409ba46b514e2ed-00001.gif" width="75%">
1618
</a>
@@ -30,16 +32,14 @@ or from GitHub
3032
python -m pip install git+https://github.com/machow/quartodoc.git
3133
```
3234

33-
<div>
34-
35-
> **Install Quarto**
35+
> [!IMPORTANT]
36+
>
37+
> ### Install Quarto
3638
>
3739
> If you haven’t already, you’ll need to [install
3840
> Quarto](https://quarto.org/docs/get-started/) before you can use
3941
> quartodoc.
4042
41-
</div>
42-
4343
## Basic use
4444

4545
Getting started with quartodoc takes two steps: configuring quartodoc,
@@ -54,21 +54,29 @@ you need to add a `quartodoc` section to the top level your
5454
`_quarto.yml` file. Below is a minimal example of a configuration that
5555
documents the `quartodoc` package:
5656

57+
<!-- Starter Template -->
58+
5759
``` yaml
5860
project:
5961
type: website
6062

6163
# tell quarto to read the generated sidebar
6264
metadata-files:
63-
- _sidebar.yml
65+
- reference/_sidebar.yml
6466

67+
# tell quarto to read the generated styles
68+
format:
69+
html:
70+
css:
71+
- reference/_styles-quartodoc.css
6572

6673
quartodoc:
6774
# the name used to import the package you want to create reference docs for
6875
package: quartodoc
6976

70-
# write sidebar data to this file
71-
sidebar: _sidebar.yml
77+
# write sidebar and style data
78+
sidebar: reference/_sidebar.yml
79+
css: reference/_styles-quartodoc.css
7280

7381
sections:
7482
- title: Some functions

docs/get-started/overview.qmd

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,29 @@ Getting started with quartodoc takes two steps: configuring quartodoc, then gene
7171

7272
You can configure quartodoc alongside the rest of your Quarto site in the [`_quarto.yml`](https://quarto.org/docs/projects/quarto-projects.html) file you are already using for Quarto. To [configure quartodoc](./basic-docs.qmd#site-configuration), you need to add a `quartodoc` section to the top level your `_quarto.yml` file. Below is a minimal example of a configuration that documents the `quartodoc` package:
7373

74+
<!-- Starter Template -->
75+
7476
```yaml
7577
project:
7678
type: website
7779

7880
# tell quarto to read the generated sidebar
7981
metadata-files:
80-
- api/_sidebar.yml
82+
- reference/_sidebar.yml
8183

8284
# tell quarto to read the generated styles
8385
format:
84-
css:
85-
- api/_styles-quartodoc.css
86+
html:
87+
css:
88+
- reference/_styles-quartodoc.css
8689

8790
quartodoc:
8891
# the name used to import the package you want to create reference docs for
8992
package: quartodoc
9093

9194
# write sidebar and style data
92-
sidebar: api/_sidebar.yml
93-
css: api/_styles-quartodoc.css
95+
sidebar: reference/_sidebar.yml
96+
css: reference/_styles-quartodoc.css
9497

9598
sections:
9699
- title: Some functions

scripts/build_tmp_starter.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import re
2+
import tempfile
3+
import subprocess
4+
from pathlib import Path
5+
from quartodoc.__main__ import build
6+
7+
p = Path("docs/get-started/overview.qmd")
8+
overview = p.read_text()
9+
10+
indx = overview.index("<!-- Starter Template -->")
11+
yml_blurb = overview[indx:]
12+
13+
match = re.search(r"```yaml\s*(.*?)```", yml_blurb, re.DOTALL)
14+
if match is None:
15+
raise Exception()
16+
17+
template = match.group(1)
18+
19+
with tempfile.TemporaryDirectory() as tmpdir:
20+
tmpdir = Path(tmpdir)
21+
# Write the template to a file
22+
p_quarto = tmpdir / "_quarto.yml"
23+
p_quarto.write_text(template)
24+
25+
try:
26+
build(["--config", str(p_quarto), "--filter", "quartodoc"])
27+
except SystemExit as e:
28+
if e.code != 0:
29+
raise Exception() from e
30+
subprocess.run(["quarto", "render", str(p_quarto.parent)])
31+
32+
print("SITE RENDERED SUCCESSFULLY")

0 commit comments

Comments
 (0)