0

Is there a way to generatate parameter information (jsdoc style) based on function implementation?

/**
 * Assign the project to a list of employees.
 * @param {Object[]} employees - The employees who are responsible for the project.
 * @param {string} employees[].name - The name of an employee.
 * @param {string} employees[].department - The employee's department.
 */

I'll give you a for instance in a another editor. In Microsoft Visual Studio you can type /// above a function and it will automatically stub out xml comments for you.

  /// <summary>
  /// 
  /// </summary>
  /// <param name="input1"></param>
  /// <param name="input2"></param>
  /// <returns></returns>
  public static decimal Add(string input1, string input2)
Rod
  • 14,529
  • 31
  • 118
  • 230
  • AFAIK jsdoc style is similar to Javadoc, what exactly you want to do? The documentation comments usually depends to the IDE/editor feature. – Tetsuya Yamamoto Oct 13 '17 at 04:18
  • Is there a way to do this in Visual Studio or VS Code? – Rod Oct 13 '17 at 04:19
  • You can read Intellisense support for JSDoc here: https://msdn.microsoft.com/en-us/library/mt162307.aspx. The tag names are similar to C# docs but started with `@`. – Tetsuya Yamamoto Oct 13 '17 at 04:22
  • Does this answer your question? [Is there a way to generate JSDoc comments in Visual Studio Code](https://stackoverflow.com/questions/34220564/is-there-a-way-to-generate-jsdoc-comments-in-visual-studio-code) – Michael Freidgeim Jun 01 '20 at 21:50

2 Answers2

0

There are editor plugins like docthis (for Visual Studio Code) that can do this for you, but because JavaScript is dynamically typed, it's never going to be as good as what you'll get for C#. That same extension will also work on TypeScript files, where you'll have much more luck and get more precise definitions (and if you haven't used it, as a C# developer you'll probably enjoy TypeScript). It can be a nice approach to write in TypeScript, auto-generate JSDoc comments with good type information, and then compile to JavaScript while keeping those comments intact.

(EDIT: I assume you wanted the editor to automatically infer and write out the parameter types for you. If you're okay with it just creating boilerplate with the names but nothing else, VS Code supports this out of the box by just typing /** and pressing Tab, and other editors would surely have the same functionality behind a plugin.)

Ryan Plant
  • 1,037
  • 1
  • 11
  • 18
0

In most of the editor backslash(/) followed by two stars(**) & enter/return will generate the function information.

But before that the function need to be defined with parameters

JSDOC can help in documenting javascript.It works with both intellij & visual studio. For visual studio code , the plugin can be available from here

For sublime text DocBlockr is a helpful package

Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
brk
  • 48,835
  • 10
  • 56
  • 78