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

fix #78: Add additional metadata for function expressions #79

Closed ekhaled closed 2 years ago

ekhaled commented 3 years ago

closes #78

alexprey commented 3 years ago

Hi, thanks for changes! Looks very nice. However, I not sure about data structure changes in SvelteDataItem, I'm think that it is not a good idea to make that type messy. I need a time to think about that and comeback later

ekhaled commented 3 years ago

If you have any suggestions, let me know. Happy to implement it 😄

alexprey commented 3 years ago

Ok, I'm thinking on that and that what I think: Params and return metadata are used in functions, and actually functions can be used anywhere in the JS code: component can have methods, variables can be a function, parameter can be a function, return type also can be a function. And if you look at JSDocType you can see that I already provide additional information about type. So, let to create a new type for JSDocType:

export interface JSDocTypeFunction extends JSDocTypeBase {
    kind: 'function';
    params?: SvelteMethodParamItem[];
    return?: SvelteMethodReturnItem;
}

and update the following:

export type JSDocType = JSDocTypeElement | JSDocTypeConst | JSDocTypeFunction | JSDocTypeUnion;

I think that is a better way to do that. If you have any ideas or points, please mention that, I'm open for discussion

ekhaled commented 3 years ago

That sounds absolutely fine to me. Are you able to make the relevant commits and update this PR?

alexprey commented 3 years ago

Ok, I'm update your PR and merge it. Try to do it on this week and plan release for the next week. Thanks for you contribution!

alexprey commented 2 years ago

@ekhaled thanks for your contribution to that library! Sorry, that I was too much slow to make last fixes and publish the new version of library 🐱