-
Notifications
You must be signed in to change notification settings - Fork 1
Demonstrate generated SDK API reference on GitHub Pages #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hey-august
wants to merge
14
commits into
main
Choose a base branch
from
august-20260622-add-docs-gen
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,577
−0
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8afd712
chore: ignore generated reference build output
hey-august 0b76c51
feat(reference): inject Fern navbar and theme
hey-august 92a9e55
ci(reference): build and publish docs with `mike` versioning
hey-august d47f96b
docs(reference): document build, versioning, and gh pages setup in RE…
hey-august 302c5d6
feat(reference): generate SDK API reference via MkDocs + mkdocstrings
hey-august e16797f
fix(reference): generate landing page + pin doc toolchain
hey-august 4f543db
build(reference): invoke Python via python3 -m for portability
hey-august 9aee9f4
Merge branch 'august-20260622-add-docs-gen'
hey-august f2084cd
style fixes
hey-august d09dee4
style fixes
hey-august 068fea6
fix (reference): use compiled fern.css for navbar, fix double hover e…
hey-august 0966fae
fix(reference): align navbar css with production Fern
hey-august a69e4e4
fix(reference): flat product-menu markup, remove language switcher
hey-august b8270fe
chore(reference): add dev-server.sh for local live-reload preview
hey-august File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # API reference docs (pilot). | ||
| # | ||
| # Builds the SignalWire Python SDK API reference (MkDocs Material + mkdocstrings) | ||
| # and publishes it to this repo's OWN GitHub Pages via mike (versioned): | ||
| # https://signalwire.github.io/signalwire-python/ | ||
| # | ||
| # PILOT triggers: workflow_dispatch + push to the pilot branch. This is NOT | ||
| # gated on releases yet. | ||
| # PRODUCTION (later): switch the trigger to `v*` tags so each release version | ||
| # is deployed and `latest` is re-aliased. See the commented block below. | ||
| # | ||
| # MANUAL REPO SETTING REQUIRED to go live (one-time, in the GitHub UI): | ||
| # Settings -> Pages -> Build and deployment -> Source = "Deploy from a branch" | ||
| # -> Branch = `gh-pages` / `(root)`. mike pushes the built site there. | ||
| name: reference-docs | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - docs/api-reference-pilot | ||
|
|
||
| # --- PRODUCTION trigger (enable when promoting out of the pilot) ------------ | ||
| # push: | ||
| # tags: | ||
| # - "v*" | ||
|
|
||
| permissions: | ||
| contents: write # mike pushes the built site to the gh-pages branch | ||
|
|
||
| jobs: | ||
| build-deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 # mike needs full history + the gh-pages branch | ||
|
|
||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install SDK (editable) + doc toolchain | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| pip install -r reference/requirements.txt | ||
| pip install -e . | ||
|
|
||
| - name: Configure git for mike | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Generate API pages | ||
| run: bash reference/gen.sh --no-build | ||
|
|
||
| - name: Resolve version | ||
| id: ver | ||
| run: | | ||
| # Pilot: use the package version. Production: derive from the v* tag, | ||
| # e.g. VERSION="${GITHUB_REF_NAME#v}". | ||
| VERSION=$(python -c "import tomllib;print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") | ||
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Deploy with mike (versioned) to gh-pages | ||
| run: | | ||
| mike deploy --config-file reference/mkdocs.yml --push --update-aliases \ | ||
| "${{ steps.ver.outputs.version }}" latest | ||
| mike set-default --config-file reference/mkdocs.yml --push latest | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,3 +247,5 @@ Anaconda3-2024.02-1-Linux-x86_64.sh | |
| chunks.json | ||
| my_chunks | ||
| *.swsearch | ||
| reference/_docs/ | ||
| reference/_site/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| # API reference (pilot) | ||
|
|
||
| Language-native API reference for the SignalWire Python SDK, generated from | ||
| docstrings with **MkDocs Material + mkdocstrings**, wrapped in the SignalWire | ||
| **Fern navbar**, and versioned with **mike**. Published to this repo's own | ||
| GitHub Pages: | ||
|
|
||
| > https://signalwire.github.io/signalwire-python/ | ||
|
|
||
| This is self-contained under `reference/` and does **not** touch the repo's | ||
| existing top-level `docs/` directory (owned by `doc-audit.yml`). | ||
|
|
||
| ## Layout | ||
|
|
||
| ``` | ||
| reference/ | ||
| mkdocs.yml MkDocs Material + mkdocstrings config (docs_dir = _docs) | ||
| gen.sh installs the SDK editable, generates the API pages, builds | ||
| overrides/main.html extends Material's base.html; injects the Fern navbar | ||
| assets/ Fern tokens/CSS/JS + logo/favicon (committed; no shared host yet) | ||
| _docs/ GENERATED docs tree (one page per signalwire.<subpackage>) [gitignored] | ||
| _site/ local `mkdocs build` output [gitignored] | ||
| README.md this file | ||
| ``` | ||
|
|
||
| The `signalwire` package is nested (`signalwire/signalwire/`). mkdocstrings | ||
| resolves imports from the **editable install**, so `gen.sh` runs `pip install -e .` | ||
| first — keep that. | ||
|
|
||
| ## Build & serve locally | ||
|
|
||
| From the repo root, in a virtualenv: | ||
|
|
||
| ```bash | ||
| pip install -e . | ||
| pip install mkdocs-material "mkdocstrings[python]" mike | ||
|
|
||
| # Generate API pages + build the static site into reference/_site | ||
| bash reference/gen.sh | ||
|
|
||
| # Live preview (regenerates pages first, then serves with autoreload) | ||
| bash reference/gen.sh --no-build | ||
| mkdocs serve --config-file reference/mkdocs.yml | ||
| ``` | ||
|
|
||
| `use_directory_urls: false`, so every page is a real `.html` file and the site | ||
| works under the `/signalwire-python/` base path. | ||
|
|
||
| ## Versioning (mike) | ||
|
|
||
| `extra.version.provider: mike` in `mkdocs.yml` turns on Material's version | ||
| selector; it reads `versions.json` from the site root at runtime. mike commits | ||
| each deployed version to a local `gh-pages` branch. | ||
|
|
||
| ```bash | ||
| bash reference/gen.sh --no-build # generate pages first | ||
|
|
||
| # Deploy a version and (re)point the `latest` alias at it; set it as default. | ||
| mike deploy --config-file reference/mkdocs.yml --update-aliases 3.0.2 latest | ||
| mike set-default --config-file reference/mkdocs.yml latest | ||
| mike list --config-file reference/mkdocs.yml # -> 3.0.2 [latest], 3.0.1 | ||
|
|
||
| mike serve --config-file reference/mkdocs.yml # preview all versions + selector | ||
| ``` | ||
|
|
||
| Add `--push` to push the `gh-pages` branch to the remote (CI does this; do not | ||
| locally). | ||
|
|
||
| ## CI | ||
|
|
||
| `.github/workflows/reference-docs.yml` (plain `actions/setup-python`, no Docker): | ||
|
|
||
| - **Pilot triggers:** `workflow_dispatch` + push to `docs/api-reference-pilot`. | ||
| - Installs the SDK editable + `mkdocs-material`, `mkdocstrings[python]`, `mike`, | ||
| runs `gen.sh --no-build`, then `mike deploy --push --update-aliases <version> latest`. | ||
| - **Production trigger (later):** `v*` tags (commented in the workflow), so each | ||
| release deploys its version and re-aliases `latest`. | ||
|
|
||
| ## Manual repo setting required to go live | ||
|
|
||
| One-time, in the GitHub UI: | ||
|
|
||
| > **Settings → Pages → Build and deployment → Source = "Deploy from a branch" → | ||
| > Branch = `gh-pages` / `(root)`.** | ||
|
|
||
| mike pushes the built site to `gh-pages`; Pages then serves it at | ||
| `https://signalwire.github.io/signalwire-python/`. | ||
|
|
||
| ## Pilot simplifications | ||
|
|
||
| - **Language switcher:** cross-site links with Python marked active; other | ||
| languages point at the POC demo (no per-language hosted site exists yet). | ||
| - **Theme toggle:** drives Material's own light/dark color scheme. No | ||
| cross-origin `localStorage` theme sync with signalwire.com/docs (different | ||
| origin — out of scope). | ||
| - Out of scope: llms.txt/markdown emission, Docker, other languages, custom domain. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be changed to
main?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this! Just pushed and switched it from the pilot branch to the
v*tag trigger. That way we get regenerated docs on a version bump instead of on all pushes tomain.The workflow can still be dispatched manually, though.