我如何在Doxygen中的示例中保留评论
我有一个简单的方法,带有注释,我想在doxygen主页上用作示例:
I have a simple method with a comment I want to use as an example in my doxygen mainpage:
\code
void showNum(int numToDisplay){
// This is just a method to display a value.
std::cout<<"Displaying Number "<<numToDisplay<<std::endl;
}
\endcode
当生成文档时,主页将正确显示代码示例,但注释将一直显示在主页的左边缘。我要使用什么字符来强制注释保持其正当性并显示出来?
When a generate the docs, the mainpage will show the code example correctly but the comment will be all the way to the left edge of the main page. What character(s) do I use to force the comment to maintain its justification and display?
预先感谢您的帮助。
如果没有更多的信息,将很难对此进行诊断,但是要检查几件事:
Without a little more information it's going to be hard to diagnose this but a couple things to check :
- 请确保在代码之前有一个空白行。
- 请确保您有四个空格缩进
- 确保注释前面的空白不是制表符
听起来好像您的代码是不被解释为代码块(由于上述原因之一)。如果您可以在文件的至少一部分中放入代码块,则可能有助于解决问题。
It sounds as if your code is not being interpreted as a code block (because of one of the reasons listed above). If you could post at least part of the file with the code block in it, it might help sort this out.
这里有一个小例子,它似乎可以满足您的要求:
Here's a small example which seems to do what you want:
/**
* @file tmp.cpp
*/
/** Brief description
*
* Long description of what the function does ...
*
* \code{.cpp}
*
* void showNum(int numToDisplay){
*
* // This is just a method to display a value.
* std::cout<<"Displaying Number "<<numToDisplay<<std::endl;
* }
*
* \endcode
*
*/
void showNum(int numToDisplay) {
std::cout << "Displaying Number " << numToDisplay << std::endl;
}