Forum: Ruby Newbie question on RDoc--top-level functions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47df9cfb356c3ee0523cc3571b169730?d=identicon&s=25 Kenneth McDonald (Guest)
on 2008-11-04 22:22
(Received via mailing list)
How do I get a top-level function (one not defined inside a class) to
show up in RDoc output. I have a number of such functions, and they
don't appear to be showing up anywhere.

Thanks,
Ken
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Thomas Sawyer (7rans)
on 2008-11-04 23:43
(Received via mailing list)
On Nov 4, 4:18 pm, Kenneth McDonald <kenneth.m.mcdon...@sbcglobal.net>
wrote:
> How do I get a top-level function (one not defined inside a class) to  
> show up in RDoc output. I have a number of such functions, and they  
> don't appear to be showing up anywhere.

Not really a good practice in any case.

You can just move them to Object, which is effectively the same
(except public vs. private):

  class Object
    # ... methods here
  end

If you consider them general purpose core extensions then Kernel may
be more appropriate:

  module Kernel
    # ... methods here
  end

T.
5a837592409354297424994e8d62f722?d=identicon&s=25 Ryan Davis (Guest)
on 2008-11-05 00:04
(Received via mailing list)
On Nov 4, 2008, at 13:18 , Kenneth McDonald wrote:

> How do I get a top-level function (one not defined inside a class)
> to show up in RDoc output. I have a number of such functions, and
> they don't appear to be showing up anywhere.


global methods get added to Object as private methods, but rdoc
doesn't automatically file them in Object (I'm filing a bug on that).
They _do_ show up in the method list:

> Public Instance methods
> x()
> this is my rdoc
>
Here I'm creating a new project, throwing a global method in the file,
and generating rdoc:
This topic is locked and can not be replied to.