Skip to content

Commit 25ee611

Browse files
committed
add readthedocs config and project urls
1 parent 3866eaf commit 25ee611

File tree

8 files changed

+134
-10
lines changed

8 files changed

+134
-10
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ jobs:
3232

3333
# Generate Swagger UI docs
3434
- name: Fetch Swagger UI
35-
run: wget https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${SWAGGER_UI_RELEASE}.tar.gz
36-
- name: Extract Swagger UI
37-
run: tar xf v${SWAGGER_UI_RELEASE}.tar.gz -C docs/_static/ --strip=1 swagger-ui-${SWAGGER_UI_RELEASE}/dist/ --transform s/dist/swagger-ui/
35+
run: ./fetch_swagger.sh
3836
- name: Generate schema
3937
run: uv run generate-schema.py
4038

.readthedocs.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
3+
# Read the Docs configuration file
4+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
5+
6+
# Required
7+
version: 2
8+
9+
# Set the OS, Python version, and other tools you might need
10+
build:
11+
os: ubuntu-24.04
12+
tools:
13+
python: "3.13"
14+
jobs:
15+
post_checkout:
16+
- git fetch --unshallow || true
17+
- git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' || true
18+
- git fetch --all --tags || true
19+
create_environment:
20+
- asdf plugin add uv
21+
- asdf install uv 0.9.2
22+
- asdf global uv 0.9.2
23+
install:
24+
- uv sync
25+
pre_build:
26+
- ./fetch_swagger.sh
27+
- uv run generate-schema.py
28+
build:
29+
html:
30+
- uv run sphinx-build -T -b html docs/ $READTHEDOCS_OUTPUT/html
31+
32+
# Build documentation in the "docs/" directory with Sphinx
33+
sphinx:
34+
configuration: docs/conf.py
35+
36+
# Optionally, but recommended,
37+
# declare the Python requirements required to build your documentation
38+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
39+
# python:
40+
# install:
41+
# - requirements: docs/requirements.txt
42+
43+
44+

README.md

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,71 @@
66
![image](https://img.shields.io/pypi/pyversions/structured-tutorials.svg)
77
![image](https://img.shields.io/github/license/mathiasertl/structured-tutorials)
88

9-
`structured-tutorials` allows you to write tutorials that can be rendered as Sphinx documentation and also be
10-
run on your local system to verify correctness.
9+
`structured-tutorials` allows you to write tutorials that can be rendered as documentation and run on your
10+
system to verify correctness.
1111

12-
With `structured-tutorials` you to specify commands in a configuration file. A Sphinx plugin allows you to
12+
With `structured-tutorials` you to specify steps in a configuration file. A Sphinx plugin allows you to
1313
render those commands in your project documentation. A command-line tool can load the configuration file and
1414
run it on your local system.
1515

16+
Please see the [official documentation](https://structured-tutorials.readthedocs.io/) for more detailed
17+
information.
18+
19+
## Installation / Setup
20+
21+
Install `structured-tutorials`:
22+
23+
```
24+
pip install structured-tutorials
25+
```
26+
27+
and configure Sphinx:
28+
29+
```python
30+
extensions = [
31+
# ... other extensions
32+
"structured_tutorials.sphinx",
33+
]
34+
35+
# Optional: Root directory for tutorials
36+
#tutorial_root = DOC_ROOT / "tutorials"
37+
```
38+
39+
## Your first (trivial) tutorial
40+
41+
To create your first tutorial, create it in `docs/tutorial.yaml` (or elsewhere, if you configured
42+
`tutorial_root` in `conf.py`):
43+
44+
```yaml
45+
parts:
46+
- commands:
47+
- command: structured-tutorial --help
48+
doc:
49+
output: |
50+
usage: structured-tutorial [-h] path
51+
...
52+
```
53+
54+
### Run the tutorial
55+
56+
Run the tutorial with:
57+
58+
```
59+
$ structured-tutorial docs/tutorials/quickstart/tutorial.yaml
60+
usage: structured-tutorial [-h] path
61+
...
62+
```
63+
64+
### Render tutorial in Sphinx:
65+
66+
Configure the tutorial that is being displayed - this will not show any output:
67+
68+
```
69+
.. structured-tutorial:: quickstart/tutorial.yaml
70+
71+
.. structured-tutorial-part::
72+
```
73+
1674
## TODO
1775
* Run in vagrant
1876

docs/changelog.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#########
2+
ChangeLog
3+
#########
4+
5+
***********
6+
0.1.0 (TBR)
7+
***********
8+
9+
Initial version.

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ documentation for details.
1212

1313

1414
.. toctree::
15-
:maxdepth: 2
15+
:maxdepth: 1
1616
:caption: Contents:
1717

1818
/quickstart
1919
/how-tos
2020
/reference
21+
/changelog
2122
/dev
2223

fetch_swagger.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -ex
2+
3+
SWAGGER_UI_RELEASE=5.30.3
4+
5+
wget https://github.com/swagger-api/swagger-ui/archive/refs/tags/v${SWAGGER_UI_RELEASE}.tar.gz
6+
tar xf v${SWAGGER_UI_RELEASE}.tar.gz -C docs/_static/ --strip=1 swagger-ui-${SWAGGER_UI_RELEASE}/dist/ --transform s/dist/swagger-ui/

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ dynamic = ["version"]
3737
[project.scripts]
3838
structured-tutorial = "structured_tutorials.cli:main"
3939

40+
[project.urls]
41+
Homepage = "https://structured-tutorials.readthedocs.io/"
42+
Documentation = "https://structured-tutorials.readthedocs.io/"
43+
Source = "https://github.com/mathiasertl/structured-tutorials"
44+
Issues = "https://github.com/mathiasertl/structured-tutorials/issues"
45+
Changelog = "https://structured-tutorials.readthedocs.io/en/latest/changelog.html"
46+
4047
[tool.coverage.run]
4148
source = [
4249
"structured_tutorials",

tests/test_cli.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
"""Test the cli entry point function."""
55

6+
from collections.abc import Iterator
67
from pathlib import Path
78
from unittest.mock import patch
89

@@ -13,10 +14,10 @@
1314

1415

1516
@pytest.fixture(autouse=True)
16-
def mock_setup_logging() -> None:
17+
def mock_setup_logging() -> Iterator[None]:
1718
"""Fixture to mock logging setup - so that it is not called multiple times."""
18-
with patch("structured_tutorials.cli.setup_logging"):
19-
return
19+
with patch("structured_tutorials.cli.setup_logging", autospec=True):
20+
yield
2021

2122

2223
def test_simple_tutorial(simple_tutorial: TutorialModel) -> None:

0 commit comments

Comments
 (0)