Javascript code documentation standard and automatic documentation generation on Ides and exportable

Asked

Viewed 4,824 times

9

Java has the Javadoc, PHP has Phpdoc and other languages, has documentation standards. Which standard most used to document javascript, already integrated with Ides, so that when using functions, it auto-completes the code and there is a way to generate automatic documentation based solely on code documentation?

How to view documentation from third-party libraries, such as jQuery?

1 answer

15


To document Javascript, I recommend the use of the pad described in Jsdoc, whose page with explanatory documentation is http://usejsdoc.org/. In addition to telling in detail a pattern that Ides like Netbeans and Eclipse understand, Jsdoc also has a command-line tool that reads your code and converts it into a ready-to-use HTML manual.

As a quick example, look at the code below

/**
 * Esta é uma função de exemplo de uso de JSDoc
 * 
 * @example 
 *   exemplo(3, 5); // 8
 * 
 * @param   {Number} obrigatorio   Parametro obrigatório
 * @param   {Number} [opcional]    Parametro ocional. Note os '[ ]'
 * @returns {Number}
 */
function exemplo (obrigatorio, opcional) {
    var resultado = 0;
    resultado = obrigatorio + (opcional || 0);
    return resultado;
}

For Netbeans IDE 7.4, using the function will generate the following

inserir a descrição da imagem aqui

In the case of Netbeans and other Ides, see how to add your favorite library, for example jQuery, to a path where there is its documented file so that your IDE displays context documentations. That way you’ll need to see much less Google for something that’s already explained during use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.