我如何记录以使文档适用于类成员而不是匿名类型?

时间:2016-12-10 00:41:15

标签: c++ documentation doxygen documentation-generation

请考虑以下示例。

/// \addtogroup api Foo Group
/// @{

/**
 * This class is well-documented.
 */
struct ThreadContext {
    /// Storage for the ThreadInvocation object that contains the function and
    /// arguments for a new thread.
    struct alignas(CACHE_LINE_SIZE) {
        /// This data is glorious.
        char data[CACHE_LINE_SIZE];
    } threadInvocation;
};
/// @}

当我对此运行doxygen时,我收到以下警告。

Doxygen/Main.h:13: warning: Member threadInvocation (variable) of class ThreadContext is not documented.

Storage for the ...开头的评论应该引用threadInvocation对象,但是doxygen认为它引用的是匿名struct

如何告诉doxygen我希望文档引用threadInvocation成员?

1 个答案:

答案 0 :(得分:3)

在深入了解doxygen documentation之后,我发现doxygen实际上几乎可以在任何地方记录大多数代码。为了记录threadInvocation并避免不记录匿名struct的警告,我必须编写这样的代码。

/// \addtogroup api Foo Group
/// @{

/**
 * This class is well-documented.
 */
struct ThreadContext {
    /// \var threadInvocation
    /// Storage for the ThreadInvocation object that contains the function and
    /// arguments for a new thread.

    /// \cond SuppressDoxygen
    struct alignas(CACHE_LINE_SIZE) {
        /// This data is glorious.
        char data[CACHE_LINE_SIZE];
    }
    /// \endcond
    threadInvocation;
};
/// @}