-
Notifications
You must be signed in to change notification settings - Fork 65
perf(docs): pre-render API reference HTML in Python #1391
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1b03c8b
perf(docs): pre-render API reference HTML in Python instead of Hugo s…
hkad98 f86cb78
test(docs): add tests for python_ref_builder, fix types
hkad98 6784c8a
fix(docs): guard links.json in generate.sh, narrow cache key
hkad98 68c4377
fix: include test dependency group in docs-scripts CI job
hkad98 dd6fc46
fix: add toml to test dependency group for docs-scripts CI
hkad98 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
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
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
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
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
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 |
|---|---|---|
|
|
@@ -3,4 +3,4 @@ linkTitle: "LINK" | |
| no_list: true | ||
| --- | ||
|
|
||
| {{< api-ref-class "PATH" >}} | ||
| CONTENT | ||
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 |
|---|---|---|
|
|
@@ -4,6 +4,3 @@ linkTitle: "API Reference" | |
| weight: 99 | ||
| navigationLabel: true | ||
| --- | ||
|
|
||
|
|
||
| Placeholder for gerenerated API reference. | ||
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
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 |
|---|---|---|
|
|
@@ -5,4 +5,4 @@ superheading: "PARENT." | |
| weight: 100 | ||
| --- | ||
|
|
||
| {{< api-ref "PATH" >}} | ||
| CONTENT | ||
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 |
|---|---|---|
|
|
@@ -4,4 +4,4 @@ linkTitle: "LINK" | |
| no_list: true | ||
| --- | ||
|
|
||
| {{< api-ref-module "PATH" >}} | ||
| CONTENT | ||
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
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,87 @@ | ||
| # Documentation Generation | ||
|
|
||
| This directory contains Python scripts that generate the API reference pages for | ||
| the GoodData Python SDK documentation site. | ||
|
|
||
| ## How it works | ||
|
|
||
| The docs site is built with Hugo. API reference pages are generated in two steps: | ||
|
|
||
| 1. **`json_builder.py`** — introspects the installed `gooddata_sdk` and | ||
| `gooddata_pandas` packages using `inspect`, producing a `data.json` file with | ||
| class/function/property metadata and parsed docstrings. | ||
| 2. **`python_ref_builder.py`** — reads `data.json` and `api_spec.toml`, then | ||
| generates markdown files with pre-rendered HTML for each module, class, and | ||
| function. Jinja2 templates in `templates/` replicate the output of the former | ||
| Hugo shortcodes, but at build time instead of at Hugo render time. | ||
|
|
||
| The generated markdown files contain Hugo front matter (title, linkTitle, weight) | ||
| and a `CONTENT` block with the full HTML. Hugo serves them as-is without needing | ||
| shortcodes, `data.json`, or `links.json`. | ||
|
|
||
| ## Workflows | ||
|
|
||
| There are three documentation deployment workflows, in order of | ||
| preference: | ||
|
|
||
| ### 1. V2 parallel workflow (`netlify-deploy-v2.yaml`) — recommended | ||
|
|
||
| Triggered manually via `workflow_dispatch`. | ||
|
|
||
| ``` | ||
| discover-versions ──> generate-version (matrix, parallel) ──> build-and-deploy | ||
| ``` | ||
|
|
||
| - `discover-versions.sh` finds the latest N release branches. | ||
| - Each version runs in its own runner: checks out the version's SDK packages, | ||
| installs master's `script-requirements.txt`, runs `json_builder.py` + | ||
| `python_ref_builder.py` via `generate-single-version.sh`. | ||
| - Per-version results are cached by `(scripts hash + templates hash + branch SHA)`. | ||
| - `assemble-versions.sh` merges all version artifacts, promotes the highest | ||
| numbered version to `/latest`, then Hugo builds the final site. | ||
| - Deploys as a Netlify **draft** (no `--prod`). | ||
|
|
||
| ### 2. Legacy single-job workflow (`netlify-deploy.yaml`) — production | ||
|
|
||
| Triggered manually via `workflow_dispatch`. | ||
|
|
||
| - Uses `hugo-build-versioned-action` which downloads `generate.sh` from master. | ||
| - `generate.sh` runs all versions sequentially in one job. | ||
| - Deploys to Netlify with `--prod`. | ||
|
|
||
| ### 3. PR preview (`netlify-deploy-preview.yaml`) | ||
|
|
||
| Triggered automatically on PRs that change `docs/**`. | ||
|
|
||
| - Only builds the current branch's docs content (no multi-version). | ||
| - Uses the simpler `hugo-build-action` (no API reference generation). | ||
| - Deploys to a Netlify preview URL (`preview-{PR}--{site}.netlify.app`). | ||
|
|
||
| ## Local development | ||
|
|
||
| Build and serve docs locally using Docker: | ||
|
|
||
| ```bash | ||
| cd docs | ||
| docker build -t python-sdk-docs -f Dockerfile .. | ||
| docker run --rm -p 1313:1313 python-sdk-docs | ||
| # Open http://localhost:1313/latest/ | ||
| ``` | ||
|
|
||
| ## Key files | ||
|
|
||
| | File | Purpose | | ||
| |------|---------| | ||
| | `json_builder.py` | Introspects SDK packages into `data.json` | | ||
| | `python_ref_builder.py` | Generates markdown + HTML from `data.json` | | ||
| | `templates/*.html.j2` | Jinja2 templates (replicate old Hugo shortcodes) | | ||
| | `tests/test_python_ref_builder.py` | Unit tests (`make test-docs-scripts`) | | ||
| | `../script-requirements.txt` | Python dependencies for both scripts | | ||
| | `../../docs/api_spec.toml` | Maps package names to output directories | | ||
| | `../../docs/*_template.md` | Markdown front matter templates (module/class/function) | | ||
|
|
||
| ## Running tests | ||
|
|
||
| ```bash | ||
| make test-docs-scripts | ||
| ``` |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.