Skip to content

Commit e325b8d

Browse files
committed
tests: script to test get-started template
1 parent 7edf864 commit e325b8d

File tree

4 files changed

+46
-4
lines changed

4 files changed

+46
-4
lines changed

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: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Check out the below screencast for a walkthrough of creating a
1212
documentation site, or read on for instructions.
1313

1414
<p align="center">
15+
1516
<a href="https://www.loom.com/share/fb4eb736848e470b8409ba46b514e2ed">
1617
<img src="https://cdn.loom.com/sessions/thumbnails/fb4eb736848e470b8409ba46b514e2ed-00001.gif" width="75%">
1718
</a>
@@ -53,6 +54,8 @@ you need to add a `quartodoc` section to the top level your
5354
`_quarto.yml` file. Below is a minimal example of a configuration that
5455
documents the `quartodoc` package:
5556

57+
<!-- Starter Template -->
58+
5659
``` yaml
5760
project:
5861
type: website
@@ -63,8 +66,9 @@ metadata-files:
6366

6467
# tell quarto to read the generated styles
6568
format:
66-
css:
67-
- reference/_styles-quartodoc.css
69+
html:
70+
css:
71+
- reference/_styles-quartodoc.css
6872

6973
quartodoc:
7074
# the name used to import the package you want to create reference docs for

docs/get-started/overview.qmd

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ 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
@@ -81,8 +83,9 @@ metadata-files:
8183

8284
# tell quarto to read the generated styles
8385
format:
84-
css:
85-
- reference/_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

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)