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
90 stars 7 forks source link

`lastComment` is not consumed when emitted in `onopentag` of the HtmlParser callback handler #47

Closed soft-decay closed 3 years ago

soft-decay commented 3 years ago

in onattribute, lastComment is comsumed (emitted and set to null):

if (!hasOwnProperty(this.eventsEmitted, baseEvent.name)) {
    this.eventsEmitted[baseEvent.name] = baseEvent;

    this.parseKeywords(comment.keywords, baseEvent);
    this.emit('event', baseEvent);
}

lastComment = null;

but it is only emitted in onopentag. It should be removed to prevent its application to other elements.

Example : In https://svelte-materialify.vercel.app/api/TextField/, the comment 'Slot for prepend inside the input.' should only be applied to <slot name="prepend" /> but is also applied to <slot />, <slot name="content" />, and on:focus.

alexprey commented 3 years ago

Hi, I'll try to look at this

alexprey commented 3 years ago

Hi @soft-decay! I'm fix this issue in this commit https://github.com/alexprey/sveltedoc-parser/commit/9a7bfc4b4b6d13e75a0ee294bf24040262d0e426. This commit based on refactoring branch, I'm add few simple tests for that, but it will be good if you can check fix on your examples and approve that this fix are correct.

Thanks!

soft-decay commented 3 years ago

Hi @alexprey,

Just checked and the problem is fixed in the example provided. Thanks.

alexprey commented 3 years ago

Perfect! So! I'll merge that