【问题标题】:Yuidoc-style comments in Ruby?Ruby 中的 Yuidoc 风格的注释?
【发布时间】:2013-05-23 14:51:58
【问题描述】:

如何在 Ruby 中使用 YUIDoc cmets?我能想到的最好的是:

  ##*
  # Get Query history
  # @type {Array} Past search query objects
  # @param {int} limit The number of objects to return. Defaults to 10. (Max 100).
  # @param {boolean} only_visible limit the search to visible items. Defaults to true.
  #

还有这个:

  #/**
  # * Get Query history
  # * @type {Array} Past search query objects
  # * @param {int} limit The number of objects to return. Defaults to 10. (Max 100).
  # * @param {boolean} only_visible limit the search to visible items. Defaults to true.
  # */

【问题讨论】:

    标签: ruby documentation yuidoc


    【解决方案1】:

    您必须在 Ruby 多行注释中嵌入 YUIDoc cmets,如下所示:

    =begin
    /**
    * Get Query history
    * @type {Array} Past search query objects
    * @param {int} limit The number of objects to return. Defaults to 10. (Max 100).
    * @param {boolean} only_visible limit the search to visible items. Defaults to true.
    */
    =end
    

    begin 和end 之前的= 字符必须在该行的第一列。

    【讨论】:

    • 有趣。这被认为是好的风格吗?请让我声明,我是一名 JavaScript 开发人员,几乎没有 Rails 经验。它几乎看起来像一个 CDATA 块或其他东西。顺便说一句.. =begin 和 =end 实际上是做什么的??
    • @AlexKessaris =begin 和 =end 是多行 cmets 的分隔符,类似于 JavaScript 中的 /* 和 */。它们在 Ruby 代码中并不常见,但在这种情况下,它们是唯一的选择。
    • 酷!感谢您在这件事上的帮助。顺便说一句,我很想知道在 Ruby 中评论的更多选项。我会在网上查一下,但也非常欢迎您的想法!
    • 最后我猜这个问题的结果是采用 YARD-style cmets。非常感谢您的帮助@toro2k
    猜你喜欢
    • 1970-01-01
    • 2010-12-17
    • 2010-10-26
    • 1970-01-01
    • 2011-02-02
    • 1970-01-01
    • 2018-09-06
    • 2018-10-05
    • 1970-01-01
    相关资源
    最近更新 更多