我如何在Doxygen中的示例中保留评论 [英] How do I preserve a comment in an example in Doxygen

查看:53
本文介绍了我如何在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;
}

这篇关于我如何在Doxygen中的示例中保留评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆