feat(site): extract api reference from components#464
Conversation
Addressing #259 for basic cases Does not include support for unimplemented items like component components or css custom properties also: - remove old examples & reference docs
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
✅ Deploy Preview for vjs10-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR extracts API reference documentation from TypeScript source files and generates interactive, framework-aware reference tables in the documentation site.
Changes:
- Add api-docs-builder script that extracts props, state, and data attributes from TypeScript source files and outputs validated JSON
- Add Astro components (ApiRefSection, ApiPropsTable, ApiStateTable, ApiDataAttrsTable, PropRow, InlineMarkdown) that render the generated JSON as interactive reference tables
- Replace hand-written reference docs for play-button and mute-button with auto-generated API reference sections, and remove old examples for fullscreen-button, time-slider, and volume-slider
Reviewed changes
Copilot reviewed 65 out of 67 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| site/vitest.config.ts | Added scripts/api-docs-builder/src to test coverage |
| site/src/utils/docs/renderInlineMarkdown.ts | Added markdown renderer for API documentation descriptions |
| site/src/utils/docs/tests/renderInlineMarkdown.test.ts | Added tests for markdown renderer |
| site/src/types/api-reference.ts | Added Zod schemas for API reference JSON structure |
| site/src/examples/react/VolumeSlider/* | Removed old example files |
| site/src/examples/react/TimeSlider/* | Removed old example files |
| site/src/examples/react/PlayButton/* | Removed old example files |
| site/src/examples/react/MuteButton/* | Removed old example files |
| site/src/examples/react/FullscreenButton/* | Removed old example files |
| site/src/examples/html/volume-slider/* | Removed old HTML examples |
| site/src/examples/html/time-slider/* | Removed old HTML examples |
| site/src/examples/html/play-button/* | Removed old HTML examples |
| site/src/examples/html/mute-button/* | Removed old HTML examples |
| site/src/examples/html/fullscreen-button/* | Removed old HTML examples |
| site/src/docs.config.ts | Removed references to deleted component pages |
| site/src/content/docs/reference/volume-slider.mdx | Removed hand-written reference page |
| site/src/content/docs/reference/time-slider.mdx | Removed hand-written reference page |
| site/src/content/docs/reference/play-button.mdx | Replaced with auto-generated API reference |
| site/src/content/docs/reference/mute-button.mdx | Replaced with auto-generated API reference |
| site/src/content/docs/reference/fullscreen-button.mdx | Removed hand-written reference page |
| site/src/content/docs/concepts/ui-components.mdx | Updated to reflect removed component pages |
| site/src/content.config.ts | Added apiReference collection |
| site/src/components/typography/Table.astro | Added outerClass prop for custom styling |
| site/src/components/docs/api-reference/PropRow.astro | Added expandable prop row component |
| site/src/components/docs/api-reference/InlineMarkdown.astro | Added inline markdown renderer component |
| site/src/components/docs/api-reference/ApiStateTable.astro | Added state table component |
| site/src/components/docs/api-reference/ApiRefSection.astro | Added main API reference section component |
| site/src/components/docs/api-reference/ApiPropsTable.astro | Added props table component |
| site/src/components/docs/api-reference/ApiDataAttrsTable.astro | Added data attributes table component |
| site/scripts/api-docs-builder/src/types.ts | Added type definitions for builder |
| site/scripts/api-docs-builder/src/tests/html-handler.test.ts | Added tests for HTML extraction |
| site/scripts/api-docs-builder/src/tests/formatter.test.ts | Added tests for type formatting |
| site/scripts/api-docs-builder/src/tests/data-attrs-handler.test.ts | Added tests for data attributes extraction |
| site/scripts/api-docs-builder/src/tests/core-handler.test.ts | Added tests for core extraction |
| site/scripts/api-docs-builder/src/index.ts | Added main builder orchestration logic |
| site/scripts/api-docs-builder/src/html-handler.ts | Added HTML element extraction logic |
| site/scripts/api-docs-builder/src/formatter.ts | Added type formatting utilities |
| site/scripts/api-docs-builder/src/data-attrs-handler.ts | Added data attributes extraction logic |
| site/scripts/api-docs-builder/src/core-handler.ts | Added props/state extraction logic |
| site/scripts/api-docs-builder/README.md | Added documentation for the builder |
| site/package.json | Added dependencies and scripts for API docs generation |
| site/CLAUDE.md | Added documentation about API reference generation |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const detail = document.getElementById( | ||
| button.getAttribute("aria-controls")!, | ||
| ); |
There was a problem hiding this comment.
Potential null dereference if button.getAttribute('aria-controls') returns null. Add a null check before calling getElementById.
| const detail = document.getElementById( | |
| button.getAttribute("aria-controls")!, | |
| ); | |
| const controlsId = button.getAttribute("aria-controls"); | |
| if (!controlsId) return; | |
| const detail = document.getElementById(controlsId); |
mihar-22
left a comment
There was a problem hiding this comment.
This is looking really good! Incredible foundation for us to layer on CSS Vars and Compound Components. I'm more concerned with how this will evolve to support the latter, might require significant changes. Either way, awesome start :)
| description: z.string(), | ||
| }); | ||
|
|
||
| export const ComponentApiReferenceSchema = z.object({ |
There was a problem hiding this comment.
Will this need to change or will it hold up when we add support for Compounds? Either we have a new schema that contains Component API Schems, or we extend this with parts.
We'll also need to discuss and establish a pattern in core for how Compound Parts will be discovered.
There was a problem hiding this comment.
Definitely needs to change for compound.
Closes #259 for basic cases
Note
Does not include support for unimplemented items like component components or css custom properties
how?
unrelated