Questions tagged [jsdoc]

JSDoc is a markup language for adding inline API documentation to JavaScript source code. This is distinct from the various tools that parse and manipulate code that follows the JSDoc syntax.

The JSDoc markup language is similar to the Javadoc syntax, used for documenting Java code, but is specialized to work with JavaScript's more dynamic syntax and therefore unique, as it is not completely compatible with Javadoc. However, like Javadoc, JSDoc allows the programmer to create doclets and tags which can then be translated into published output, like HTML or RTF.

Example:

/**
    Represents a book.
    @constructor
    @param {string} title - The title of the book.
    @param {string} author - The author of the book.
 */
function Book(title, author) {
}

The following annotations are commonly used in modern JSDoc, but the full list varies between implementations:

  • @param Documents a method parameter; a datatype indicator can be added between curly braces
  • @return Documents a return value
  • @constructor Marks a function as a constructor
  • @deprecated Marks a method as deprecated
  • @private Signifies that a method is private
  • @requires Describe a required resource.
  • @this Specifies the type of the object to which the keyword "this" refers within a function.
  • @throws Documents an exception thrown by a method
  • @exception Synonym for @throws
  • @author Developer's name
  • @version Provides the version number of a library
1697 questions
13
votes
2 answers

JSDoc: arrow function params

I'm trying to document my code with JSDoc (EcmaScript 2015, WebStorm 12 Build 144.3357.8). I have an arrow function which I want to document its parameters. This two examples work (I get auto-completion): /** @param {Number} num1*/ var a = num1 =>…
Ziki
  • 1,390
  • 1
  • 13
  • 34
13
votes
2 answers

How to create jsdoc types from json schemas

I have tons of json schema for node.js project. Can I use them in any way for: Accessing them as jsdoc types from ".js" code files to increase webstorm intellisense accuracy Or for creating jsdoc type definitions automatically ?
uzay95
  • 16,052
  • 31
  • 116
  • 182
13
votes
2 answers

Is There Any Way to Avoid Using the JSDoc "@method" Annotation

I'm not a big fan of generated documentation personally (I'm more of a "read the source Luke" kinda guy), but I can see how such documentation might be useful to others. Now, normally their generating of documentation wouldn't impact me, except for…
machineghost
  • 33,529
  • 30
  • 159
  • 234
12
votes
2 answers

Can VS code auto generate jsdoc with typescript types?

If I have some function like this: const function = (param: string) => { // ... } Now in VS Code if I start typing /** above so that it generates the docs, it gives this: /** * * @param param */ const function = (param: string) => { //…
r-gee
  • 121
  • 2
12
votes
6 answers

Write JSdoc for generic function in typescript

I've distilled an essence of my problem with following codes: full source I have Base class, and Derived, Derived2: class Base { static get type() { return 'Base'; } } class Derived extends Base { } class Derived2 extends Base…
Vincent
  • 3,191
  • 3
  • 29
  • 35
12
votes
1 answer

What does `function(*=)` imply in a JSDoc-style code comment?

I'm writing some code comments using JSDoc style, and want to know what *= implies in @returns {function(*=): *}, which is generated by WebStorm. I have tried to search the JSDoc wiki and usejsdoc.org but with no result. Below is my code: /** * Get…
KInGcC
  • 372
  • 1
  • 2
  • 9
12
votes
1 answer

jsdoc - Reuse docs for multiple functions?

I have a function with a huge list of options: /** * Show dialog in a blocking manner. * * @param {object} opts * @param {string} opts.msg "Body" of the dialog. * @param {number} opts.timeout Seconds - floating point values are rounded.…
AndyO
  • 1,512
  • 20
  • 28
12
votes
3 answers

JSDoc: reference @param of method in another @param

I am new to using JSDocs and couldn't find an answer to this question. Suppose I wanted to write this simple function: function hasQ(array, item) {return array.includes(item);} which with JSDoc's I would mark-up like: /** * Another way to call…
SumNeuron
  • 4,850
  • 5
  • 39
  • 107
12
votes
3 answers

Can JS Doc generate PDF

I am using JS Doc version 3 (https://github.com/jsdoc3/jsdoc). When I run the tool, by default it generates documentation in HTML format. Is it possible to generate doc in PDF format?
Sai
  • 2,089
  • 3
  • 19
  • 30
12
votes
2 answers

Describing an array of objects in JSDoc

I've got a function which takes an array of objects. Looks like this. myAwesomeFunction([ { name: 'someName', next: false, test: 'test' }, { name: 'nameTwo', next: true } ]); So far my JSDoc…
Per Pettersen
  • 131
  • 1
  • 4
12
votes
1 answer

How to display Javascript methods in a 'group' in JSDOC?

Is there are possibility to 'group' functions within a class (AMD/RequireJS Module) ? My classes have sometimes over 20+ functions which actually belong to a specific 'interface implementation' and sometimes they just need to be grouped for better…
xamiro
  • 1,391
  • 1
  • 16
  • 32
12
votes
1 answer

The error message "There are no input files to process" from jsdoc

Jsdoc is installed locally ( npm install jsdoc ). I get the following error while trying to execute .\node_modules.bin\jsdoc --debug ./lib/JavaScriptSource.js Output: DEBUG: JSDoc 3.3.0-dev (Sun, 15 Jun 2014 18:39:52 GMT) …
TDreama
  • 420
  • 3
  • 8
12
votes
3 answers

jsDoc - how to specify array length

In jsDoc I can specify my array parameters and members like this: /** * @constructor * @param {Array.} myArray */ function someFunction( myArray ){ this.firstArray = myArray; /** @member {Array.} */ this.secondArray =…
Wilt
  • 41,477
  • 12
  • 152
  • 203
12
votes
1 answer

JSDoc preserve order of comments in output

I have a JavaScript object, that introduces some public methods and I want to use JSDoc to document them. In the source file I have these functions grouped and ordered in a reasonable order, but after generating JSDoc I receive all of them in an …
Anton Vernigor
  • 497
  • 1
  • 4
  • 11
11
votes
4 answers

Google Closure Compiler 100% typed

How can I get my application to be 100% typed in regard to google closure compiler? I already tagged everything with jsdoc comments. Is it even possible to get 100? I'm at 64,6%
Sven Hecht
  • 1,337
  • 1
  • 16
  • 23