How to make Yard `@ macro` apply to multiple files

If I have one file , follow these steps:

module Something
  class Resource
    # Defines a new property
    # @param [String] name the property name
    # @param [Class] type the property 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

Methods propertydefined with the correct documentation. However, if I have these definitions in separate files, the documentation is not created properly, for example, in the following case:

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 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

If Yard macros are not transferred in separate files when creating documentation. How to enable this?

+3
source share
1 answer

YARD require, , . , , , . , "file1.rb" "file2.rb", , , .

, , YARD "file1.rb". , , :

$ yard doc lib/path/to/file1.rb lib/**/*.rb

( " " file1.rb "," ? , YARD )

+5

All Articles