0

I have this method in a class I am using

def binary_search(a,x)
  # ...
end

and I want in the documentation for the parameters to appear as def binary_search(array, key) and not binary_search(a,x). I have tried to use the documentation modifier # :binary_search: array, key with no success. I know this a little thing, but if somebody knows how to do make the parameters different in the documentation than in the actual source code, can you please show me? Thanks.

ab217
  • 16,900
  • 25
  • 74
  • 92

2 Answers2

1

You're supposed to be able to use the :call-seq: directive in the method header comment as follows:

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

I haven't got this working yet. I'm using RDoc V1.0.1 and Ruby 1.8.7.

Richard Cook
  • 32,523
  • 5
  • 46
  • 71
  • I tried it and it didn't work on my system either and I'm running Ruby 1.9.2 with RDoc 2.5.8 – ab217 Sep 23 '10 at 02:12
1

Maybe try # :args: thing_to_try like so: (be careful about whitespace)

# 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
Tim Snowhite
  • 3,736
  • 2
  • 23
  • 27