13

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.

5
  • 3
    How do you expect it to know that a and b are strings? Also, how can you tell what it returns? 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). 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? 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... 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". Commented Sep 19, 2012 at 7:08

2 Answers 2

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:

enter image description here

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.

Sign up to request clarification or add additional context in comments.

9 Comments

VS 2012 version is also available here.
The latter version (for VS2012,VS2013, VS2014) only works with Visual Studio Pro not Visual Studio Express :(
@WetNoodles, with access to extensions, Typescript and Apache Cordoba support it looks promising. Will try tonight.
@DimitryK okay yes, I just confirmed that this works. Community is essentially the next version of Express.
|
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.