8

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);
}
Tim McNamara
  • 18,019
  • 4
  • 52
  • 83

4 Answers4

3

JSDoc is one way to do it.

/**
 * Adds two numbers.
 */
function add(a, b) {
    return a+b;
}
icktoofay
  • 126,289
  • 21
  • 250
  • 231
0

Have you seen JSDoc (which has now been superceded by JSDoc toolkit)?

Russ Cam
  • 124,184
  • 33
  • 204
  • 266
0

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.

neurolabs
  • 542
  • 3
  • 8
0

PDoc is an in-line documentation generator for the Prototype library, written in Ruby.

Tim McNamara
  • 18,019
  • 4
  • 52
  • 83