Skip to content

Add script for TOML config schema doc generation#6979

Open
ryancbahan wants to merge 11 commits intomainfrom
03-11-add-config-to-docgen
Open

Add script for TOML config schema doc generation#6979
ryancbahan wants to merge 11 commits intomainfrom
03-11-add-config-to-docgen

Conversation

@ryancbahan
Copy link
Contributor

@ryancbahan ryancbahan commented Mar 11, 2026

WHY are these changes introduced?

We need to generate TOML configuration reference docs for shopify.dev. This tooling needs authenticated API calls (appFromIdentifiers, fetchSpecifications) which require the full CLI runtime, so it lives in packages/app and runs via a bin script after pnpm build.

WHAT is this pull request doing?

Adds a new pnpm generate-schema-docs workflow that fetches extension specs from the API and generates doc/interface/example files for all app config sections and extension types:

  • packages/app/src/cli/services/docs/schema-to-docs.ts — utilities to convert JSON schemas from extension specs into doc-site-compatible TypeScript files (doc pages, interface definitions, example TOML)
  • packages/app/src/cli/services/docs/generate-schema-docs.tsgenerateSchemaDocs(basePath) service function that authenticates, fetches specs, partitions them into app config vs extensions, and writes all output files
  • bin/docs/generate-schema-docs.js — thin ESM entry point that imports from built dist
  • bin/docs/build-dev-docs.sh — updated to compile and include config docs alongside command docs when present
  • bin/docs/tsconfig.schema-docs.json — TypeScript config for compiling the generated .doc.ts files
  • pnpm generate-schema-docs script in root package.json

Output goes to docs-shopify.dev/configuration/ (doc pages, interfaces, examples) and feeds into the existing build-dev-docs pipeline.

How to test your changes?

  1. pnpm build
  2. Auth with the e2e test app org: pnpm shopify auth login
  3. pnpm generate-schema-docs — produces files in docs-shopify.dev/configuration/
  4. pnpm build-dev-docs — includes config pages in generated output
  5. pnpm knip passes

Measuring impact

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor Author

ryancbahan commented Mar 11, 2026

@ryancbahan ryancbahan mentioned this pull request Mar 11, 2026
3 tasks
@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 82.03% 14721/17945
🟡 Branches 74.44% 7306/9815
🟢 Functions 81.22% 3727/4589
🟢 Lines 82.44% 13922/16888

Test suite run success

3833 tests passing in 1480 suites.

Report generated by 🧪jest coverage report action from 3e1add3

@ryancbahan ryancbahan changed the base branch from rcb/non-interactive-validate to graphite-base/6979 March 18, 2026 15:37
Adds a new hidden `docs:generate-schema` command that authenticates,
fetches all extension specifications, and generates `.doc.ts` files
in the `ReferenceEntityTemplateSchema` format for the existing
`generate-docs` pipeline.

- One consolidated page for app.toml (Global + per-module sections)
- One page per extension type
- JSON Schema contracts used when available, Zod→JSON Schema fallback
  via zod-to-json-schema for specs without contracts
- Flat dot-notation interfaces for generate-docs compatibility
- Build pipeline updated to compile configuration docs if present

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan force-pushed the 03-11-add-config-to-docgen branch from 836414a to 553e7c0 Compare March 18, 2026 17:10
@ryancbahan ryancbahan changed the base branch from graphite-base/6979 to main March 18, 2026 17:10
@ryancbahan ryancbahan force-pushed the 03-11-add-config-to-docgen branch from 553e7c0 to c48918c Compare March 18, 2026 17:13
The generate-docs tool overwrites output on each invocation. Schema docs
and command docs must be compiled separately (different tsconfigs) but
passed to generate-docs together so both end up in generated_docs_data.json.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan force-pushed the 03-11-add-config-to-docgen branch from c48918c to 33fc9f7 Compare March 18, 2026 17:25
@ryancbahan ryancbahan changed the title add docs:generate-schema command for TOML config documentation Move docs:generate-schema from oclif command to standalone bin script Mar 18, 2026
The service function is imported by bin/docs/generate-schema-docs.js
(via dist/), so knip can't trace it from the bin entry. Add it
explicitly to the packages/app knip entries.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan force-pushed the 03-11-add-config-to-docgen branch from 3656b99 to 77b8d03 Compare March 18, 2026 20:07
ryancbahan and others added 4 commits March 18, 2026 14:17
Reset lockfile to main and re-ran pnpm install to get a minimal diff
(only zod-to-json-schema addition).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
These files were accidentally left untracked. The service function
contains the logic extracted from the deleted oclif command, and
the bin script is the new entry point for pnpm generate-schema-docs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When merging allOf subschemas, the spread overwrite lost the required
array from earlier subschemas. Now required arrays are concatenated,
so fields from all subschemas are correctly marked as required in docs.

Also add a comment explaining intentional word splitting in
build-dev-docs.sh.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan changed the title Move docs:generate-schema from oclif command to standalone bin script Add standalone script for TOML config schema doc generation Mar 18, 2026
@ryancbahan ryancbahan changed the title Add standalone script for TOML config schema doc generation Add script for TOML config schema doc generation Mar 18, 2026
ryancbahan and others added 2 commits March 18, 2026 15:15
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use the existing escapeSingleQuotes helper when emitting enum values
in tsTypeForField to prevent syntax errors if a value contains ' or \.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ryancbahan ryancbahan marked this pull request as ready for review March 18, 2026 21:18
@ryancbahan ryancbahan requested review from a team as code owners March 18, 2026 21:18
@github-actions
Copy link
Contributor

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.


const clientId = process.argv[2]
if (!clientId) {
console.error('Usage: node bin/docs/generate-schema-docs.js <client-id>')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need to pass a client id in order to dump extension data until we have a static way to grab schemas without being app-scoped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
}
return {...prop, ...merged, allOf: undefined}
}
// For anyOf/oneOf, pick the first non-null branch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may require returning to -- generated docs on pr above this seem good, but the quality of our docgen will be proportional to how straightforward and correct our json contracts are.

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.

1 participant