我终于放弃了微软的XML文档格式所施加的尖括号税(而且毫无意义,因为MSVC环境对C++项目仍然不会有任何花哨的处理),并将我的当前项目切换到使用Doxygen和Javadoc风格的语法。
这太棒了。内联文档更易读、易打,生成的输出更有用、更灵活。特别是,我已经打开了MULTILINE_CPP_IS_BRIEF
选项,这允许我编写尽可能长的“简要”描述,然后使用空行将我的“详细”文档分成段落。换句话说:
/// Changes the active viewing area of the currently selected region.
///
/// The modification is merely enqueued. This function has no effect until the
/// FlushRegion() function is called.
///
/// Newly-exposed regions will not be repainted automatically. The user must also
/// call the UpdateRegion() function on these regions to cause their contents to
/// be redrawn.
///
/// @param dx The amount, in pixels, to shift the visible region horizontally.
/// @param dy The amount, in pixels, to shift the visible region vertically.
///
/// @remarks
/// Note that this function is reentrant, but not thread-safe!
void ScrollRegion(int dx, int dy);
这样做可以让我得到我想要的输出,同时减少了我需要使用的嘈杂元命令数量,例如
@brief
和\details
。
问题出现在当我尝试像隐含的“details”部分一样,在我的“remarks”部分中包含第二段时。 例如:/// Changes the active viewing area of the currently selected region.
///
/// The modification is merely enqueued. This function has no effect until the
/// FlushRegion() function is called.
///
/// Newly-exposed regions will not be repainted automatically. The user must also
/// call the UpdateRegion() function on these regions to cause their contents to
/// be redrawn.
///
/// @param dx The amount, in pixels, to shift the visible region horizontally.
/// @param dy The amount, in pixels, to shift the visible region vertically.
///
/// @remarks
/// Note that this function is reentrant, but not thread-safe!
///
/// If thread safety is required, the user must handle locking and unlocking
/// the region manually.
void ScrollRegion(int dx, int dy);
生成的输出未将@remarks部分中的第二段解释为备注的一部分。我可以看出,因为它在HTML输出中没有与同一级别缩进,并且不在XML输出中的标签下方。
我尝试在第二段开头添加a @par命令,但是那也没有达到我想要的效果。新段落仍然不是“remarks”部分的子元素。在XML输出中,它被放置在一个新的标签内,该标签是原始标签的同级。
在研究此问题时,我看到有人重复使用了@remarks命令:
/// Changes the active viewing area of the currently selected region.
///
/// The modification is merely enqueued. This function has no effect until the
/// FlushRegion() function is called.
///
/// Newly-exposed regions will not be repainted automatically. The user must also
/// call the UpdateRegion() function on these regions to cause their contents to
/// be redrawn.
///
/// @param dx The amount, in pixels, to shift the visible region horizontally.
/// @param dy The amount, in pixels, to shift the visible region vertically.
///
/// @remarks
/// Note that this function is reentrant, but not thread-safe!
/// @remarks
/// If thread safety is required, the user must handle locking and unlocking
/// the region manually.
void ScrollRegion(int dx, int dy);
那确实产生了我想要的输出。两个段落都嵌套在XML输出中
<simplesect kind="remark">
标签下的<para>
标签中,并且在HTML输出中视觉关系是正确的。但这看起来很丑,像是一个错误。
我是否遗漏了一种标准方法? 我肯定不是第一个想在文档的"remarks"部分中有多个段落的人...这不仅限于@remarks
;例如,使用@internal
时也会发生同样的事情。我安装了最新版本的Doxygen(1.8.2),但我非常怀疑这与版本有关。
\remark
命令将被合并成一个段落。这不是我想要的。我想要独立的段落。但接下来的句子确实说“每个备注都会在新行上开始”,所以这可能只是文档错误。它应该说“块”或“节”,而不是“段落”。知道这是官方解决方案很好,尽管我仍然认为它看起来像一个错误。 - Cody Gray\remark
而不是\remarks
会更少引起混淆。如果你不喜欢文档的样子,我建议完全放弃\remarks
或将两个备注合并成一个:即\remark请注意,此函数是可重入的,但不是线程安全的!如果需要线程安全,则用户必须手动处理锁定和解锁区域。
- Chris