Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a function definition from a JSDoc comment (or vice-versa)

Is it possible, preferably, in Sublime Text or Webstorm, to type in a JSDoc-style comment, like so:

/**
 * Repeat <tt>str</tt> several times.
 * @param {string} str The string to repeat.
 * @param {number} times How many times to repeat the string.
 * @returns {string}
 */

And generate a function definition like so:

function repeat (str, times) {
    return
}

?

A vice-versa operation is fine too, I'm just looking for a way to save on extra keystrokes.

like image 457
pilau Avatar asked Jun 18 '13 17:06

pilau


2 Answers

It would appear that sublime-jsdocs is just what you're looking for for ST2. Scroll down a bit and you'll even see animated GIFs demonstrating automatic documentation creation from function definitions. It can be installed via Package Control.

I don't use Webstorm, but a quick Google search would seem to indicate that JSDoc functionality is already built-in, although it doesn't look as nifty as Sublime's, which has a bunch of config options, is more flexible, and doesn't require running a bloated IDE :)

like image 192
MattDMo Avatar answered Sep 29 '22 07:09

MattDMo


sublime-jsdocs is what u need. Use this link to install it in sublime through Package Control

like image 31
Shekhar Kumar Avatar answered Sep 29 '22 05:09

Shekhar Kumar