formatting - 为什么 doxygen 行注释之后的常规注释看起来像预处理器代码?
问题描述
我在任何地方都找不到这个,所以...
这是我的第一次 Doxygen 尝试。我有一个 C 代码并使用 Doxygen 生成 HTML 文档。
但是,当我混合块和行注释时,生成的源代码格式不正确。一些注释(不是 doxygen)被呈现为实际注释,一些显示为预处理器行。
这是一个 MWE 源代码:
#ifdef __DEFINES_H_
#define __DEFINES_H_
// this comment looks like a comment
/** error */
#define ERROR -1
// this is also ok
/** This is zero */
#define ZERO 0
// and so is this one
#define FIRST 1 /**< the first */
// but this comment is listed with class="preprocessor"
#define TEN 10 /**< just 10 */
// and this comment also looks like a preprocessor line
/** error */
#define ANOTHER_ERROR -1
// here the comment looks like a comment again
/** This is zero */
#define ANOTHER_ZERO 0
#endif // __DEFINES_H_
该文件的 HTML 源代码如下(抱歉,行长)。
<div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="preprocessor">#define __DEFINES_H_</span></div>
<div class="line"><a name="l00003"></a><span class="lineno"> 3</span>  </div>
<div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment">// this comment looks like a comment</span></div>
<div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"></span><span class="preprocessor">#define ERROR -1</span></div>
<div class="line"><a name="l00007"></a><span class="lineno"> 7</span>  </div>
<div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment">// this is also ok</span></div>
<div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"></span><span class="preprocessor">#define ZERO 0</span></div>
<div class="line"><a name="l00011"></a><span class="lineno"> 11</span>  </div>
<div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment">// and so is this one</span></div>
<div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="preprocessor">#define FIRST 1 </span></div>
<div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="preprocessor">// but this comment is listed with class="preprocessor"</span></div>
<div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="preprocessor">#define TEN 10 </span></div>
<div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">// and this comment also looks like a preprocessor line</span></div>
<div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  </div>
<div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#define ANOTHER_ERROR -1</span></div>
<div class="line"><a name="l00021"></a><span class="lineno"> 21</span>  </div>
<div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="comment">// here the comment looks like a comment again</span></div>
<div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="comment"></span><span class="preprocessor">#define ANOTHER_ZERO 0</span></div>
<div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  </div>
<div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#endif // __DEFINES_H_</span></div>
这就是浏览器显示它的方式。
第 15 行和第 18 行使用<span class="preprocessor">
when should use <span class="comment">
。
正如我所看到的,它发生在/**< */
评论之后。
但是如何解决这个问题?
解决方案
我用 doxygen 1.8.13 版本检查了它,在这里我可以看到所示的问题。使用当前的 1.9.1 版本,问题就消失了。
在 1.8.13 版本中,第 18 行被标记为“预处理器”,而在 1.9.1 版本中,它被标记为“注释”
此错误已在 1.8.13 和 1.9.1 之间修复,因此修复它是升级到新版本。(实际上在 1.9.0 中已修复,但最好不要使用 1.9.0 而使用 1.9.1)。
推荐阅读
- python - Python
.py 不选择修改 .py - python - 调用实例名称时隐式调用方法
- algorithm - 查找丢失条目的地址
- python - 如何在 python 3 中安装 Gurobi?
- tsql - SQL有条件地从行中扣除一些数字
- ios - 带有证书的推送通知到 iOS 错误
- android - Numberpad 的 Android 模拟器键盘输入不再起作用
- python - 如何解决 remove_widget 在 Kivy 的另一个布局中要删除的小部件
- reactjs - 重定向到用户在登录前尝试访问的同一页面 - Reactjs
- mysql - Google API 对 Google Cloud 上的 MySQL 代理的身份验证范围不足