我正在使用YARD为我的 ruby gem 编写文档。在我的 gem 中,我有一些代码遵循这种常见的 ruby 模式,其中一个模块包含在一个类中,并且该模块不仅添加了实例方法,而且还添加了类方法:
module Moo
def self.included(klass)
klass.extend ClassMethods
end
module ClassMethods
def hello
puts "hello"
end
end
end
class Foo
include Moo
end
Foo.hello # => class method runs, printing "hello"
默认情况下,YARD 将为 Foo 类生成如下所示的文档:
我认为这个文档是不充分的,因为它没有告诉用户该Foo.hello
方法可用。要了解hello
,用户必须点击Moo
,然后点击ClassMethods
。
Foo
在一页上列出所有类和实例方法的列表会很棒。我怎样才能做到这一点?我是否需要更改代码,或者是否可以添加一个标签来给 YARD 一个提示ClassMethods
?