I'm programming in C++ using Visual Studio 2010 Ultimate. I want to document some functions and I want the documentation to show up in Intellisense.
我正在使用Visual Studio 2010 Ultimate使用c++编程。我想要记录一些函数,我想要文档显示在Intellisense中。
According to MSDN, I just need to put the comment before the declaration or after it on the same line. So I tried this:
根据MSDN,我只需要将注释放在声明之前或声明之后的同一行。所以我试着:
// This is a test.
void foo();
void bar() { foo(); }
When moving my mouse over foo()
, the comment doesn't appear in the tooltip. I also tried:
在foo()上移动鼠标时,注释不会出现在工具提示中。我也试过:
///
<summary></summary>
tags/doc
(by setting the "Generate XML documentation files" option in the project settings)I've had no luck so far. Does anyone know a way to make this work?
到目前为止我运气不佳。有人知道怎么做这个工作吗?
13
This now supported in VS 2012!
这个现在支持VS 2012!
Previously, XML tags in the comments were only read in by C++/CLI, not plain old C++. VS 2012 now brings at least some of this into regular C++ - it is in the What's New in Visual Studio 2012 and in the MSDN docs: XML Documentation (Visual C++).
以前,注释中的XML标记仅由c++ /CLI读取,而不是普通的老c++。VS 2012现在至少在常规c++中引入了一些这方面的内容——在Visual Studio 2012和MSDN文档(Visual c++)中都有新的内容:XML文档(Visual c++)。
I've tested it with my own application in 2012 ultimate, and I can confirm that the summary, para, and seealso tags are all pulled out an formatted for tooltips.
我在2012年的ultimate中使用了我自己的应用程序对它进行了测试,我可以确认摘要、para和seealso标记都是为工具提示而设计的。
7
Try installing Visual Assist and using doxigen style:
尝试安装Visual Assist和doxigen风格:
/**
* COMENT OF A CLASS
**/
class Foo
{
public:
/**
* \brief A foo method.
*
* More complete description of foo.
*
* \param i A foo parameter.
* \return An int
*
**/
int fooMethod(int i);
private:
int i; /*!< COMENT OF A MEMBER */
};
6
I'm not sure which version of Visual Studio introduced that but in VS 2015 you can simply put comment above a function
, method
, class
, struct
, union
, enum class
, namespace
or even individual variables (locals too) and it will be shown by Intellisense. If you want to document something from a different module, you have to write a comment in the header file. Examples:
我不确定是哪个版本的Visual Studio引入的,但是在VS 2015中,你可以将注释放在函数、方法、类、结构体、union、enum类、名称空间甚至单个变量(也包括局部变量)之上,它将通过Intellisense显示。如果您想要记录来自不同模块的内容,您必须在头文件中编写注释。例子:
3
I haven't used VS2010 is too many years to remember whether this worked there or not. But what I have done for years in many different version of VS is ...:
我还没用过VS2010,它在那里用了多少年都记不起来了。但是我多年来在不同版本的VS中所做的是……
#pragma region foo(float)
/// <summary> .... </summary>
/// <param name="bar"> .... </param>
/// <returns> .... </returns>
int foo(float bar)
{
// stuff
}
#pragma endregion
In other words, manually putting in exactly what Visual Studio will automagically put in for C# code for you.
换句话说,手动输入Visual Studio为您自动输入c#代码的内容。
Then give the Intellisense engine a minute or so to reparse the file. Doing a build will force it to reparse, of course.
然后给Intellisense引擎一分钟左右来重新解析文件。当然,进行构建将迫使它重新解析。
As I recall, this works in the most recent VS2010 Express Community, but I don't recall whether it worked in VS2010 Ultimate.
我记得,这在最近的VS2010 Express社区中行得通,但我不记得它在VS2010 Ultimate中是否行得通。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2011/12/23/7e8e001f6069647b6dfc0a60de93a013.html。