PyCharm 2016.1 Help

Creating JSDoc Comments

To make your code easy to use by other developers it is considered good practice to provide an HTML documentation of its Application Programming Interface (API). Such documentation can be generated automatically by the JSDoc tool. All you need, is supply your code with documentation comments in accordance with the JSDoc standard. The tool retrieves information from your comments and renders it in HTML using a built-in template.

You can find a detailed description of the JSDoc syntax with examples and explanation of their use in the article An Introduction to JSDoc.

PyCharm creates stubs of JSDoc comments on typing the opening tag /** and pressing Enter. If this feature is applied to a method or a function, @param tags are created. In any other places PyCharm adds an empty documentation stub.

TODO patterns and Closure Compiler annotations inside documentation comments are also recognized and are involved in code completion, intention actions, and other types of coding assistance.

Documentation comments in your source code are available for the Quick Documentation Lookup and open for review on pressing Ctrl+Q.

PyCharm checks syntax in the comments and treats it according to the Code Inspections settings.

On this page:

Example of JavaScript comment

Consider the following function:

function loadDocs(myParam1, myParam2){}

Type the opening documentation comment and press Enter to generate the documentation comment stub:

/** * @param myParam1 * @param myParam2 */

To enable or disable generation of documentation comments

  1. Open the Settings dialog box, expand the Editor node, then expand General node, and click the Smart Keys page.
  2. In the Enter section, select or clear Insert documentation comment stub check box.
  3. Then, scroll to the Insert type placeholders in the documentation comment stub option and select the check box.

To create a JSDoc comment block for a method or a function

  1. Place the caret before the method or function declaration.
  2. Type the opening block comment /** and press Enter.
  3. Describe the listed parameters and return values.

Documentation comment can be created with the dedicated action Fix Doc Comment. It can be invoked by means of Find Action command.

Press Ctrl+Shift+A, with the caret somewhere within a class, method, function, or field, which should be documented, and enter the action name Fix Doc String. The missing documentation stub with the corresponding tags is added. For example:

function loadDocs(myParam1, myParam2){}

Type the opening documentation comment and press Enter to generate the documentation comment stub:

/** * @param myParam1 * @param myParam2 */

The next case lays with fixing problems in the existing documentation comments.

For example, if a method signature has been changed, PyCharm highlights a tag that doesn't match the method signature.

For Python, PyCharm suggests an inspection Ignore unresolved reference:

py_fix_doc_comment

For JavaScript, PyCharm suggests an intention action UpdateJSDoc comment. You can also press Ctrl+Shift+A, and type the action name:

fix_doc_comment_js

See Also

Last modified: 20 April 2016