[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Newbie question on RDoc--top-level functions

Kenneth McDonald

11/4/2008 9:18:00 PM

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


2 Answers

Trans

11/4/2008 10:41:00 PM

0



On Nov 4, 4:18=A0pm, Kenneth McDonald <kenneth.m.mcdon...@sbcglobal.net>
wrote:
> How do I get a top-level function (one not defined inside a class) to =A0
> show up in RDoc output. I have a number of such functions, and they =A0
> 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.

Ryan Davis

11/4/2008 11:02:00 PM

0


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:

> % sow blah
> creating project blah
> ... done, now go fix all occurrences of 'FIX'
>
> blah/Rakefile:9: # p.developer('FIX', 'FIX@example.com')
> blah/README.txt:3:* FIX (url)
> blah/README.txt:7:FIX (describe your package)
> blah/README.txt:11:* FIX (list of features or problems)
> blah/README.txt:15: FIX (code sample of usage)
> blah/README.txt:19:* FIX (list of requirements)
> blah/README.txt:23:* FIX (sudo gem install, anything else)
> blah/README.txt:29:Copyright (c) 2008 FIX
>
> % cd blah
> ./blah
>
> % echo "
> >
> > ##
> > # this is my rdoc
> >
> > def x
> > 42
> > end" >> lib/blah.rb
>
> % cat !$
> cat lib/blah.rb
> class Blah
> VERSION = '1.0.0'
> end
>
> ##
> # this is my rdoc
>
> def x
> 42
> end
>
> % rake docs
> (in /Users/ryan/blah)
> /Library/Ruby/Gems/1.8/gems/rake-0.8.3/lib/rake/gempackagetask.rb:
> 13:Warning: Gem::manage_gems is deprecated and will be removed on or
> after March 2009.
> rm -r doc
>
> History.txt:
> README.txt:
> blah:
> blah.rb: c.
> Generating HTML...
> Diagrams: ..
>
> Files: 4
> Classes: 1
> Modules: 0
> Methods: 1
> Elapsed: 1.075s