如何在Doxygen的示例中保留注释

3

我有一个简单的方法以及一个注释,我想在我的doxygen主页中使用它作为示例:

\code

    void showNum(int numToDisplay){

        // This is just a method to display a value.
        std::cout<<"Displaying Number "<<numToDisplay<<std::endl;
    }

\endcode

当生成文档时,主页将正确显示代码示例,但注释将位于主页左侧边缘。我该使用什么字符来强制注释保持对齐并显示?
感谢您的帮助。
1个回答

1

如果没有更多的信息,诊断这个问题将会很困难,但是有几件事情需要检查:

  • 确保你的代码前面有一个空行。
  • 确保你的缩进有四个空格。
  • 确保你注释前面的空格不是制表符。

听起来好像你的代码没有被解释为代码块(因为上述原因之一)。如果你能发布至少包含代码块的文件的一部分,可能会有所帮助。

这里有一个小例子,看起来可以做到你想要的:

/**
 * @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;
}

只需将{.cpp}放入我的代码标记中,问题就得到解决了。谁能想到呢?谢谢。 - Miek

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接