问题
I'm looking at generating API docs for a JavaScript project. Does JavaScript have anything similar to Python's docstring?
function add(a, b) {
/**
Returns the sum of `a` and `b`.
*/
return (a - 0) + (b - 0);
}
回答1:
Have you seen JSDoc (which has now been superceded by JSDoc toolkit)?
回答2:
JSDoc is one way to do it.
/**
* Adds two numbers.
*/
function add(a, b) {
return a+b;
}
回答3:
When I needed it, JSDoc was the only available tool, and was pretty messy. We always got stack overflows because they used perl and regular expressions to parse the source. At first glance JSDoc Toolkit as mentioned look good, they're now using JavaScript.
回答4:
PDoc is an in-line documentation generator for the Prototype library, written in Ruby.
来源:https://stackoverflow.com/questions/4180224/what-is-the-standard-way-of-adding-documentation-to-a-javascript-function