Skip to content

Commit 4f5b3d5

Browse files
committed
Track docs publish script
1 parent 8060d44 commit 4f5b3d5

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,22 @@ The rendered site lands in `docs/_site/`. The generated API source pages land in
9999
__from wheel__
100100
- download the appropriate `.whl` for your system from the more recent release listed in `Releases` and run `uv pip install ./pyensmallen...` OR
101101
- copy the download url and run `uv pip install https://github.com/apoorvalal/pyensmallen/releases/download/<version>/pyensmallen-<version>-<pyversion>-linux_x86_64.whl`
102+
103+
## Documentation
104+
105+
GitHub Pages is served from the `gh-pages` branch. This repository does not
106+
auto-publish the website when `master` changes, so updating the site is a
107+
separate step.
108+
109+
After rendering the documentation site into `docs/_site/`, publish it with:
110+
111+
```bash
112+
scripts/publish_docs.sh
113+
```
114+
115+
The script:
116+
117+
- creates a temporary worktree for `gh-pages`
118+
- syncs `docs/_site/` into that worktree
119+
- commits the site update if anything changed
120+
- pushes `gh-pages` to `origin`

scripts/publish_docs.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
SITE_DIR="${ROOT_DIR}/docs/_site"
6+
WORKTREE_DIR="$(mktemp -d "${TMPDIR:-/tmp}/pyensmallen-gh-pages.XXXXXX")"
7+
8+
cleanup() {
9+
if git -C "${ROOT_DIR}" worktree list | grep -q "${WORKTREE_DIR}"; then
10+
git -C "${ROOT_DIR}" worktree remove --force "${WORKTREE_DIR}"
11+
fi
12+
rm -rf "${WORKTREE_DIR}"
13+
}
14+
15+
trap cleanup EXIT
16+
17+
if [ ! -d "${SITE_DIR}" ]; then
18+
echo "docs/_site does not exist. Render the documentation site before publishing." >&2
19+
exit 1
20+
fi
21+
22+
git -C "${ROOT_DIR}" worktree add "${WORKTREE_DIR}" gh-pages
23+
rsync -a --delete --exclude .git "${SITE_DIR}/" "${WORKTREE_DIR}/"
24+
touch "${WORKTREE_DIR}/.nojekyll"
25+
26+
git -C "${WORKTREE_DIR}" add -A
27+
28+
if git -C "${WORKTREE_DIR}" diff --cached --quiet; then
29+
echo "No site changes to publish."
30+
exit 0
31+
fi
32+
33+
git -C "${WORKTREE_DIR}" commit -m "Update published docs site"
34+
git -C "${WORKTREE_DIR}" push origin gh-pages
35+
36+
echo "Published docs/_site to gh-pages."

0 commit comments

Comments
 (0)