简体   繁体   English

从JSDoc注释生成函数定义(反之亦然)

[英]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: 最好在Sublime Text或Webstorm中键入JSDoc样式的注释,如下所示:

/**
 * 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. 反之亦然,我只是在寻找一种节省额外击键次数的方法。

It would appear that sublime-jsdocs is just what you're looking for for ST2. 看起来sublime-jsdocs正是您在ST2中寻找的东西。 Scroll down a bit and you'll even see animated GIFs demonstrating automatic documentation creation from function definitions. 向下滚动一下,您甚至会看到动画GIF,这些GIF演示了根据函数定义自动创建文档。 It can be installed via Package Control . 可以通过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 :) 我没有使用Webstorm,但是快速的Google搜索似乎表明JSDoc功能已经内置 ,尽管它看起来不像Sublime那样漂亮,后者具有大量的配置选项,更加灵活,并且没有不需要运行a肿的IDE :)

sublime-jsdocs is what u need. sublime-jsdocs是您需要的。 Use this link to install it in sublime through Package Control 使用链接通过Package Control将其安装在Sublime中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM