Ri needs to tell me what to require

% ri File.copy

------------------------------------------------------------- File::copy
      File::copy(from, to, verbose = false)

···

------------------------------------------------------------------------
      Copies a file +from+ to +to+ using #syscopy. If +to+ is a
      directory, copies +from+ to +to/from+. If +verbose+ is true, +from
      -> to+ is printed.

Yay! That's what I want!

irb(main):001:0> File.copy("foo", "bar")
NoMethodError: undefined method `copy' for File:Class
         from (irb):1

*cry*

It turns out that File.copy is defined in 'ftools', but I have no idea how I'm supposed to know that.

Ben

In principle a +1 from me, but check also:

http://groups.google.de/groups?threadm=6D24974B-123E-11D9-8C3F-000A95D2DFAE%40mac.com

regards,

Brian

···

On Thu, 17 Feb 2005 06:37:54 +0900 Ben Giddings <bg-rubytalk@infofiend.com> wrote:

% ri File.copy

------------------------------------------------------------- File::copy
      File::copy(from, to, verbose = false)
------------------------------------------------------------------------
      Copies a file +from+ to +to+ using #syscopy. If +to+ is a
      directory, copies +from+ to +to/from+. If +verbose+ is true, +from
      -> to+ is printed.

Yay! That's what I want!

irb(main):001:0> File.copy("foo", "bar")
NoMethodError: undefined method `copy' for File:Class
         from (irb):1

*cry*

It turns out that File.copy is defined in 'ftools', but I have no idea
how I'm supposed to know that.

Ben

In principle a +1 from me, but check also:

http://groups.google.de/groups?threadm=6D24974B-123E-11D9-8C3F-000A95D2DFAE%40mac.com

Which says:

>> Excellent idea. The only problem is that, as things stand, this isn't
>> easily knowable, as the file containing the method definition may not
>> be the one that you end up requiring into your Ruby source. For
>> example, the various YAML methods are defined in files in the yaml/
>> directory, but you don't require these into your code. Instead you
>> say
>>
>> require "yaml"
>>
>> and it drags them in for you.

In principle then, the file 'yaml/foo.rb' should contain some kind of comment saying "hey, if you want the functionality that this file provides, require 'yaml' not this file". That way people who are looking at that file in their favourite editor can know how to get access to those functions. It should be possible to do that in a way that rdoc can pick up on it, right?

Ben

···

On Feb 17, 2005, at 03:15, Brian Schröder wrote:

Yes, you could put this comment at the end of the description of each function. But this is a lot of "repeat yourself", and who wants that?

So it seems someone has to think about extending rdoc with some new meta commands, create a patch, discuss and standardize it and get it included. Sadly thats more work than I have time, so I just hope that someone else will do this. Not the nice way, but I don't see another possibility.

Regards,

Brian

···

On Thu, 17 Feb 2005 23:24:11 +0900 Ben Giddings <bg-rubytalk@infofiend.com> wrote:

On Feb 17, 2005, at 03:15, Brian Schröder wrote:
> In principle a +1 from me, but check also:
>
> http://groups.google.de/groups?threadm=6D24974B-123E-11D9-8C3F
> -000A95D2DFAE%40mac.com

Which says:

>> Excellent idea. The only problem is that, as things stand, this isn't
>> easily knowable, as the file containing the method definition may not
>> be the one that you end up requiring into your Ruby source. For
>> example, the various YAML methods are defined in files in the yaml/
>> directory, but you don't require these into your code. Instead you
>> say
>>
>> require "yaml"
>>
>> and it drags them in for you.

In principle then, the file 'yaml/foo.rb' should contain some kind of
comment saying "hey, if you want the functionality that this file
provides, require 'yaml' not this file". That way people who are
looking at that file in their favourite editor can know how to get
access to those functions. It should be possible to do that in a way
that rdoc can pick up on it, right?

Brian Schröder wrote:

Yes, you could put this comment at the end of the description of each
function. But this is a lot of "repeat yourself", and who wants that?

Would it really need to be at the beginning of each function, or could one command at the top of the file do it?

I don't know how the internals of rdoc work at all, but it seems that that should be possible, just some little comment at the top saying:

# To use any of the functions from this file
# require 'yaml'

So it seems someone has to think about extending rdoc with some new
meta commands, create a patch, discuss and standardize it and get it
included. Sadly thats more work than I have time, so I just hope that
someone else will do this. Not the nice way, but I don't see another
possibility.

I don't know how rdoc works, so that might be necessary. I was looking into customizing some rdoc output the other day, and it seemed like there was a lot going on in there that I didn't understand.

Maybe it's time for the next big leap in rdoc functionality.

Ben