docs: add Syntax component for inline language-specific identifiers#2751
docs: add Syntax component for inline language-specific identifiers#2751notowen333 wants to merge 2 commits into
Conversation
Introduces a new auto-imported <Syntax py="..." ts="..." /> component that renders the correct identifier based on the global language toggle. Replaces manual patterns like "`snake_name` / `camelName`" in shared prose with a single reactive element. - New Syntax.astro component (custom element + inline script) - Auto-imported via astro-auto-import plugin - Converted ~26 instances across 16 doc pages - Updated agent skills, references, and contributor docs
|
Assessment: Comment Clean, well-scoped documentation addition. I spot-checked the converted identifiers against the SDK source ( Review themes
Nice quality-of-life improvement for the docs — the live language switching on inline identifiers is a real readability win. |
Address review feedback: - Render both Python and TypeScript content at build time with CSS-driven visibility (no empty flash, crawlable by default) - Remove unused data-code attribute - JS now toggles display:inline/none instead of setting textContent
|
Re-reviewed after
The remaining note (extracting the duplicated Updated assessment: Approve. Nice, quick turnaround. 👍 |
Description
Adds a new
<Syntax>MDX component that renders language-appropriate identifiers (Python snake_case vs TypeScript camelCase) inline based on the global language selector. This eliminates the manual pattern of spelling out both variants in shared prose (e.g.,`snake_name` / `camelName`).Motivation
Documentation pages frequently reference SDK identifiers in prose that sits outside language-specific tabs. Previously this meant writing both names inline, which was verbose, inconsistent across pages, and didn't react to the reader's language preference. The new component provides a single source of truth per identifier that switches live with the language toggle.
Public API Changes
No public API changes — this is a documentation infrastructure addition.
Component API
pytscodetrue<code>(false for plain text)Implementation
site/src/components/Syntax.astro— custom element<syntax-switch>with an idempotent inline script that reads the same localStorage key as the existing language tabsastro-auto-importso no explicit imports needed in MDX.lang-optiondelegated listener) and cross-tabstorageeventsScope
Type of Change
Documentation update
Testing
npx astro buildpasses (655 pages, 0 broken links)sdk-typescript/strands-ts/src/Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.