Tag:

迭代Yardoc` @ macro`的寄存器

我正在寻找迭代一个yardoc @macro的寄存器的@macro 。 我知道你可以使用它们如下所示: class Post include DataMapper::Resource # @macro dm.property # @return [$2] the $1 $0 of the post property :title, String end 并且您可以生成寄存器由coma分隔的参数,就好像您正在使用如下所示的数组的一部分: # @macro dsl_method # @method $1(${2–2}) # @return [${-1}] the return value of $0 create_method_with_args :foo, :a, :b, :c, String 生成: foo(a, b, c)并returns (String) the return value of create_method_with_args […]

用YARD记录“splatted”参数的最佳方法是什么?

我有一个方法应该采用任何类的1+参数,类似于Array#push : def my_push(*objects) raise ArgumentError, ‘Needs 1+ arguments’ if objects.empty? objects.each do |obj| puts “An object was pushed: #{obj.inspect}” @my_array.push obj end end 使用YARD语法记录方法参数的最佳方法是什么? 编辑: 我意识到我原来的问题有点过于模糊,并没有明确说明我在寻找什么。 一个更好的问题是,在使用splatted参数时,在YARD中指定方法的arity(在这种情况下为1-∞)的最佳方法是什么? 我知道我可以在文本中指定它,但似乎应该有一个标签或类似的东西来指定arity。