Rdoc

Hello,

Is there a way to specify the return value of a method in rdoc?

I would like my rdoc documentation to look like the ruby-core-api:
“method_name(param1, param2) => return_value”

Thanks for helping

Martin Gütlein wrote:

Hello,

Is there a way to specify the return value of a method in rdoc?

I would like my rdoc documentation to look like the ruby-core-api:
“method_name(param1, param2) => return_value”

Thanks for helping

You can override the whole calling string with #call-seq:

#!/usr/bin/env ruby
#Encoding: UTF-8

#That’s my class.
class A

#call-seq:

A#my_method ==> 27

#And this is my method.
def my_method
27
end

end

Note the blank line between the calling string (which may be multiline)
and the method description.
If you speak German, you may want to have a look here:
http://wiki.ruby-portal.de/RDoc
If not, I’d like to point you to the official RDoc documentation at
http://rdoc.sourceforge.net/doc/index.html (but I wasn’t able to find
the #call-seq directive there till now)

Marvin

At 2009-09-30 11:33AM, “Martin Gütlein” wrote:

Hello,

Is there a way to specify the return value of a method in rdoc?

I would like my rdoc documentation to look like the ruby-core-api:
“method_name(param1, param2) => return_value”

Thanks for helping

Use the “call-seq:” directive

# ... comments about this method ...
#
# call-seq:
#   method_name(param1, param2) => return_value
#
def method_name(first_param, second_param)
  ...

Note the parameter names in the call-seq don’t have to match what you
actually use in your code.