2016-08-26 159 views
3

我在翻译我的C++库并使用Doxygen编写了一个很好的文档。假设我声明了类型:Doxygen中返回值的默认描述

typedef enum { 
    NO_ERROR,    ///< Everything fine. 
    SOME_REALLY_BAD_ERROR, ///< Something went wrong. 
    VERY_INFREQUENT_ERROR ///< Used only in some cases. 
} ReturnType; 

并将其用作返回值以标记函数中可能的错误。现在,我定义一个函数:

/** Very important description 
* 
* @return NO_ERROR on proper exit, SOME_REALLY_BAD_ERROR otherwise. 
*/ 
ReturnType ImportantFunction(); 

所以每函数定义我必须粘贴默认返回值的描述相同(但有时我会回到VERY_INFREQUENT_ERROR和写入不同的描述)。所以我的问题是:

Doxygen有没有办法创建返回值的默认描述,或者我应该创建一个罕见情况的描述?

回答

2

AFAIK您无法创建默认说明。你可以做的是使用\copydoc至少写你texte只有一次:

/** 
* \class common_ReturnType 
* 
* NO_ERROR on proper exit, SOME_REALLY_BAD_ERROR otherwise. 
*/ 

/** Very important description 
* 
* @return \copydoc common_ReturnType 
*/ 
ReturnType ImportantFunction(); 

/** Very important description with very infrequent result 
* 
* @return \copydoc common_ReturnType In very infrequent cases, VERY_INFREQUENT_ERROR. 
*/ 
ReturnType ImportantFunctionWithInfrequentResult(); 

,这将产生你的文档中为common_ReturnType虚拟条目。您可以在配置文件中使用EXCLUDE_SYMBOLS = common_*将其从输出中排除。

+2

前几天我推。在我看来,这种类型的问题的一个可能的解决方案,以github“引入命令includedoc和snippetdoc”拉请求503.使用\ snippetdoc这应该是可能的, – albert

+0

我想这将是足够的,因为我可以然后创建一个好'ReturnType'的文档。 – SzymonPajzert

1

您可以用确切的说回文档定义别名命令:

ALIASES += "[email protected] NO_ERROR on proper exit, SOME_REALLY_BAD_ERROR otherwise." 

然后你可以使用快捷键:

/** 
* @return_noerr 
*/ 
+0

不错的主意,但我担心这意味着每次我想修改类型文档时都会修改通用配置文件。既然它可以发生在类型本身的每一个变化,我更喜欢基于代码的解决方案。 – SzymonPajzert