Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto generate function documentation in Visual Studio

I was wondering if there is a way (hopefully keyboard shortcut) to create auto generate function headers in visual studio.

Example:

Private Function Foo(ByVal param1 As String, ByVal param2 As Integer) 

And it would automagically become something like this...


'----------------------------------  'Pre:  'Post: 'Author:  'Date:  'Param1 (String):  'Param2 (Integer):  'Summary:  Private Function Foo(ByVal param1 As String, ByVal param2 As Integer) 
like image 408
Ryan M Avatar asked Jan 09 '09 19:01

Ryan M


People also ask

How do you create a document in Visual Studio?

You can generate the XML documentation file using either the command-line compiler or through the Visual Studio interface. If you are compiling with the command-line compiler, use options /doc or /doc+. That will generate an XML file by the same name and in the same path as the assembly.

How do I create a summary in Visual Studio?

Type in /// before your method, property, etc. VS will generate the comment blocks automatically. Pedantism: Visual Studio will automatically generate these comment blocks.


2 Answers

Make that "three single comment-markers"

In C# it's ///

which as default spits out:

/// <summary> ///  /// </summary> /// <returns></returns> 

Here's some tips on editing VS templates.

like image 191
Michael Paulukonis Avatar answered Sep 19 '22 13:09

Michael Paulukonis


GhostDoc!

Right-click on the function, select "Document this" and

private bool FindTheFoo(int numberOfFoos) 

becomes

/// <summary> /// Finds the foo. /// </summary> /// <param name="numberOfFoos">The number of foos.</param> /// <returns></returns> private bool FindTheFoo(int numberOfFoos) 

(yes, it is all autogenerated).

It has support for C#, VB.NET and C/C++. It is per default mapped to Ctrl+Shift+D.

Remember: you should add information beyond the method signature to the documentation. Don't just stop with the autogenerated documentation. The value of a tool like this is that it automatically generates the documentation that can be extracted from the method signature, so any information you add should be new information.

That being said, I personally prefer when methods are totally selfdocumenting, but sometimes you will have coding-standards that mandate outside documentation, and then a tool like this will save you a lot of braindead typing.

like image 38
Rasmus Faber Avatar answered Sep 18 '22 13:09

Rasmus Faber