Skip to content

Commit 05831ea

Browse files
authored
feat(docs): Publish pdoc-generated API reference to GitHub Pages (#651)
1 parent a75e51f commit 05831ea

6 files changed

Lines changed: 771 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish API Docs
2+
on:
3+
push:
4+
tags: ['v*']
5+
workflow_dispatch:
6+
permissions:
7+
contents: read
8+
pages: write
9+
id-token: write
10+
concurrency:
11+
group: pages
12+
cancel-in-progress: false
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
- uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
19+
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
20+
with:
21+
python-version-file: pyproject.toml
22+
- run: ./scripts/docs.sh
23+
- uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
24+
- name: Archive site
25+
run: |
26+
tar \
27+
--dereference --hard-dereference \
28+
--directory docs/_site \
29+
-cvf "$RUNNER_TEMP/artifact.tar" \
30+
--exclude=.git \
31+
--exclude=.github \
32+
.
33+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
34+
with:
35+
name: github-pages
36+
path: ${{ runner.temp }}/artifact.tar
37+
retention-days: 1
38+
if-no-files-found: error
39+
deploy:
40+
needs: build
41+
environment:
42+
name: github-pages
43+
url: ${{ steps.deployment.outputs.page_url }}
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0
47+
id: deployment

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ instance/
7272
# Sphinx documentation
7373
docs/_build/
7474

75+
# pdoc documentation
76+
docs/_site/
77+
7578
# PyBuilder
7679
target/
7780

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ test = [
3636
lint = ["ruff~=0.15"]
3737
type_check = ["pyright~=1.1"]
3838
nox = ["nox~=2026.2", "nox-uv~=0.7"]
39+
docs = ["pdoc>=14", "pydoc-markdown>=4"]
3940

4041

4142
[tool.pytest.ini_options]

scripts/docs-serve.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -eu
3+
cd "$(dirname "$0")/.."
4+
if [ "${1:-}" = "--live" ]; then
5+
exec uv run --group docs pdoc workos -p 4000 --docformat google
6+
fi
7+
if [ ! -d docs/_site ]; then
8+
./scripts/docs.sh
9+
fi
10+
exec python3 -m http.server 4000 --directory docs/_site

scripts/docs.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -eu
3+
cd "$(dirname "$0")/.."
4+
rm -rf docs/_site
5+
uv run --group docs pdoc workos -o docs/_site --docformat google
6+
if [ ! -f docs/_site/index.html ] && [ -f docs/_site/workos.html ]; then
7+
cp docs/_site/workos.html docs/_site/index.html
8+
fi
9+
uv run --group docs pydoc-markdown -p workos --render-toc > docs/_site/workos.md
10+
cp docs/_site/workos.md docs/_site/index.md
11+
12+
version=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
13+
cat > docs/_site/llms.txt <<EOF
14+
# WorkOS Python SDK
15+
16+
> Official Python client for the WorkOS API. Provides synchronous and
17+
> asynchronous clients for SSO, Directory Sync, User Management, Audit Logs,
18+
> Organizations, Events, Webhooks, and more. Current version: ${version}.
19+
20+
The full API reference is available as markdown at [index.md](index.md).
21+
HTML documentation is at [index.html](index.html).
22+
23+
## Docs
24+
25+
- [Full API reference (markdown)](index.md): every public class and function in the \`workos\` package
26+
- [HTML API reference](index.html): browsable pdoc-rendered site
27+
- [WorkOS product documentation](https://workos.com/docs): guides, concepts, and REST API reference
28+
- [Python SDK guide](https://workos.com/docs/sdks/python): installation and getting started
29+
30+
## Source
31+
32+
- [GitHub repository](https://github.com/workos/workos-python)
33+
- [PyPI package](https://pypi.org/project/workos/)
34+
EOF

0 commit comments

Comments
 (0)