如何在 Doxygen 代码示例中插入多行注释

发布于 2024-12-21 02:16:55 字数 485 浏览 2 评论 0原文

我试图在 Doxygen 文档中包含一个包含多行注释的代码示例。问题是 C++ 预处理器将 */ 解释为我的 Doxygen 注释的结尾,因此文件的语法被破坏。

例如:

/*! \brief My Doxygen comment.
 *
 * \code
 * myFunction() /* Some multi-line comment */
 * \endcode
 */

我已经尝试过适用于 JavaDoc 注释的建议:使用 HTML 实体对斜杠进行编码,如下所示:

* \code
* myFunction() /* Some multi-line comment */
* \endcode

但这不起作用(我猜是因为 Doxygen 不会替换代码部分中的 HTML 实体)。

所以问题是:是否可以在代码示例中包含多行注释以及如何做到?

I am trying to include a code example which contains a multi-line comment in Doxygen documentation. The problem is that the C++ preprocessor interprets the */ as the end of my Doxygen comment and therefore the syntax of the file is broken.

For example:

/*! \brief My Doxygen comment.
 *
 * \code
 * myFunction() /* Some multi-line comment */
 * \endcode
 */

I already tried the suggestion which works for JavaDoc comments: encode the slash using HTML entities like this:

* \code
* myFunction() /* Some multi-line comment */
* \endcode

but this doesn't work (I guess because Doxygen does not replace HTML entities within code sections).

So the question is: is it possible to include multi-line comments in code example and how can it be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

指尖上得阳光 2024-12-28 02:16:55

使用不同的评论风格。

而不是您拥有的内容,请使用:

/// \brief My Doxygen comment.
/// 
/// \code
/// myFunction() /* Some multi-line comment */
/// \endcode
///

////*! 相同,并标记 doxygen 部分。预处理器会将每一行视为单行注释。

Use different comment styles.

Instead of what you have, use:

/// \brief My Doxygen comment.
/// 
/// \code
/// myFunction() /* Some multi-line comment */
/// \endcode
///

The /// is the same as /*! and marks a doxygen portion. The pre-processor will treat each line as a single line comment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文