In C#, I comment methods like this:
/// <summary>
/// Does absolutely nothing
/// </summary>
/// <param name="a">First useless parameter</param>
/// <param name="b">Second useless parameter</param>
/// <returns>zero</returns>
public int Foo(int a, int b)
{
return 0;
}
Which gives very nice IntelliSense hint window:
What, if any, is the equivalent in Visual C++ or (even better) a solution that would work in other IDEs like XCode or Eclipse?
Update
I found this similar question, but @edtheprogrammerguy's answer has good references so I'll leave the questino here here. Also, SO won't let me delete my question.
Update the Second
A lot of the C# XML comments (<summary>
, for instance) work out of the box. It'd be nice if the ///
comment automatically inserted the required summary
, param
and returns
tags, but I imagine that it'd be pretty easy to implement with a new code snippet.
Update the third
Here's a code snippet that inserts the header. It doesn't scan the method parameter list, but it's a nice start. Save to Documents\Visual Studio 2012\Code Snippets\Visual C++\My Code Snippets
as anything with a .snippet
extension, restart VS, and activate by typing summ
+ TAB above a method.
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
<Title>SnippetFile1</Title>
<Author>dlively</Author>
<Description>Insert a summary/param/return header for a method</Description>
<HelpUrl>
</HelpUrl>
<Shortcut>summ</Shortcut>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>summary_text</ID>
<ToolTip>summary_text</ToolTip>
<Default>Insert description of method</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>returns_text</ID>
<ToolTip>returns_text</ToolTip>
<Default>Description of return value</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>parameter_name</ID>
<ToolTip>parameter_name</ToolTip>
<Default>Name of the parameter</Default>
<Function>
</Function>
</Literal>
<Literal Editable="true">
<ID>parameter_description</ID>
<ToolTip>parameter_description</ToolTip>
<Default>Description</Default>
<Function>
</Function>
</Literal>
</Declarations>
<Code Language="cpp" Kind="method decl"><![CDATA[/// <summary>
/// $summary_text$
/// </summary>
/// <param name="$parameter_name$">$parameter_description$</param>
/// <returns>$returns_text$</returns>]]></Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Also, see the very nice Code Snippet Designer VS extension which makes creating these a breeze.
IntelliSense is a code-completion aid that includes a number of features: List Members, Parameter Info, Quick Info, and Complete Word. These features help you to learn more about the code you're using, keep track of the parameters you're typing, and add calls to properties and methods with only a few keystrokes.
Visual Studio Code IntelliSense is provided for JavaScript, TypeScript, JSON, HTML, CSS, SCSS, and Less out of the box. VS Code supports word based completions for any programming language but can also be configured to have richer IntelliSense by installing a language extension.
You can enable or disable particular IntelliSense features in the Options dialog box, under Text Editor > C/C++ > Advanced. To configure IntelliSense for single files that aren't part of a project, look for the IntelliSense and browsing for non-project files section.
Over time, IntelliSense determines which variable or function the user most likely needs. IntelliSense also displays a short description of a function in the pop-up window—depending on the amount of documentation in the function's source code.
Regarding automatically inserting comment tags by typing ///, I wrote an extension - CppTripleSlash that you might find useful.
It is for producing documentation from the source files. The /doc
compiler option will cause it to generate an .xdc file which can be turned into an .xml documentation file. VC++ is not as nice about Intellisense as C# is.
References:
http://msdn.microsoft.com/en-us/library/ms177227.aspx
http://msdn.microsoft.com/en-us/library/ms173501.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With