I thought it would be a good idea for there to be a central place for people to list JSDoc plugins they've made and are happy for others to use - that way if we as users are after a quick fix/feature, we can browse through the list of plugins and see if any of them help us.
I'm unsure if such a resource exists already, so I thought I'd start a topic for it. Although I think this would work nicer on a wiki page or something.
(As an aside - for those of you who use version management, how do you store your plugins? do you fork jsdoc and just commit the entire repo with all your plugins, or do you make a separate repository per plugin?)
To get the ball rolling, I thought I'd add a couple of plugins I've been muddling along with.
First, a disclaimer - the plugins I've shared appear to work for my documentation, but are not widely tested so don't be surprised by things that don't work! If you like you can email me if you notice something not working (preferably with a fix :P) and I can incorporate it, but I don't intend to do full support of the plugins - they're really for my personal use and I share them in case they might help others. Feel free to tweak them to your uses.
pragmaTag
Status: Appears to be working, not rigorously tested, subject to further development/changes.
Description:
adds two tags, `@+` and `@-`. Tags added in the '@+' will be added to subsequent doclets until '@-' is encountered. Can be nested. NOTE: for the moment "subsequent doclets" means only those that have associated symbols, i.e. it excludes virtual doclets documented with @name and so on. I don't know how to get it working for those yet.
Known issues:
* only doclets that have a corresponding bit of code will be affected by the @+ and @-. In particular, virtual doclets that are not associated with code such as blocks using `@name` will not be affected. This is because of issue #228 (I think this can be worked around but I haven't figured it out yet)
Example:
// example: use of pragma tags for lots of constants
// Let's document the following code:
const MY_CONSTANT = 1;
const MY_CONSTANT2 = 2;
const MY_CONSTANT3 = 3;
const MY_CONSTANT4 = 4;
// ------ without pragma tags ------ // ------ with pragma tags ------ //
/** Some documentation // /** @+
* @const // * @const
* @default // * @default
* @type {number} */ // * @type {number} */
const MY_CONSTANT = 1; //
// /** Some documentation */
/** Some documentation // const MY_CONSTANT = 1;
* @const //
* @default // /** Some documentation */
* @type {number} */ // const MY_CONSTANT2 = 2;
const MY_CONSTANT2 = 2; //
// /** Some documentation */
/** Some documentation // const MY_CONSTANT3 = 3;
* @const //
* @default // /** Some documentation */
* @type {number} */ // const MY_CONSTANT4 = 4;
const MY_CONSTANT3 = 3; //
// /** @- */
/** Some documentation //
* @const //
* @default //
* @type {number} */ //
const MY_CONSTANT4 = 4; //
inheritDoc
Status: Appears to be working (again, might not stand up under rigorous use or use outside of my documentation setup)
Description:
Added tags:
- @inheritparams <someOtherSymbol>: copies the parameters and return values of <someOtherSymbol> to the current doclet. They can be overidden.
- @inheritdoc <someOtherSymbol>: as above, but additionally copies the description, summary, classdesc (where they have not been specified).
- @override: the same as @inheritdoc, but use it in a subclass method that overrides the superclass method and you then don't have to write <someOtherSymbol>.
Known issues:
- I think Google/Java Closure Compiler also has @override and @inheritdoc, and I suspect mine does something different to theirs, so make sure you understand what each tag does before using it (you may wish to modify the plugin and rename the tags to something less confusing if you like; for me I have never used any other documentation system with these tags so it doesn't bother me)
- I have no idea what happens if you daisy chain many @inheritdoc/@inheritparam in various orders (within the file). I'd like to hope that things work, but don't be surprised if many nested levels of @inherit... fail on some parameters.
Example:
/** a function
* @param {number} x - x value
* @param {number} y - y value
* @returns {number} a number
*/
function myFunction (x, y) {
return x + y;
}
// x, returns and description ("a function") documentation are taken from myFunction
// y should be overridden, z should be there.
/**
* @param {number} y - overridden y explanation
* @param {number} z - z value
* @inheritdoc myFunction
*/
function myFunction2 (x, y, z) {
return x + y + z
}
// only y is borrowed from myFunction as myFunction has x and y only
// if you document z explicitly it will be there, otherwise it will show up as "undocumented"
/** another function
* @inheritparams myFunction
* @returns {number} fasdf
*/
function myFunction3 (y, z) {
return y + z;
}
I hope others add their plugins here so we get a nice plugins list going! (Note - if you're looking around in the repo that those plugin files came from, don't be tempted by any of the plugin-looking files there that aren't part of JSDoc3 and that I didn't mention here - they're probably heavily in progress and not ready for sharing).