Sveld auto doc of Props and Accessibility #364
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DO NOT MERGE - this is for previewing
What does your PR address?
Fixes #351
Notes: This actually uses https://github.com/mattjennings/vite-plugin-sveld which in turn uses sveld.
To differentiate between props that are Props and props that are for Accessibility, it is using magic strings in the description, if
a11y
appears in the description, it will be moved into the Accessibility tab.To enable this for a components doc page, add
components={["Accordion/AccordionGroup","Accordion/AccordionItem"]}
to the DocsShell's props. It handles a plain string for a single component and an array of strings components.Although it handles migrating the Props tabs over incrementally (it replaces the
props DocsShellTable
, it can't be done for Accessibility due to extraneous tables being added like KeyBindings that sveld can't detect.I've done the Accordion components as an example to show what's needed. They are not for publishing yet, but rather to show what's needed and how different scenarios work.
Where a type has a union of possible values, it must be declared using the
@type
directive, otherwise only the last type of the union is declared from the auto-inference.Vite also complains mightily about doing dynamic imports like this, so some more testing needs to be done of a full published docs site. There is a fallback option if issues arise, but it's uglier to wire up.