我正在使用的课程中有这个方法
def binary_search(a,x)
# ...
end
我希望在文档中参数显示为def binary_search(array, key)
而不是binary_search(a,x)
. 我尝试使用文档修饰符# :binary_search: array, key
但没有成功。我知道这一点,但如果有人知道如何使文档中的参数与实际源代码中的参数不同,你能告诉我吗?谢谢。
您应该能够: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。
也许# :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