如果我在一个文件中有以下内容:
module Something
class Resource
# Defines a new property
# @param [String] name the property name
# @param [Class] type the property's type
# @macro [attach] property
# @return [$2] the $1 property
def self.property(name, type) end
end
class Post < Resource
property :title, String
property :view_count, Integer
end
end
用 get 定义的方法property
正确记录。但是,如果我在单独的文件中有这些定义,则无法正确生成文档,例如以下情况:
file0.rb
:
require 'file1.rb'
require 'file2.rb'
file1.rb
:
module Something
class Resource
# Defines a new property
# @param [String] name the property name
# @param [Class] type the property's type
# @macro [attach] property
# @return [$2] the $1 property
def self.property(name, type) end
end
end
file2.rb
:
module Something
class Post < Resource
property :title, String
property :view_count, Integer
end
end
当在单独的文件中时,Yard 宏在生成文档时不会保留。如何实现这一点?