我正在编写一个广泛使用元编程的库,并具有诸如
之类的特征/// Doxygen comments...
template<class T>
struct unit_traits<T, typename void_t<
typename T::base_unit_type,
typename T::conversion_ratio,
typename T::pi_exponent_ratio,
typename T::translation_ratio>::type>
{
typedef typename T::base_unit_type base_unit_type; ///< typedef documentation
typedef typename T::conversion_ratio conversion_ratio; ///< typedef documentation
typedef typename T::pi_exponent_ratio pi_exponent_ratio; ///< typedef documentation
typedef typename T::translation_ratio translation_ratio; ///< typedef documentation
};
然而,专门化只是一个实现细节(还有其他地方专门化用于结束递归等),并且它使doxygen输出变得混乱,因为库用户只需要知道unit_traits<someType>::...
是可用的。有没有办法隐藏文档中的特化参数,最好不要创建虚拟文档目标?
更新
为了清楚起见,我尝试了以下内容,并且他们没有隐藏专业化:
template<class T>
struct unit_traits
/** @cond */
<T, typename void_t<
typename T::base_unit_type,
typename T::conversion_ratio,
typename T::pi_exponent_ratio,
typename T::translation_ratio>::type>
/** @endcond */
{
typedef typename T::base_unit_type base_unit_type;
typedef typename T::conversion_ratio conversion_ratio;
typedef typename T::pi_exponent_ratio pi_exponent_ratio;
typedef typename T::translation_ratio translation_ratio;
};
和
template<class T>
struct unit_traits
#ifndef DOXYGEN_SHOULD_SKIP_THIS
<T, typename void_t<
typename T::base_unit_type,
typename T::conversion_ratio,
typename T::pi_exponent_ratio,
typename T::translation_ratio>::type>
#endif
{
typedef typename T::base_unit_type base_unit_type;
typedef typename T::conversion_ratio conversion_ratio;
typedef typename T::pi_exponent_ratio pi_exponent_ratio;
typedef typename T::translation_ratio translation_ratio;
};
答案 0 :(得分:1)
根据doxygen FAQ,您可以使用预处理器基本上让doxygen看到您的代码的不同版本(这是一个好主意还是不是一个单独的问题)。
所以,大概你可以这样做:
/** Doxygen doc for general-form unit_traits. */
template<typename General>
class unit_traits;
现在,你可以像这样愚弄doxygen(再次告诫):
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Code actually being built.
template<>
class unit_traits<int>
#else // DOXYGEN_SHOULD_SKIP_THIS
/** Doxygen comment for the int case. */
class unit_traits
#endif // DOXYGEN_SHOULD_SKIP_THIS
{
....
};
你的编译器可以正常使用它。关于doxygen,它既可以工作也可以不工作 - 因为它不是真正有效的C ++代码而不是unit_traits
这两个模板,doxygen会不会买或不买,即使它有,下一个版本可能不
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Code actually being built.
template<>
class unit_traits<int>
#else // DOXYGEN_SHOULD_SKIP_THIS
/** Doxygen comment for the int case. */
class int_unit_traits
#endif // DOXYGEN_SHOULD_SKIP_THIS
{
...
};
由于两个预处理器路径都是有效的C ++(好吧,有点),你的编译器和 doxygen应该很高兴。
<强>买者强>
就我个人而言,我认为你正在努力愚弄&#34; doxygen表明存在概念问题。重度模板化的C ++是边缘无法记录的,而且doxygen在这方面做得比我在百万年里做得更好,但它仍然存在问题。
在类似的情况下,我通常只将一般案例和专业化的所有文档放在一般案例的doxygen评论中。我让doxygen忽略了特化(使用预处理器),并且只是对每个说文档都是一般情况的非doxygen注释。不可否认,这也很糟糕: - )