Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

293
Visualizações
Is there a convention for specifying the author, date, or source of code in JavaScript?

I would like to specify the sources of foreign functions (for example here from StackOverflow 🤓). Also I would like to add my name, date and website to my own functions.

I can of course just put everything in a comment the way I want. But are there certain conventions I should follow? Maybe even machine readable?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

JSDoc is usually used to specify metadata for javascript code, and can be used to automatically generate documentation. See: https://jsdoc.app/about-getting-started.html

Example:

/**
 * @author Some Guy <example@example.com>
 * @see {@link https://jsdoc.app/tags-description.html} for further information.
 * @description How to use JSDoc to tag javascript.
 */
about 4 years ago · Juan Pablo Isaza Relatório

0

There is no official way to specify this. At least no One True Way.

With that said, the most widely accepted is JSDoc comments. You need to start a block comment with /** (two asterisks) and then you can use the special JSDoc syntax to explain your source with @author and @see:

/**
 * Function that returns a random number
 * @author Jon Skeet
 * @see {@link https://stackoverflow.com/a/11373465}
 * 
 * @param {number} min - minimum bound (inclusive)
 * @param {number} max - maximum bound (inclusive)
 * @return {string} - uniformly distributed integer within the range as a string 
 */
function rand(min, max){
   return (Math.floor(Math.random() * (max - min + 1)) + min).toFixed(0);
}

Maybe even machine readable?

JSDoc is machine readable. There are many tools that consume it. Most notably, many standard JavaScript editors like Visual Studio Code will give you the JSDoc for a function on hover. Screenshot of code editor which shows that the JSDoc comment is shown when hovering over the function.

However, there are other tools that can consume JSDoc or subset of it. They may produce documentation, or perform type checking based on what is specified for @param and @return, or other tasks.

It is also worth noting that you do not need to have any tool in order to use JSDoc. You can write it directly in your source code even if it does not get consumed ever. It can still be read by other humans who would understand it. Even if it is the first time they encounter the documentation style, it is straight-forward enough to be easily understood.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda