What is the best way to document components in Svelte 5? #11597
-
Due to the many changes in svelte 5 like "svelte/internals", "svelte/compiler", etc. Most tools (if not all) for generating components I know this question is ahead of the facts... However, I'm curious to know if there is a better way to do all this than to continue using "svelte/compiler" or "svelte/internals". Thank you... |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
it should be <!--
@component General description of the component
--> and type Props = {
/**
* Description of the prop
* @deprecated - use `otherProp` intead
*/
requiredProp: string,
optionalProp?: string,
};
let { ... }: Props = $props(); or /**
* @typedef {object} Props
* @prop {string} requiredProp - Description of the prop
* @prop {string} [optionalProp]
*/
/** @type {Props} */
let { ... } = $props(); |
Beta Was this translation helpful? Give feedback.
-
I apologize I was not very clear in my question... I'm referring to the best way to document components for a library. That takes the comments and props and returns as an object or an AST which can be rendered into a website for the library. With Svelte 4 or lower, we used a solution like Sveld or Svench. |
Beta Was this translation helpful? Give feedback.
I believe the components should be types as I showed, and the docs extractors need to implement Svelte 5 support. So the best is to open an issue about Svelte 5 support in those projects.