Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warnings to provide documentation #202

Open
softwareantics opened this issue Feb 7, 2024 · 6 comments
Open

Add warnings to provide documentation #202

softwareantics opened this issue Feb 7, 2024 · 6 comments
Labels
🌳 parser 🆘 help wanted Lower priority for Bscotch, so external help needed to resolve

Comments

@softwareantics
Copy link

My projects has some fairly strict rules around documentation. It would be neat to have some warnings around missing documentation for variables, functions, enums, etc.

@adam-coster
Copy link
Member

Can you provide some examples of the kinds of cases you'd want to see error info for, and what info you'd want to see in the error messages?

@softwareantics
Copy link
Author

We should implement support for the following warnings:

  • A warning should be triggered when a description is missing for a variable, function, enumeration, etc.
  • If a param/argument tag is missing for a function with parameters, a warning should be displayed.
    • Additionally, if the parameter type is not specified, a warning could be shown.
  • A warning should be raised when no return type is specified for a function.
  • Warnings should be generated where a type is not specified for variables, return types, etc.

Something as simple as:

Missing JSDoc description tag for {name here}
Missing JSDoc argument tag for type {function name - parameter name}
Missing JSDoc return tag for {function name here}

Furthermore, perhaps providing support for access modifiers or simply supporting /// @ignore would be a great addition, too :).

@adam-coster
Copy link
Member

I like these, though since we don't have a strong desire for them ourselves they unfortunately won't be very high up on my priority queue.


For future reference for myself, or for anyone who wants to take a crack at this.

When functions are processed we already know if they have docs:

const docs = ctx.docs || this.PROCESSOR.consumeJsdoc();

Logic could be added to look at the JSDoc contents, and add diagnostic errors via this.PROCESSOR.addDiagnostic().

Since not all users would want this, we'd need to add some Diagnostic containers specifically for this purpose to allow filtering:

export interface DiagnosticCollections {

Those new collections would probably be something like:

  • JSDOC_MISSING_DESCRIPTION
  • JSDOC_MISSING_RETURN
  • JSDOC_MISSING_PARAM
  • JSDOC_MISSING_PARAM_TYPE

After all of that we'll be getting the new diagnostics. BUT, since most users won't want that extra diagnostic info we'd need to also update the extension to allow configuration of which diagnostics the user wants. Currently we DON'T have a config option for that, but that's definitely something we'll want at some point anyway. I'm not sure what the best way would be to handle that, but poking around at other extensions they seem to use fully separate config options for each entry (or otherwise use a separate config file from the VSCode config, a la eslint.

Having them in the Extension config would probably be best, though. The config entries could be something like "stitch.diagnostics.enable.JSDOC_MISSING_DESCRIPTION" booleans or something.

@adam-coster adam-coster added 🆘 help wanted Lower priority for Bscotch, so external help needed to resolve 🌳 parser labels Feb 26, 2024
@softwareantics
Copy link
Author

Is this something I could look at implementing?

@adam-coster
Copy link
Member

Is this something I could look at implementing?

Definitely! It's complicated, especially if you aren't used to the Node.js ecosystem, so it'll take some doing. You can make a draft PR to ask questions as you go.

I haven't added much documentation for development setup, but that's something I can do sometimes this week to reduce initial friction

@softwareantics
Copy link
Author

That sounds great, I'd love to see this feature through to the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌳 parser 🆘 help wanted Lower priority for Bscotch, so external help needed to resolve
Projects
None yet
Development

No branches or pull requests

2 participants