Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a convention on how to document a JavaScript file with comments? Like function signatures, examples, etc

Java has Javadoc, Python has docstring. Is there something similar in JavaScript?

like image 783
runw Avatar asked Aug 30 '13 09:08

runw


People also ask

Is there Javadoc for JavaScript?

JSDoc 3 is an API documentation generator for JavaScript, similar to Javadoc or phpDocumentor. You add documentation comments directly to your source code, right alongside the code itself.

How do you comment a function in JavaScript?

Usually, most developers use /* and */ syntax to write multi-line block comments. But the standard way to use block comments in JavaScript is to; Start with /** in a blank line. End with */ at the end line.

Are there Docstrings in JavaScript?

But that's where I was wrong — Javascript has docstrings (or its equivalent) and they're the tooltips that I love in VSCode. These guides are wonderful because they articulate the contract that you are agreeing to when you use the method or ask about the property.


1 Answers

The most commonly used is JsDoc (https://jsdoc.app/).

This is also a tool that generates documentation from your sources, commented with JsDoc style: https://github.com/jsdoc3/jsdoc

like image 88
Tibos Avatar answered Sep 21 '22 19:09

Tibos