最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Comment javascript methods in Visual Studio - Stack Overflow

programmeradmin2浏览0评论

Is there a way to insert a snippet for XML comments in javascript in Visual Studio 2010 with automatically generated parameters?

If I type /// here...

function foo(a, b){

...it should change to this (depending on the parameters):

function foo(a, b){
    /// <summary>$cursorhere</summary>
    /// <param name="a" type="string">Param a</param>
    /// <param name="b" type="string">Param b</param>
    /// <returns type="function">Return function</returns>

So it would be similar to the snippet generation if I'm in C# code.

EDIT

To clarify, I just want to know if there is a shortcut or existing plugin to achieve the functionality mentioned above approximately.

Is there a way to insert a snippet for XML comments in javascript in Visual Studio 2010 with automatically generated parameters?

If I type /// here...

function foo(a, b){

...it should change to this (depending on the parameters):

function foo(a, b){
    /// <summary>$cursorhere</summary>
    /// <param name="a" type="string">Param a</param>
    /// <param name="b" type="string">Param b</param>
    /// <returns type="function">Return function</returns>

So it would be similar to the snippet generation if I'm in C# code.

EDIT

To clarify, I just want to know if there is a shortcut or existing plugin to achieve the functionality mentioned above approximately.

Share Improve this question edited Sep 19, 2012 at 13:16 Marc asked Sep 19, 2012 at 6:05 MarcMarc 6,7719 gold badges50 silver badges79 bronze badges 5
  • 3 How do you expect it to know that a and b are strings? Also, how can you tell what it returns? – Korvin Szanto Commented Sep 19, 2012 at 6:08
  • Yep, I don't know that, thats right. But I would use these parameters as default. And VS could determine the object types by existing function calls in the project, but thats just an idea. The main thing I want to achieve is to just type some letters and the summary gets created (with the amount of parameters). – Marc Commented Sep 19, 2012 at 6:16
  • There is a way I'm sure, Visual Studio 2010 supports plugins, what have you tried? Have you looked at this: msdn.microsoft.com/en-us/library/ms165392.aspx? – Korvin Szanto Commented Sep 19, 2012 at 6:20
  • 1 "And VS could determine the object types by existing function calls in the project" - Or possibly it could guess, since the same function could be called with different types... – nnnnnn Commented Sep 19, 2012 at 6:23
  • He guys, thanks for your time, I was just looking for a easy way to add javascript comments similar to C# comments, I don't want to write an own plugin for that and of course it has to guess the variable type if there is more then one function call, but that is not necessary at all. And what have I tried? Just googling, couldn't find anything. I hoped to get an answer here like "just press A, B then C" or "it's not possible". – Marc Commented Sep 19, 2012 at 7:08
Add a comment  | 

2 Answers 2

Reset to default 23

You can make a code snippet, but that seems too much trouble to me. I use JScript vsdoc Stub Generator, it generates XML comments like these ones:

This extension's goal is to provide a simple way to add vsdocs to JavaScript that acts similar to other XML comments provided by Visual Studio. A comment stub is created when a triple-slash ("///") is added on a new line.

I think you're looking for JS intellisense comments and references, described here:

http://msdn.microsoft.com/en-us/library/bb514138.aspx

Basically it's very similar to what you expected.

UPDATE: sorry, didn't read your question properly. Snippets are trivial to make for yourself, it's not even a plugin really, just an xml file you add to your file system. You can use the snippet editor: http://snippeteditor.codeplex.com/ to make it even easier.

发布评论

评论列表(0)

  1. 暂无评论