feat(docs): Publish pdoc-generated API reference to GitHub Pages#651
feat(docs): Publish pdoc-generated API reference to GitHub Pages#651gjtorikian merged 2 commits intomainfrom
Conversation
Users and integrators have no browsable reference for the Python SDK's public API. Generate the site with pdoc on tag pushes and publish it to GitHub Pages so the docs stay in lockstep with releases. The workflow tars the site manually and uploads it via actions/upload-artifact rather than upload-pages-artifact, which Socket flagged for an input-argument taint flow (matching the workos-dotnet and workos-kotlin fixes).
LLM-driven coding assistants look for /llms.txt at a docs site root to discover the canonical reference. Emitting one alongside the pdoc output makes the published Python SDK docs directly consumable by those tools without forcing them to crawl the HTML.
Greptile SummaryThis PR adds a GitHub Actions workflow to publish pdoc-generated API reference docs to GitHub Pages on tag pushes, along with local build and preview scripts, a
Confidence Score: 4/5Safe to merge once the tomllib compatibility gap is addressed; all other changes are additive and low-risk. The docs.sh script calls scripts/docs.sh — the tomllib import needs a 3.10-compatible fallback. Important Files Changed
|
| uv run --group docs pydoc-markdown -p workos --render-toc > docs/_site/workos.md | ||
| cp docs/_site/workos.md docs/_site/index.md | ||
|
|
||
| version=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") |
There was a problem hiding this comment.
tomllib was added to Python's standard library in 3.11, but this project requires python >= 3.10. Running this script under Python 3.10 will fail with ModuleNotFoundError: No module named 'tomllib'. In CI the setup-python step may resolve to a newer interpreter, but locally — or if uv selects Python 3.10 — the build breaks at the version-extraction step.
| version=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") | |
| version=$(uv run python -c " | |
| try: | |
| import tomllib | |
| except ImportError: | |
| try: | |
| import tomli as tomllib | |
| except ImportError: | |
| import sys, re | |
| data = open('pyproject.toml').read() | |
| m = re.search(r'^version\s*=\s*\"([^\"]+)\"', data, re.MULTILINE) | |
| if not m: | |
| sys.exit('Cannot determine version from pyproject.toml') | |
| print(m.group(1)) | |
| raise SystemExit(0) | |
| print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version']) | |
| ") |
| uv run --group docs pdoc workos -o docs/_site --docformat google | ||
| if [ ! -f docs/_site/index.html ] && [ -f docs/_site/workos.html ]; then | ||
| cp docs/_site/workos.html docs/_site/index.html | ||
| fi | ||
| uv run --group docs pydoc-markdown -p workos --render-toc > docs/_site/workos.md |
There was a problem hiding this comment.
The
uv run calls omit --locked, so uv may resolve and install package versions that differ from what is pinned in uv.lock. Adding --locked ensures the docs build is reproducible and consistent between local runs and CI.
| uv run --group docs pdoc workos -o docs/_site --docformat google | |
| if [ ! -f docs/_site/index.html ] && [ -f docs/_site/workos.html ]; then | |
| cp docs/_site/workos.html docs/_site/index.html | |
| fi | |
| uv run --group docs pydoc-markdown -p workos --render-toc > docs/_site/workos.md | |
| uv run --locked --group docs pdoc workos -o docs/_site --docformat google | |
| if [ ! -f docs/_site/index.html ] && [ -f docs/_site/workos.html ]; then | |
| cp docs/_site/workos.html docs/_site/index.html | |
| fi | |
| uv run --locked --group docs pydoc-markdown -p workos --render-toc > docs/_site/workos.md |
Summary
Publish API DocsGitHub Actions workflow that runs on tag pushes (and manual dispatch), generates the site with pdoc, and deploys it to GitHub Pages so SDK docs stay in lockstep with releases.actions/upload-artifact(manualtarstep +github-pagesartifact name) instead ofactions/upload-pages-artifact, which Socket flagged for an input-argument taint flow — matches the workos-dotnet (Make events parameter required for list_events #251) and workos-kotlin fixes.scripts/docs.sh(build) andscripts/docs-serve.sh(local preview, with--livefor pdoc's hot-reload server) plus adocsdependency group withpdocandpydoc-markdown.llms.txtalongside the HTML so LLM coding assistants can discover the canonical reference without crawling HTML; version is read frompyproject.tomlat build time.docs/_site/build output.Test plan
uv sync --locked --devinstalls the newdocsgroup cleanly./scripts/docs.shproducesdocs/_site/{index.html,index.md,llms.txt,workos.html,workos.md}./scripts/docs-serve.shserves the built site at http://localhost:4000./scripts/docs-serve.sh --livestarts pdoc's live-reload serverllms.txtreflects the current version frompyproject.tomlworkflow_dispatchonce merged and confirm the Pages deploy succeeds