Generating Javascript documentation [closed]

谁说胖子不能爱 提交于 2019-11-29 20:26:02
Raynos

There are tools like Natural Docs to do this. I've personally used it in the past and this works fine with javascript.

There are also tools like docco to document source code.

In general auto generated documentation tends to be too restrictive and sometimes handmade API's like the jQuery API are easier to use.

Also documentation for dynamic languages is different from documentation on static languages. As API's are used differently and state exist in a more loose sense.

I found a great tutorial to create JS documentation using JSDoc. I hope it helps to someone who need it.

Create useful relevant Javascript documentation with JSDoc

This was exactly what I need. Thanks for your answers stackers.

If you work with node.js, i created a module that generate class diagram for javascript/node/html/css. Its based on the "WAE" extension of UML. Its called wavi. For javascript, function,variable and use of other modules are automatically recognized. You can use it for documenting your application.

https://www.npmjs.org/package/wavi

SmartComments + YUIDocs

Using that extraordinary couple you can document a large JavaScript project in less than one minute.

SmartComments, it’s a tool that allow you to create implicit comments from JavaScript source code.

You can use in the console or through of a Sublime Text Plugin.

Please go to http://smartcomments.github.io for further information.

autodoc is teh dope; https://www.npmjs.org/package/autodoc | https://github.com/dtao/autodoc

Autodoc lets you write tests in comments just above your JavaScript functions, then run those tests from the command line and auto-generate documentation with the same tests embedded and executing right in the browser.

Think literate programming, look at http://danieltao.com/lazy.js/docs/ for a nice example. Those green checkmarks are the tests.

✓ Lazy([1, 2, 4])       // instanceof Lazy.ArrayLikeSequence
✓ Lazy({ foo: "bar" })  // instanceof Lazy.ObjectLikeSequence
✓ Lazy("hello, world!") // instanceof Lazy.StringLikeSequence
✓ Lazy()                // sequence: []
✓ Lazy(null)            // sequence: []

This is what the source looks like github.com/../lazy.js#L86

/**
 * Wraps an object and returns a {@link Sequence}. For `null` or `undefined`,
 * simply returns an empty sequence (see {@link Lazy.strict} for a stricter
 * implementation).
 *
 * - For **arrays**, Lazy will create a sequence comprising the elements in
 *   the array (an {@link ArrayLikeSequence}).
 * - For **objects**, Lazy will create a sequence of key/value pairs
 *   (an {@link ObjectLikeSequence}).
 * - For **strings**, Lazy will create a sequence of characters (a
 *   {@link StringLikeSequence}).
 *
 * @public
 * @param {Array|Object|string} source An array, object, or string to wrap.
 * @returns {Sequence} The wrapped lazy object.
 *
 *
 * @examples
 * Lazy([1, 2, 4])       // instanceof Lazy.ArrayLikeSequence
 * Lazy({ foo: "bar" })  // instanceof Lazy.ObjectLikeSequence
 * Lazy("hello, world!") // instanceof Lazy.StringLikeSequence
 * Lazy()                // sequence: []
 * Lazy(null)            // sequence: []
 */

It extends JSDoc https://developers.google.com/closure/compiler/docs/js-for-compiler, so in addition you can have Google's closure compiler verifying and optimising lot of things for you.

Which framework are you using ? (if any). I think the tool you'll choose depends a lot on that, since ideally it would have to understand class extensions and all. Otherwise I think jsDoc is a great place to start.

Hi i just found YUIDoc. I don't know much about it, but it looks good...

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