What is the standard way of adding documentation to a JavaScript function? [closed]

限于喜欢 提交于 2019-12-10 13:03:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!