迭代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 (${2--1}).each do |$arg| returns (String) the return value of create_method_with_args但我有兴趣调用类似(${2--1}).each do |$arg| 并且文档说每个参数都有一行文档。

不幸的是,宏是一种非常简单的工具,可以减少文档的干扰。 由于安全问题,我们选择不执行可执行宏(您可能不希望在评论中运行Ruby)。 对于所有问题,它们并不是一个通用的解决方案,但它们在非常简单的情况下运行良好。 对于更复杂的情况,插件仍然是推荐的方法。

也就是说,既然你仍然需要在某处指定实际的参数文档,我不会看到一个插件甚至会为你简化任何事情。 如果我是你,我会简单地定义它,并使用@param标签分别定义每个参数。 例如(让我们假设宏以前与您在问题中的方式“附加”):

 # @param [String] a documentation for a # @param [Symbol] b documentation for b # @param [Hash] c documentation for c create_method_with_args :bar, :a, :b, :c, Fixnum 

这对我来说似乎很合理,因为在这些文档中你没有其他的东西可以干掉。