bscotch / stitch

Tools and apps for GameMaker development: a CLI for pipeline development, a VSCode extension for coding, and more.
Other
110 stars 13 forks source link

Add warnings to provide documentation #202

Open softwareantics opened 7 months ago

softwareantics commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

We should implement support for the following warnings:

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 commented 6 months ago

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:

https://github.com/bscotch/stitch/blob/87783b9ababee4095308a131d41e1e850029d61f/packages/parser/src/visitor.functionExpression.ts#L19

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:

https://github.com/bscotch/stitch/blob/87783b9ababee4095308a131d41e1e850029d61f/packages/parser/src/project.diagnostics.ts#L7

Those new collections would probably be something like:

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.

softwareantics commented 6 months ago

Is this something I could look at implementing?

adam-coster commented 6 months ago

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 commented 6 months ago

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