我在使用的课程中有这种方法

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top