Repository navigation
Conversation
|
Not feedback directly on your changes, but playing around with this rendered content makes it plainly obvious that we are severely lacking in attribute and top-level resource descriptions. Looks good though. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds Terraform documentation to API operation pages. Each operation shows the Terraform resources and data sources that call it, with their attributes, an HCL example and the import command.
The data comes from the released Cloudflare Terraform provider instead of Stainless' internal SDK JSON. Every input is public and pinned to a version. The generator is offline and read-only, and a scheduled workflow keeps the data in sync.
How it works
packages/docs-site/scripts/generate-terraform-docs.tsreads local checkouts ofcloudflare/terraform-provider-cloudflare(at a release tag) and of thecloudflare-gomodules itsgo.modrequires. From those checkouts it takes:docs/{resources,data-sources}/*.md: tfplugindocs output, the same content the Terraform Registry showsexamples/internal/services/*client calls, resolved through cloudflare-goapi.mdinternal/version.goand.git/HEADin each checkoutThe output,
src/generated/terraform-docs.json(format 2), stores each declaration once and lists the linked declarations and roles for each SDK endpoint. It also records the provider and SDK versions and commit SHAs. At build time,src/terraform-extension.tsmatches those endpoints to OpenAPI operations by method + path, with path parameter names ignored. Account, zone and combined account-or-zone paths match each other, so it doesn't depend onoperationId. The build warns, instead of failing, about declarations that match no operation.Security
The generator reads third-party repositories, so it treats their contents as untrusted data:
child_process,http,fetch(, dynamicimport(), etc.scripts/source-tree.ts): it refuses symbolic links,..and absolute paths, paths that end up outside the checkout, and oversized files.file:line. An SDK call that can't be resolved also fails the run.go.mod. The output is validated against the same zod schema the site uses to read it.Sync workflow
.github/workflows/sync-terraform-docs.ymlruns daily at 06:17 UTC and can be started by hand:generatehas read-only permissions, no secrets and no saved git credentials.pull-requestnever sees third-party sources.bot/sync-terraform-docsand opens or updates a PR withgh.gh pr merge --match-head-commit.Third-party actions are pinned to commit SHAs, and workflow inputs reach shell scripts only through
envand are validated. The job does nothing until a new provider version is published.UI
sensitive/deprecatedmarkers.terraform importcommand.Coverage (provider v5.27.0, cloudflare-go v6.10.0 / v7.12.0)
create.cloudflare_snippets(its resource makes no API calls). Not documented by the provider:cloudflare_rate_limits(list data source).Validation
api.mdand service parsing, the tfplugindocs parser (includingfile:lineerrors), version checks, source-tree confinement (symlink and path-escape attempts), and the offline guard.pnpm --filter docs-site check(0 errors),oxlintandactionlint.--checkreproduces the committed file byte for byte from v5.27.0 sources.DOCS_SYNC_TOKENsecret (a GitHub App or fine-grained token): PRs opened withGITHUB_TOKENdon't trigger CI, so they would never be merged automatically.Screenshots
From the first iteration. The layout is unchanged, but the labels were updated afterwards: "Computed" is now "Read-only", and the "forces replacement" badge is gone.