Try/jsdoc parser#13637
Conversation
|
On recognising functions:
Regarding default exports: Adding a comment including the I'm not sure what the above will do for functions that aren't exported. If they are still exported then it's likely they'll be in the global namespace. It would be possible to adapt the template to filter out any nodes in the global namespace except for a whitelist. Generally everything exported should be in the |
|
Closing for now. We are going to try a different approach. Context https://meta.trac.wordpress.org/ticket/3063#comment:9 |
Playground to understand how to use jsdoc and jsdoc-parser to generate API documentation and how it relates to #13329
As per the instructions in the core ticket, in the Gutenberg root folder, execute:
and open the generated file
parsed-jsdoc.json(see here the raw formatted file).Questions
Here's a set of questions I don't have answers for yet:
How to restrict generated documentation to the Public API?
Example:
packages/dompackage.Symbols that should be documented (and are):
Symbols that we shouldn't be documented (and are):
In this package, we should document the named export
focus, but we don't. This is a tricky one. Here's what jsdoc finds and what not:domnamespace, we should usedom.focus.focusable.findinstead.domnamespace, we should usedom.focus.focusable.findinstead.How to document symbols that don't have a JSDoc comment?
In the above example, jsdoc didn't report the existence of
focus.tabbable.findbecause it didn't have any JSDoc comment.How to document functions exported as variables
packages/a11ypackage. We should have two functions documented (setup,speak) but they aren't.This is a common pattern:
export const myFunction = ( ... ) => { ... }?. It looks like jsdoc classifies this as amemberand doesn't provide input/output information.How to document default exports?
Example:
packages/api-fetchpackage. The default export isn't documented.Example:
packages/components. It looks like jsdoc needs a@moduletag to detect thedefaultexports. That could solve the particular case ofpackages/api-fetch, but how would we document default exports in sub-folders?How to document renamed exports?
Example:
packages/block-library. It should document a few functionschildren,node,serialize,parseexported throughapi.jsthat are renamed from the default export.Example:
packages/components. Almost all components are exported insrc/index.jsby renaming the default exports.Example:
packages/compose. Besides the renamed default exports, we also should report thecomposenamed export that is renamed fromflowRight.How to document export chains?
packages/editor.The editor exports a variety of things. We should document
mediaUploadas a function in thewp.editornamespace. Because it's exported through a export chain it isn't properly reported by jsdoc (it is reported, but its name is "exports", it should bemediaUpload).