23

Is there something like JavaDocs for Javascript? When I press ctrl+space in netbeans IDE while

writing javascript, the javascript documentation comes out for the object specified. But this documentation is I guess Netbeans' property.

If we write javascript in proper commented way, Netbeans builds docs for our custom javascript too.

Can we find any such javascript documentation, outside Netbeans? So that we can refer to it?

Thanks for answer.

0

4 Answers 4

16

Have a look at the doc pages at Mozilla Developer Network (MDN) for a static reference:

However, I am afraid that there is no tab-completion that can be used inside an IDE.

Sign up to request clarification or add additional context in comments.

2 Comments

Google search tip: add " mdn" after a javascript term, e.g., "substr mdn" and the corresponding MDN page will almost always be the first search result.
I wouldn't give up on tab completion for JsDoc (Javadocish) inside an IDE. WebStorm says they support it: stackoverflow.com/questions/11076572/…
11

In Google's source code of their homepage doodles, they use comments which look very similar to javadoc comments, so there must be some standard that at least Google uses.

Here is an example:

/**
 * Configuration for a simulator speed setting.
 * - stepTime: ms between simulation steps that do something.
 * - emptyStepTime: ms between no-op steps.
 * - tapeTime: ms for a tape operation.
 * - branchTime: ms for a branch operation.
 * @typedef {{stepTime: number, tapeTime: number, emptyStepTime: number,
 *            branchTime: number}}
 * @private
 */

1 Comment

These are JSDoc tags, in this case for the Google Closure compiler, so they can actually serve a functional purpose (I think the compiler actually enforces them, such as the @typedef and @private tags in your pasted example).
7

(Ten years later.) There are two parts to your question:

  1. Seeing documentation for methods and such from the standard library.

    Yes, most modern JavaScript IDEs (like Visual Studio Code, WebStorm, ...) have documentation for the JavaScript standard library objects/methods built into them (usually by drawing on the type information from definitely typed, which also includes types for lots of other libraries you may use).

  2. Including documentation in your own code and seeing it / building documentation files.

    Yes, most modern JavaScript IDEs support JSDoc (which is very JavaDoc-like) and will show you your documentation inline.

    To actually build documentation, you'll need a tool that understands JSDoc (whether it's the JSDoc tool itself or any of several others that also understand the format) that creates documentation files for you in HTML, PDF, or whatever format.

Here are some examples of JSDoc comments (taken from my answer here), but see the JSDoc documentation for details:

/**
 * Does something nifty.
 *
 * @param   whatsit  The whatsit to use (or whatever).
 * @returns A useful value.
 */
function nifty(whatsit) {
    return /*...*/;
}

You can augment that with types if you want type hints:

/**
 * Does something nifty.
 *
 * @param   {number} whatsit  The whatsit to use (or whatever).
 * @returns {string} A useful value.
 */
function nifty(whatsit) {
    return /*...*/;
}

If you use TypeScript, the types would be part of the code rather than in the JSDoc:

// TypeScript example
/**
 * Does something nifty.
 *
 * @param   whatsit  The whatsit to use (or whatever).
 * @returns A useful value.
 */
function nifty(whatsit: number): string {
    return /*...*/;
}

Comments

-1

Try an application called Ortelius. It uses some kind of javadoc like syntax to genrate documentation. ortelius.marten.dk

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.