简单的Rdoc关于文档修饰符的问题

时间:2010-09-22 19:20:12

标签: ruby rdoc

我在使用

的课程中使用此方法
def binary_search(a,x)
  # ...
end

我想在参数文档中显示为def binary_search(array, key)而不是binary_search(a,x)。我试图使用文档修饰符# :binary_search: array, key但没有成功。我知道这个小东西,但是如果有人知道怎么做使文档中的参数与实际源代码中的参数不同,你能告诉我吗?感谢。

2 个答案:

答案 0 :(得分:1)

您应该能够在方法标题注释中使用:call-seq:指令,如下所示:

##
# Pass array and key.
#
# :call-seq:
#   binary_search(array, key)
def binary_search(a, x)
  # ...
end

我还没有这个工作。我正在使用RDoc V1.0.1和Ruby 1.8.7。

答案 1 :(得分:1)

也许像这样尝试# :args: thing_to_try :(小心空白)

# rdoc-2.5.8/lib/rdoc/parser/ruby.rb:48
# The parser extracts the arguments from the method definition.  You can
# override this with a custom argument definition using the :args: directive:

   ##
   # This method tries over and over until it is tired 

   def go_go_go(thing_to_try, tries = 10) # :args: thing_to_try
     puts thing_to_try
     go_go_go thing_to_try, tries - 1
   end