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
Terse documentation #294
Comments
Personally, I think using inference based on Flow annotations hits the sweet spot in terms of concision, avoiding Yet Another Type Annotation Syntax, and taking best advantage of the tooling ecosystem.
Coincidentally, this is exactly what documentation.js aims to support! What this doesn't give you is parameter descriptions -- but all the other examples above don't have that either. If you want to describe the parameters (which I think for most real world functions is good practice), JSDoc gives you that option, and with documentation.js you don't have to sacrifice type or default value inference.
|
I considered going with Flow-style annotations, but that would lock me into using a preprocessor even after Node starts supporting enough of ES6 to run my code, and make it impossible to have tools that understand just ES6 without extensions work with the code. |
Comment-type Flow annotations are well-established now, could we support those too? |
As @marijnh https://github.com/marijnh/getdocs and @IvanSanchez's https://github.com/IvanSanchez/Leafdoc indicate, there's a significant faction that wants more compact documentation syntax than JSDoc.
As far as "how it's terse":
Comment style
Both projects consume
//
C++ style comments as well as or instead of/**
comments. It's code-wise simple to support one as well as the other, but the JSDoc/**
style makes it explicit which comments will be output in documentation and which will not be. If we supported//
comments, my best guess is that we'd put in a rule that said "if this comment block contains at least one tag, treat it as documentation"Short params syntax
This is in getdocs:
This is roughly equivalent to
But it expresses only types, rather than param descriptions, and refers to params by their index in the arguments array rather than their name.
I wonder if we could do something like a
@params
tag that split the difference:Leafdoc also does a short arguments / return value syntax, like
Note that both of these approaches are super close to type annotations - Leafdoc's are so close to Flow annotations that I'd argue they should be Flow annotations.
Multiple comments on one line
From Leafdoc:
As far as I know, the
;
character isn't used in JSDoc syntax, but I would need to look again. I'm cool with a delimiter to avoid newlines, but it isn't something I'd personally use, since it's similar to bunching lots of source code on the same line; moving complexity around.The text was updated successfully, but these errors were encountered: