当前位置:编程学习 > C/C++ >>

Doxygen按原始注释输出(保留空格和换行)

在Doxygen注释中,我们经常需要用空格加上符号来描述一种结构图,但是因为Doxygen默认忽略空格和换行,因此导致输出的结果不是我们想要的。假定我们想输出如下的注释:

[cpp] 
/**
*                        JOIN (exists (select 1 from x3 where x1.id3 = x3.id3)  
*                       /        \                                                        
*                      r1         x1                                                        
*/   

因为Doxygen忽略空格和换行,因此输出到html以后,就变成了下面的样子:

[cpp] 
JOIN(preserve) (exists (select 1 from x3 where x1.id3 = x3.id3) / \ r1 x1  

如果需要按原始格式输出,有两种方法:
1. 用html标签<pre>

[cpp] 
/**
 * <pre>
 *                        JOIN (exists (select 1 from x3 where x1.id3 = x3.id3)  
 *                       /        \                                                        
 *                      r1         x1                                                        
 * </pre>
 */   

这样输出就成了

[cpp] 
  JOIN(preserve) (exists (select 1 from x3 where x1.id3 = x3.id3)   
 /        \                                                         
r1         x1          

2. 用Doxygen的标签verbatim和endverbatim

[cpp] 
/**
 * @verbatim
 *                        JOIN (exists (select 1 from x3 where x1.id3 = x3.id3)  
 *                       /        \                                                        
 *                      r1         x1                                                        
 * @endverbatim
 */   

输出如下

[cpp] 
  JOIN(preserve) (exists (select 1 from x3 where x1.id3 = x3.id3)   
 /        \                                                         
r1         x1       

<pre>标签和verbatim的区别。
1. <pre>是html的标签,verbatim是Doxygen自己的标签。
2. <pre>不会影响Doxygen自身的标签,例如<pre>标签中有Doxygen标签@ref等,@ref仍然会指向参考。
3. verbatim标签是真正的逐字输出,因此@verbatim和@endverbatim之间的所有Doxygen标签都会失效。

补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,