W języku C#, ja skomentować metody tak:VC++ Komentarze, dokumentacja i IntelliSense
/// <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;
}
Który daje bardzo ładne okno podpowiedzi IntelliSense:
Co, jeśli w ogóle, jest odpowiednikiem w Visual C++ lub (jeszcze lepiej) rozwiązanie, które działałoby w innych IDE, takich jak XCode czy Eclipse?
Aktualizacja
znalazłem this similar question, ale odpowiedź użytkownika @ edtheprogrammerguy ma dobre referencje więc będę zostawić questino tutaj tutaj. Ponadto SO nie pozwala mi usunąć mojego pytania.
Aktualizacja drugie
Wiele C# XML komentarze (<summary>
, na przykład) działa po wyjęciu z pudełka. Byłoby miło, gdyby komentarz ///
automatycznie wstawił wymagane tagi summary
, param
i returns
, ale wyobrażam sobie, że byłoby to całkiem łatwe do wdrożenia z nowym fragmentem kodu.
Aktualizacja trzeci
Oto fragment kodu, który wstawia nagłówek. Nie skanuje listy parametrów metod, ale jest to dobry początek. Zapisz do Documents\Visual Studio 2012\Code Snippets\Visual C++\My Code Snippets
jak nic z rozszerzeniem .snippet
, uruchom ponownie VS i aktywuj, wpisując summ
+ TAB powyżej metody.
<?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>
Zobacz także bardzo ładne Code Snippet Designer VS rozszerzenie, które umożliwia tworzenie nich pestka.