【问题标题】:Document using YARD an instance method's return type that returns instance of class使用 YARD 记录返回类实例的实例方法的返回类型
【发布时间】:2016-06-03 10:36:28
【问题描述】:

我在任何地方都找不到这个,包括 Yard 的文档。

我希望记录实例方法的返回类型。例如,

class Foo
  def initialize
  end
end

我将其记录为

@return [???] returns the instance of `Foo`

我应该写什么???应该是Foo吗?

【问题讨论】:

    标签: ruby documentation yard


    【解决方案1】:

    正确,根据tags overview,它提到了以下内容:

    类或模块类型

    任何 Ruby 类型都可以作为类或模块类型。这种类型只是类或模块的名称。

    【讨论】:

    • 如果@return [Foo]表示返回了一个实例,那么如何表明一个方法将Foo作为一个类返回?
    • @return [Class<Foo>],根据github.com/lsegal/yard/issues/1109
    猜你喜欢
    • 1970-01-01
    • 2015-05-23
    • 2018-01-12
    • 1970-01-01
    • 2013-05-11
    • 1970-01-01
    • 2013-11-16
    • 2017-11-22
    • 1970-01-01
    相关资源
    最近更新 更多