为什么在 doxygen 行注释之后的常规注释看起来像预处理器代码?
Why regular comments after doxygen line comments looks like preprocessor code?
我在任何地方都找不到这个,所以...
这是我第一次尝试 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="comment">
时使用 <span class="preprocessor">
。
正如我所见,它发生在 /**< */
条评论之后。
但是如何解决这个问题?
我用 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)
我在任何地方都找不到这个,所以...
这是我第一次尝试 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="comment">
时使用 <span class="preprocessor">
。
正如我所见,它发生在 /**< */
条评论之后。
但是如何解决这个问题?
我用 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)