Skip to content

wip: add catalog docs codemod#2654

Draft
sunker wants to merge 12 commits into
mainfrom
eriksundell/catalog-docs-codemod-with-ai
Draft

wip: add catalog docs codemod#2654
sunker wants to merge 12 commits into
mainfrom
eriksundell/catalog-docs-codemod-with-ai

Conversation

@sunker
Copy link
Copy Markdown
Contributor

@sunker sunker commented May 25, 2026

This is a very rough draft, no need to study the code just yet. The PR will be split into multiple smaller ones before it's ready for review and merge.


What this PR does / why we need it:

Adds two create-plugin add codemods - panel-docs and datasource-docs - that wires a plugin for multi-page documentation support.

Beyond the wiring (adding devDep, npm scripts, tplugin.json setup and adds/changes workflows), each codemod also drops a set of plugin-type-specific stub Markdown files into <docsPath>/. Every stub uses a section-brief protocol (<!-- section-brief:start --> ... <!-- section-brief:end -->) so a human or an agent has clear scope guidance for each H2.

Optionally, opted into via --agent-loop=claude|codex|cursor, the codemods also scaffold an AI authoring layer under <docsPath>/AGENTS.md and the loop's skills folder:

  • <docsPath>/AGENTS.md — the canonical authoring guide. Defines the frontmatter schema, filesystem conventions, agent-hint protocol, common page-pattern catalog, and a 13-rule style guide lifted (and adapted) from the Grafana Writers' Toolkit — voice, tense, person, headings, link text, em dashes etc. AGENTS.md is the file both humans and agents read first.
  • write-plugin-docs (shared) — per-page authoring. Fills a stub or updates an existing page, reads the source files implied by the page title and section briefs, strips the briefs after.
  • review-plugin-docs (shared) — plugin-specific review against the style guide, frontmatter schema, leftover section briefs and factual alignment with source.
  • validate-plugin-docs (shared) — runs npm run docs:validate --json, groups diagnostics, applies category-based fixes, loops up to 3 times.
  • bootstrap-plugin-docs (per codemod, panel-specific or datasource-specific) — one-shot orchestrator. Inventories src/, provisioning/dashboards/*.json, existing screenshots, README/CHANGELOG. Walks the PanelPlugin / DataSource builder chains to extract option tables, standard field options, capability flags. Routes README content to stub pages, prompts the author for non-source-backed topics, then hands each page to write-plugin-docs. Both bootstraps work on greenfield and brownfield plugins.

Testing the canary build:

For a panel:

npx -y https://pkg.pr.new/@grafana/create-plugin@4438c6a add panel-docs --agentLoop claude|cursor|codex|none ​

For a datasource:

npx -y https://pkg.pr.new/@grafana/create-plugin@4438c6a add datasource-docs --agentLoop claude|cursor|codex|none ​
Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 25, 2026

Hello! 👋 This repository uses Auto for releasing packages using PR labels.

✨ This PR can be merged but will not trigger a new release. To trigger a new release add the release label before merging.
NOTE: When merging a PR with the release label please avoid merging another PR. For further information see here.

@tolzhabayev tolzhabayev moved this from 📬 Triage to 🧑‍💻 In development in Grafana Catalog Team May 26, 2026
@sunker sunker added minor Increment the minor version when merged release Create a release when this pr is merged labels May 28, 2026
@sunker sunker self-assigned this May 28, 2026
sunker added 12 commits May 29, 2026 11:15
Adds the full `create-plugin add catalog-docs` command:
- reads src/plugin.json to detect plugin type and set docsPath
- adds @grafana/plugin-docs-cli devDependency and docs:serve/docs:validate scripts
- copies type-specific markdown stubs into the docs folder with pluginName interpolation
- copies validate-docs.yml CI workflow (always overwrites)
- bumps build-plugin action ref in release.yml
- idempotent: each step skips gracefully if already applied
- Move schema inline to index.ts, remove separate schema.ts
- Remove h1 headings from all doc templates (frontmatter title is authoritative)
- Fix workflow action versions to v4 (checkout, setup-node)
- Update rollup.config.ts to glob nested codemod entry points and copy all templates dirs generically
- Use runtime readFileSync approach for template loading (revert esbuild text loader approach)
- Restore realExistsSync mock pattern in tests so template dir checks hit the real filesystem
@sunker sunker force-pushed the eriksundell/catalog-docs-codemod-with-ai branch from dce09de to 4438c6a Compare May 29, 2026 09:15
@sunker sunker added preview Opts the PR into pkg.pr.new preview publishing and removed release Create a release when this pr is merged labels May 29, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 29, 2026

Open in StackBlitz

@grafana/create-plugin

npm i https://pkg.pr.new/@grafana/create-plugin@4438c6a -D

@grafana/eslint-plugin-plugins

npm i https://pkg.pr.new/@grafana/eslint-plugin-plugins@4438c6a -D

@grafana/plugin-docs-cli

npm i https://pkg.pr.new/@grafana/plugin-docs-cli@4438c6a -D

@grafana/plugin-docs-parser

npm i https://pkg.pr.new/@grafana/plugin-docs-parser@4438c6a -D

@grafana/plugin-e2e

npm i https://pkg.pr.new/@grafana/plugin-e2e@4438c6a -D

@grafana/plugin-meta-extractor

npm i https://pkg.pr.new/@grafana/plugin-meta-extractor@4438c6a -D

@grafana/plugin-types-bundler

npm i https://pkg.pr.new/@grafana/plugin-types-bundler@4438c6a -D

@grafana/react-detect

npm i https://pkg.pr.new/@grafana/react-detect@4438c6a -D

@grafana/sign-plugin

npm i https://pkg.pr.new/@grafana/sign-plugin@4438c6a -D

@grafana/tsconfig

npm i https://pkg.pr.new/@grafana/tsconfig@4438c6a -D

commit: 4438c6a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged preview Opts the PR into pkg.pr.new preview publishing

Projects

Status: 🧑‍💻 In development

Development

Successfully merging this pull request may close these issues.

2 participants