Skip to content

Commit 887326e

Browse files
committed
adjust docs
1 parent 4d13e6f commit 887326e

File tree

5 files changed

+56
-23
lines changed

5 files changed

+56
-23
lines changed

.github/workflows/gh-pages.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,50 @@
1-
name: GitHub Pages
1+
name: Deploy Docs
22

33
on:
44
release:
5-
types:
6-
- created
5+
types: [created]
6+
pull_request:
7+
branches: [main]
78

89
jobs:
9-
job:
10-
name: GitHub Pages
10+
build:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
1414
- uses: actions/setup-python@v5
1515
with:
1616
python-version: "3.13"
17-
- name: Install project dependencies
17+
- name: Install dependencies
1818
run: pip install -e ".[dev]"
19+
- name: Generate versions.json
20+
run: |
21+
cat <<EOF > docs/versions.json
22+
[
23+
{
24+
"version": "latest",
25+
"url": "/xarray-dataclass/latest/"
26+
},
27+
{
28+
"version": "stable",
29+
"url": "/xarray-dataclass/stable/"
30+
}
31+
]
32+
EOF
1933
- name: Build docs
20-
run: python -m sphinx -b html docs docs/_build
34+
run: |
35+
# Set DOCS_VERSION env var according to event
36+
if [[ "${{ github.event_name }}" == "release" ]]; then
37+
export DOCS_VERSION=stable
38+
else
39+
export DOCS_VERSION=latest
40+
fi
41+
42+
python -m sphinx -b html docs docs/_build
43+
- name: Copy versions.json to build output
44+
run: cp docs/versions.json docs/_build/
2145
- name: Deploy docs
2246
uses: peaceiris/actions-gh-pages@v3
2347
with:
24-
force_orphan: true
2548
github_token: ${{ secrets.GITHUB_TOKEN }}
2649
publish_dir: ./docs/_build
50+
destination_dir: ${{ github.event_name == 'release' && 'stable' || 'latest' }}

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pixi add --pypi xarray-dataclasses
6767

6868
## Basic usage
6969

70-
xarray-dataclasses uses [the Python's dataclass].
70+
xarray-dataclass uses [the Python's dataclass].
7171
Data (or data variables), coordinates, attributes, and a name of DataArray or Dataset objects will be defined as dataclass fields by special type hints (`Data`, `Coord`, `Attr`, `Name`), respectively.
7272
Note that the following code is supposed in the examples below.
7373

@@ -378,25 +378,24 @@ pixi run pre-commit-install
378378
```
379379

380380
### Testing, linting, and formatting
381-
We have [a test workflow][test-workflow] for testing, static type checking, linting, and formatting the code.
382-
It is used for status checks when a pull request is created.
383-
If you would like to check them in local, the following commands are almost equivalent (the difference is that the workflow is run under multiple Python versions).
381+
We have a test workflow for testing and a pre-commit workflow for static type checking, linting, and formatting the code.
382+
It is performed when a pull request is created against main.
383+
If you would like to check them in local, the following commands are almost equivalent (the difference is that the test workflows are run under multiple Python versions).
384384
Furthermore, these tasks are defined only in the `dev` environment. Pixi does not require you to specify the environment
385385
in that case.
386386

387-
```shell
387+
```
388388
pixi run tests
389-
pixi run flake8
390-
pixi run black
391-
pixi run pyright
389+
pixi run -e dev pre-commit run --all-files
392390
```
393391

394392
### Creating documentation
395-
We also have a [documentation workflow] (Add link). However, if you want to locally create the documentation
393+
We also have a documentation workflow. However, if you want to locally create the documentation
396394
run the following:
397395

398396
```shell
399-
pixi run doc_build
397+
pixi run doc_build # this just creates the build
398+
pixi run doc_serve # build and serve at http://localhost:8000/
400399
```
401400

402401
### Create a release

docs/conf.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import os
2+
3+
version = os.environ.get("DOCS_VERSION", "unknown")
4+
release = version
5+
16
# project information
2-
author = "Akio Taniguchi"
3-
copyright = "2020-2024 Akio Taniguchi"
7+
author = "Wouter-Michiel Vierdag"
8+
copyright = "2025 Wouter-Michiel Vierdag"
49

510

611
# general configuration
@@ -31,6 +36,10 @@
3136
"image_light": "logo-light.svg",
3237
"image_dark": "logo-dark.svg",
3338
},
34-
"github_url": "https://github.com/astropenguin/xarray-dataclasses/",
35-
"twitter_url": "https://twitter.com/astropengu_in/",
39+
"switcher": {
40+
"json_url": "https://xarray-contrib.github.io/xarray-dataclass/versions.json",
41+
"version_match": version,
42+
},
43+
"github_url": "https://github.com/xarray-contrib/xarray-dataclass/",
44+
"twitter_url": "https://x.com/xarray_dev/",
3645
}

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ dev = { features = ["dev"], solve-group = "default" }
7474
[tool.pixi.feature.dev.tasks]
7575
tests = "pytest"
7676
doc_build = { cmd = "sphinx-apidoc -efT -o docs/_apidoc src/xarray_dataclasses && sphinx-build -a docs docs/_build" }
77+
doc_serve = { cmd = "sphinx-build -a docs docs/_build && python -m http.server --directory docs/_build 8000" }
7778

7879
[tool.pyright]
7980
reportMissingImports = "none"

0 commit comments

Comments
 (0)