jsdoc rules for better packages reference docs #91
Maciek Kucmus (mkucmus)
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
jsdoc rules
examples of how to make reference section better by following some jsdoc rules
Description
Use JSDoc: @description
Every function must contain a comment with general description of a purpose or main goal.
Can be placed as a first text in the function/type comment section or prefixed with
@descriptiontag later on.will become on function detail page:
and the same description will be used in index file:
Visibility
@publicevery function or type marked by this tag will be published and appear in a package reference table of functions:@betaor nothing - won’t appear in reference index file.Parameters
Use JSDoc: @param
In our case the
@paramtag is necessary in order to have an explanation what a specific parameter is used for:Will become:
If provided type like
Productis defined in@shopware-pwa/typespackage, vitepress will try to link it to the corresponding file in GitHub repository. Otherwise it will remain a plain text like it does for typesstringorbooleanand other primitive types.Complex types
Every exported type should be also documented, especially defined properties and methods:
Will become:
if it’s a method (function)
for properties
Custom tags
@categoryThis tag is used to group functions in the groups to improve the readiness:
Will place a tagged function to Product section in index file of a package:
@NOLINKEvery function listed in a package index file is automatically linked to the function detail page:
getProductUrlfrom@shopware-pwa/helperswill be linked to:helpers/getProductUrl.mdIf there is no need to create a specific detail page for a function, use
@NOLINKtag in the function’s description to not link the function to the corresponding page. Otherwise there will be a warning during build time of vitepress documentation.A good example is endpoints getters that are self-descriptive and there is nothing new to add.
Beta Was this translation helpful? Give feedback.
All reactions