alexprey / sveltedoc-parser

Generate a JSON documentation for a Svelte (https://github.com/sveltejs/svelte) component
https://www.npmjs.com/package/sveltedoc-parser
MIT License
89 stars 7 forks source link

The JSDoc descriptions for slot props is not parsed correctly #61

Closed alexprey closed 3 years ago

alexprey commented 3 years ago

Look at the following examples:

{#each items as item}
        <!-- 
            Render the one item markup based on data passed in slot property.
            @param {GenericListItem} prop The item of the list that should be rendered.
         -->
        <slot prop={item}></slot>
{/each}

In output for slot property we have only name, but ignore any description and type reading for that.

Actual output

            "parameters": [
                {
                    "name": "prop",
                    "visibility": "public"
                }
            ]

Expected output

            "parameters": [
                {
                    "name": "prop",
                    "description": "The item of the list that should be rendered.",
                    "type": {
                        "kind": "type",
                        "type": "GenericListItem"
                    },
                    "visibility": "public"
                }
            ]

Techinical details

Changes for this fix corelated with #47 issue. The issue #47 already has changes that will be merged soon, please start fix from branching on following commit: https://github.com/alexprey/sveltedoc-parser/commit/9a7bfc4b4b6d13e75a0ee294bf24040262d0e426

alexprey commented 3 years ago

After check the typings file, I found that it has wrong specification of slot parameters. So, it should be reworked. Thats why I mark this issue with braking label.

How it now:

export interface IScopedCommentItem {
    description?: string | null;
    visibility?: JSVisibilityScope;
    keywords?: JSDocKeyword[];
}
export interface ISvelteItem extends IScopedCommentItem {
    name: string;
    locations?: SourceLocation[];
}
export interface SvelteSlotParameter extends ISvelteItem {}

But should be like following structure:

export interface SvelteSlotParameter {
    name: string;
    type: JSDocType;
    description?: string;
    locations?: SourceLocation[];
}