Ask HN: Best libraries for converting JavaScript comments to both docs and tests?
Basically, I'd like to automate docs and tests as much as possible from comments like this (or something similar):
/**
* Adds `b` to `a`.
*
* @param a {Number}
* @param b {Number}
* @return {Number}
* @api public
*/
function add (a, b) {
return a + b;
}
Obviously there are libraries that can do what I'm asking, but I'm having trouble finding the best one(s), so I figured I'd just ask here. :)
3 comments
[ 2.7 ms ] story [ 18.4 ms ] threadEdit: Found https://github.com/tj/dox, but surely there's a way to convert these comments (with maybe a little extra info) to tests?
Now what you might want is something like:
Then the documentation could link out to the specific test or tests for this method. Though if you are going to go this route you will probably want some sort of automated code analysis to find the test locations and link them in. Creating rudimentary documentation from these comments should be trivial.