Skip to content

Charts docs skill: document <Source> code-block indentation convention#50098

Open
adamwoodnz wants to merge 1 commit into
trunkfrom
cursor/charts-docs-source-indent-convention-e318
Open

Charts docs skill: document <Source> code-block indentation convention#50098
adamwoodnz wants to merge 1 commit into
trunkfrom
cursor/charts-docs-source-indent-convention-e318

Conversation

@adamwoodnz

Copy link
Copy Markdown
Contributor

Fixes CHARTS-226.

Proposed changes

  • Add an "Authoring <Source> example blocks" section to the charts-docs skill (.agents/skills/charts-docs.md) capturing:
    • The Storybook dedent that strips one leading indentation level from <Source code={ } /> template literals.
    • The tabs-only convention already used across the chart docs: leading imports/setup flush at column 0, JSX body at one tab, props at two tabs, closing tag back at one tab.
    • A warning not to run Prettier over .mdx files (the repo's pre-commit hook only formats JS/TS/JSON, so leaving .mdx alone is intentional — Prettier would introduce a tab/space mix and break the dedent).
    • A worked example matching the existing bar-chart/stories/index.docs.mdx pattern, using real tab characters.
    • A quick self-check for authors: props should render on their own indented lines in the rendered Storybook docs, not flat against the component tag.
  • Cross-reference the convention from projects/js-packages/charts/docs/ai-documentation-guide.md so authors who land in the in-package guide see the same pointer.
  • Add a changelog entry (docs-tooling only, no user-facing change).

Related product discussion/links

Does this pull request change what data or activity we track or use?

No. Documentation-tooling change only.

Testing instructions

This PR is docs-tooling only; there is no runtime code to run.

  • Read .agents/skills/charts-docs.md and confirm the new "Authoring <Source> example blocks" section is present and the embedded example uses real tab characters (verify with cat -A .agents/skills/charts-docs.md — indentation on the JSX body lines should show as ^I).
  • Read projects/js-packages/charts/docs/ai-documentation-guide.md and confirm the new bullet under "Code Examples" references the skill section.
  • Confirm the changelog entry exists at projects/js-packages/charts/changelog/charts-docs-source-indent.

Linear Issue: CHARTS-226

Open in Web Open in Cursor 
Storybook's <Source code={ `...` } /> blocks dedent the template literal
before rendering, so authoring the JSX body at column 0 causes props to
render flat against the component tag. This surfaced on CHARTS-218
(HeatmapChart PR #50065) where every heatmap doc example rendered with
flat props until the blocks were re-indented to match the other chart
docs.

Add an 'Authoring <Source> example blocks' section to the charts-docs
skill (.agents/skills/charts-docs.md) capturing the dedent gotcha, the
tabs-only body-indentation convention, an example matching the existing
bar-chart doc pattern, and a quick self-check for future authors. Also
cross-reference the convention from the in-package AI documentation
guide so authors landing there see the same guidance.

Co-authored-by: Adam Wood <adamwoodnz@users.noreply.github.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the cursor/charts-docs-source-indent-convention-e318 branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack cursor/charts-docs-source-indent-convention-e318
bin/jetpack-downloader test jetpack-mu-wpcom-plugin cursor/charts-docs-source-indent-convention-e318

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Jul 1, 2026
@adamwoodnz adamwoodnz self-assigned this Jul 1, 2026
@adamwoodnz adamwoodnz added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Jul 1, 2026
@adamwoodnz adamwoodnz marked this pull request as ready for review July 1, 2026 02:07
@adamwoodnz

Copy link
Copy Markdown
Contributor Author

@claude are the new instructions clear and concise?

@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @adamwoodnz's task in 1m 14s —— View job


Are the new instructions clear and concise? — yes, mostly. A few small notes.

I read the new skill section, the cross-reference in ai-documentation-guide.md, the changelog, and checked the guidance against the real bar-chart docs.

What works well

  • The section is well-structured: mechanism → convention → worked example → self-check. That ordering is easy to follow.
  • The worked example uses real tab characters (verified: charts-docs.md:50-56 show ^I), and it faithfully matches the live pattern in src/charts/bar-chart/stories/index.docs.mdx (imports flush at col 0, <BarChart at one tab, props at two, /> back at one). The convention is accurate against actual code. ✅
  • The Prettier warning with the why (pre-commit only formats JS/TS/JSON) is exactly the kind of context that stops someone "helpfully" reformatting and reintroducing the bug. Good call.
  • Numbered-list renumbering (new step 9, shifted 10/11) is correct and the changelog is appropriately scoped as docs-tooling-only.

Suggestions (all minor — nothing blocking)

  1. The mechanism sentence is in mild tension with the convention. It says the dedent "strips one leading indentation level." But the convention puts imports at column 0 — so the common minimum indentation is already 0, and a naive reader reasoning from "one level gets stripped" might expect the one-tab JSX body to be dedented back to flush (the broken state you're trying to avoid). It'd be clearer to describe what dedent actually keys off — the common/minimum leading indentation across the block — and then frame the convention as: keep imports at col 0 so nothing is stripped, and the one-tab JSX body therefore renders indented. The convention itself is empirically correct; it's just the explanation that could momentarily mislead.

  2. The path reference is partial. Example (matches bar-chart/stories/index.docs.mdx) — the real path is src/charts/bar-chart/stories/index.docs.mdx. A full path saves an author a find.

  3. Some redundancy on the tabs point. "Use tabs only" (bullet), the Prettier warning, and the self-check's "check for a tab/space mix" all restate the same tabs-vs-spaces hazard, and line 318 of the in-package guide restates the whole convention again. This is defensible as deliberate cross-referencing, but if you want it tighter, the in-package bullet could shrink to a one-line pointer ("see the charts-docs skill for the Source-block indentation convention") and let the skill be the single source of truth.

Net: clear and usable as-is. Suggestion #1 is the only one I'd genuinely recommend acting on, since a reader reasoning from the stated mechanism could draw the wrong conclusion. #2 and #3 are polish.

Want me to apply #1 (reword the dedent mechanism) and #2 (full path)? Just say the word and I'll push to this branch.
• branch cursor/charts-docs-source-indent-convention-e318

@jp-launch-control

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

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