Skip to content

Make each Python SDK its own independent sphinx docset#18981

Open
jkodroff wants to merge 6 commits into
masterfrom
jkodroff/fix-python-cross-package-nav
Open

Make each Python SDK its own independent sphinx docset#18981
jkodroff wants to merge 6 commits into
masterfrom
jkodroff/fix-python-cross-package-nav

Conversation

@jkodroff
Copy link
Copy Markdown
Member

Summary

Fixes the regression where PR #18980's preview site showed only pulumi package content without sibling-package sidebar links. The per-package builds were correctly producing isolated output, but the layout assumed a shared docset spanning all packages.

This PR switches to Option 2 from our discussion: each Python SDK is now its own independent sphinx docset.

What changed

  • Per-package sphinx source dirs. Each package gets its own conf.py + index.rst:
    • tools/pydocgen/source/pulumi/
    • tools/pydocgen/source/pulumi_policy/
    • tools/pydocgen/source/pulumi_esc_sdk/
  • Version is now displayed in the rendered docs. Each conf.py reads its package's installed version via importlib.metadata.version() and sets version / release so the RTD theme renders it in the sidebar.
  • Simpler script. scripts/generate_python_docs.sh picks ./source/${PACKAGE}/ and builds directly to static-prebuilt/docs/reference/pkg/python/${PACKAGE}/. No temp dirs, no fabricated one-package toctree.
  • Hugo hub page. New content/docs/reference/pkg/python/_index.md renders the parent /docs/reference/pkg/python/ page as a hand-curated list of the three SDKs. Replaces the role of the sphinx-generated unified index. Hugo runs after the static-prebuilt copy in build-site.sh, so this Hugo page wins the path collision on next deploy.

Trade-offs

  • ✅ Truly independent regens. A broken pulumi_policy release on PyPI no longer blocks pulumi docs.
  • ✅ Brings Python parity with TypeScript, which already works as independent docsets.
  • ✅ Each rendered page now shows the SDK version.
  • ⚠️ No automatic cross-references between packages. pulumi_policy referencing pulumi.Resource will render as a code span rather than a link. In practice these refs are rare and the trade-off is worth the decoupling. If we miss them later, intersphinx is a clean follow-up.

Orphaned files

The shared top-level sphinx artifacts (static-prebuilt/docs/reference/pkg/python/{_static,genindex,search,...}/, objects.inv, searchindex.js, the old index.html) become orphans after this PR. They're still referenced by the existing pulumi/index.html, pulumi_policy/index.html, pulumi_esc_sdk/index.html on master (which link to ../_static/, ../genindex/, etc.).

As each per-package workflow runs post-merge, the new self-contained per-package output will replace those files. After all three packages have been regenerated, the top-level sphinx assets can be deleted in a follow-up. They're harmless dead weight in the meantime.

Test plan

Pre-merge (already done)

  • bash -n scripts/generate_python_docs.sh — shell syntax OK.
  • All three conf.py files parse cleanly as Python (project, version, release fields populate).
  • make lint clean.

Post-merge

  1. Visit the new Hugo hub. Browse to https://www.pulumi.com/docs/reference/pkg/python/ (or the preview site) and confirm the page lists the three SDKs as a Hugo-rendered hub, not the old sphinx index.

  2. Regenerate each Python SDK with the new layout. Each workflow now produces a self-contained docset; the resulting PR's diff should rewrite many files in static-prebuilt/docs/reference/pkg/python/<pkg>/.

    ```bash
    gh workflow run pulumi-sdk-python-docs.yml --repo pulumi/docs --ref master -f version=3.238.0
    gh workflow run pulumi-policy-sdk-python-docs.yml --repo pulumi/docs --ref master -f version=1.20.0
    gh workflow run pulumi-esc-sdk-python-docs.yml --repo pulumi/docs --ref master -f version=0.13.1
    ```

    For each PR, strip automation/merge label and disable auto-merge before reviewing (consistent with our usual test posture):

    ```bash
    gh pr edit --remove-label automation/merge --repo pulumi/docs
    gh pr merge --disable-auto --repo pulumi/docs
    ```

  3. Verify each preview site. For each generated PR's preview:

    • /docs/reference/pkg/python/<pkg>/ renders the package's docs.
    • The rendered sidebar/header includes the package version (e.g. "3.238.0" for pulumi).
    • The page does not try to link to siblings (those navs are intentionally gone).
  4. Verify the hub page. After all three packages regenerate, the /docs/reference/pkg/python/ URL should still serve the Hugo hub (Hugo runs second; takes precedence).

Rollback

If something is broken, git revert this commit. The old per-package builds (with shared parent index) will resume producing output that links to the still-present shared assets.

🤖 Generated with Claude Code

Replaces the implicit "one shared sphinx docset spanning all packages"
model with three independent per-package docsets. Each per-package
workflow now produces output that depends only on its own package; a
regen of one package no longer affects the rendered HTML of the others.

Layout change:

- tools/pydocgen/source/pulumi/         — own conf.py + index.rst
- tools/pydocgen/source/pulumi_policy/  — own conf.py + index.rst
- tools/pydocgen/source/pulumi_esc_sdk/ — own conf.py + index.rst

Each conf.py displays the installed package version (via
importlib.metadata.version) in the rendered docs' sidebar, so reference
pages now indicate which release they correspond to. Falls back to
"unknown" if the package isn't installed (e.g. local dev without pipenv).

generate_python_docs.sh is simpler: pick the right source/<PACKAGE>/ dir
and build directly to static-prebuilt/.../python/<PACKAGE>/. No temp
dirs, no fabricated single-package toctree. Install only the target
package (and pulumi where Policy needs it for autodoc).

Adds a Hugo content stub at content/docs/reference/pkg/python/ that
replaces the sphinx-generated unified parent index.html. Hugo runs after
the static-prebuilt copy step in build-site.sh, so the new _index.md
will override the orphaned sphinx index.html on the next deploy.

This is a corollary of issue #18934 (Part 4 follow-up). Fixes a
regression where PR #18980's preview site showed only the pulumi package
without sibling-package sidebar links — the per-package builds were
correctly producing isolated output, but the layout assumed a shared
docset.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 14, 2026

Docs review

Scoped review of content/docs/reference/pkg/python/_index.md plus a content-pass over the build script and the per-package conf.py files. The build-script changes are out of scope for a docs review beyond verifying that BUILD-AND-DEPLOY.md still matches reality — it does (lines 936–960 already describe the per-package model and the static-prebuilt/docs/reference/pkg/python/<PACKAGE>/ output), so no update needed there.

content/docs/reference/pkg/python/_index.md

Bullet style (lines 8–10): The file uses * for the unordered list, but - is the convention everywhere else in content/docs/ and in STYLE-GUIDE.md's own examples. Worth normalizing for consistency:

- [**Pulumi SDK** (`pulumi`)](/docs/reference/pkg/python/pulumi/) — the core Pulumi SDK for Python.
- [**Pulumi Policy SDK** (`pulumi_policy`)](/docs/reference/pkg/python/pulumi_policy/) — for authoring CrossGuard policy packs in Python.
- [**Pulumi ESC SDK** (`pulumi_esc_sdk`)](/docs/reference/pkg/python/pulumi_esc_sdk/) — for programmatically interacting with Pulumi ESC (Environments, Secrets, and Configuration).

Title SEO (line 2): `API Reference (Python)` drops the "Pulumi" qualifier the old Sphinx index had. For an /docs/reference/pkg/python/ landing page, the search-term-rich form helps. Consider:

title: Pulumi Python SDK API Reference

(That also keeps the title ≤60 chars and reads more naturally than the parenthesized form.)

Em-dash density (lines 8–10, 12): Four em-dashes across a 12-line file — three of them in identical "item — description" bullet shape. The pattern reads as a stylistic tic. Swapping the bullet em-dashes for a colon would help and matches how similar hub pages elsewhere in the docs phrase short descriptors:

- [**Pulumi SDK** (`pulumi`)](/docs/reference/pkg/python/pulumi/): the core Pulumi SDK for Python.
- [**Pulumi Policy SDK** (`pulumi_policy`)](/docs/reference/pkg/python/pulumi_policy/): for authoring CrossGuard policy packs in Python.
- [**Pulumi ESC SDK** (`pulumi_esc_sdk`)](/docs/reference/pkg/python/pulumi_esc_sdk/): for programmatically interacting with Pulumi ESC (Environments, Secrets, and Configuration).

The em-dash on line 12 is fine to keep — only one, used parenthetically.

Terraform-bridge link (line 12): Verified — /registry/packages/terraform/api-docs/ matches the destinations in scripts/redirects/pulumi-terraform-python-redirects.txt, so the redirect chain is consistent.

Aliases: No aliases: field, which is correct here — /docs/reference/pkg/python/ is the same URL the old Sphinx-generated index.html served, and the PR description correctly notes Hugo runs after the static-prebuilt copy, so the new page takes precedence on the same path. No redirect needed.

tools/pydocgen/source/<pkg>/conf.py (all three)

Copyright year missing (line 13 in each file): `copyright = 'Pulumi'` — Sphinx's convention (and what RTD theme renders in the footer) is '<year>, <holder>'. The deleted top-level conf.py had the same omission, so this is not a regression, but worth fixing while the files are being rewritten:

copyright = '2026, Pulumi'

Duplication across the three files: The three conf.py files are byte-identical except for the project string and the argument to _pkg_version(). Not a blocker — explicit-per-package matches the PR's "truly independent docsets" goal and keeps each build self-contained — but if these drift in the future, a shared helper module would prevent it. Fine to leave as-is for now.

Things that look good

  • PR description is unusually thorough — rationale, trade-offs, orphaned-files note, and rollback plan all called out.
  • Adding the package version to the rendered sidebar is a real user-facing improvement.
  • The Hugo hub page correctly replaces what was previously a Sphinx-generated index that would no longer exist post-merge — without it, /docs/reference/pkg/python/ would 404 after the per-package workflows run.
  • BUILD-AND-DEPLOY.md already accurately describes the per-package model; no doc drift introduced.

Mention @claude if you'd like another pass after edits.

Three new cards under Reference for the ESC SDK across the three
languages it ships: TypeScript (Node.js), Python, and Go. Mirrors the
"Language SDKs" and "Policy SDKs" sections immediately above.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pulumi-bot
Copy link
Copy Markdown
Collaborator

pulumi-bot commented May 14, 2026

The dotnet and python per-language reference pages have _index.md
landing pages listing their available SDKs, but nodejs did not, so
/docs/reference/pkg/nodejs/ surfaced no ESC SDK link. Mirror the
python/_index.md structure with the three Node.js SDKs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hugo's dev server doesn't serve content from static-prebuilt/, so SDK
reference pages 404 in dev mode. This trips up anyone trying to preview
their changes to /docs/reference/pkg/... locally without realizing they
need the build + serve-static combo.

Adds explicit notes to:
  * README.md — expands the make serve / make build / make serve-static
    entries in the Makefile helpers list to call out the gap.
  * BUILD-AND-DEPLOY.md — adds a callout in the Local Development section.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Reference > SDKs section of the left nav is defined in
config/_default/menus.yml as a hand-curated list, separate from the
content frontmatter menus. It previously had 5 Language SDK entries +
2 Policy SDK entries but no ESC SDK entries — so the ESC SDKs were
missing from the navigation even though they appeared in the Reference
home page's card layout.

Adds three new entries under `reference-sdks`:
  * TypeScript ESC SDK
  * Python ESC SDK
  * Go ESC SDK

Also fixes the Go ESC SDK URL on the Reference home page card to match:
`https://pkg.go.dev/github.com/pulumi/esc-sdk/sdk/go` is the actual
package documentation; the shorter `/sdk` URL pkg.go.dev only renders
the module root with "this package is not in the latest version".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pulumi-bot
Copy link
Copy Markdown
Collaborator

pulumi-bot commented May 14, 2026

Lighthouse Performance Report

Commit: d031e9f | Metric definitions

Page Device Score FCP LCP TBT CLS SI
Homepage Mobile 🟡 62 2.8s 3.2s 818ms 0.019 6.7s
Homepage Desktop 🟡 86 0.8s 1.7s 28ms 0.020 2.9s
Install Pulumi Mobile 🔴 39 5.2s 7.9s 232ms 0.438 5.2s
Install Pulumi Desktop 🟡 83 1.3s 1.7s 20ms 0.023 3.0s
AWS Get Started Mobile 🟡 55 5.1s 7.4s 283ms 0.083 5.1s
AWS Get Started Desktop 🟡 80 1.3s 2.0s 20ms 0.024 3.1s

The verbose "TypeScript (Node.js)" label was inherited from the Reference
home page card; the left-nav already shows three TypeScript-related SDK
entries (Pulumi, Policy, ESC), so just "TypeScript" reads cleaner here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants