【问题标题】:Doxygen: how to describe multiple parameters in one line?Doxygen:如何在一行中描述多个参数?
【发布时间】:2021-04-16 15:24:53
【问题描述】:

我有一些函数有很多参数,有时这些参数在本质上非常相似,例如,当将颜色传递给函数时,我有参数“RGB”,我想知道这是否可能,在 doxygen 中,将它们记录在一起。我现在为此做了一些相当广泛的事情:

    /// @param x      Initial cursor position at X axis.
    /// @param y      Initial cursor position at Y axis. 
    /// @param r      Text amount of red color (default: 1.f)
    /// @param g      Text amount of green color (default: 1.f)
    /// @param b      Text amount of blue color (default: 1.f)

我想知道是否可以统一相同性质的参数,例如,有没有办法可以做类似的事情?:

    /// @param x y :   Initial cursor position.
    /// @param r g b : Text color (default: white)

你会推荐什么?

【问题讨论】:

    标签: doxygen


    【解决方案1】:

    我在\param 命令的文档中指出:

    \param '['dir']' { 参数描述 } 开始一个 具有名称的函数参数的参数描述 ,后跟参数的描述。这 检查参数的存在并给出警告,如果 此(或任何其他)参数的文档是否缺失 存在于函数声明或定义中。 \param 命令 有一个可选属性 dir,用于指定 范围。可能的值是“[in]”、“[in,out]”和“[out]”,注意 此描述中的 [方] 括号。当一个参数既是 输入和输出,[in,out] 用作属性。这是一个例子 对于函数 memcpy:

    /*!
    * Copies bytes from a source memory area to a destination memory area,
    * where both areas may not overlap.
    * @param[out] dest The memory area to copy to.
    * @param[in] src The memory area to copy from.
    * @param[in] n The number of bytes to copy
    */ void memcpy(void *dest, const void *src, size_t n);
    

    参数描述是一个没有特殊内部结构的段落。全部 可以在段落内使用视觉增强命令。多种的 相邻的 \param 命令将合并为一个段落。每个 参数描述将在新行开始。 \param 描述 当一个空行或一些其他的分割命令是结束时 遭遇。有关示例,请参见 \fn 部分。请注意,您还可以 使用单个 \param 命令记录多个参数 逗号分隔列表。这是一个例子:

    /** Sets the position.
     * @param x,y,z Coordinates of the position in 3D space.
     */
    void setPosition(double x,double y,double z,double t) { }
    

    请注意,对于 PHP,您还可以指定类型(或类型,如果您将它们分开 带有管道符号)允许用于参数(因为这不是 定义的一部分)。语法与 phpDocumentor,即 @param datatype1|datatype2 $paramname description

    所以在这种情况下:

    /// @param x,y   Initial cursor position.
    /// @param r,g,b Text amount of red, green, blue color (default: 1.f i.e. white)
    

    【讨论】:

    • 非常感谢阿尔伯特!这有很大帮助。我之前实际上尝试过这个,但是我的语法高亮在逗号之后没有拾取任何东西,所以我认为它不起作用。但现在我看到它确实有效。 (ps:我认为最后你从错误使用复数@params的帖子中复制了我的示例,所以我建议你编辑它以防有人偶然发现这篇文章)
    • 哎呀,你是对的,编辑不够。
    猜你喜欢
    • 2012-10-18
    • 1970-01-01
    • 2015-12-10
    • 1970-01-01
    • 2020-07-25
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 2011-03-27
    相关资源
    最近更新 更多