ri needs to tell me what to require

Discussion in 'Ruby' started by Ben Giddings, Feb 16, 2005.

  1. Ben Giddings

    Ben Giddings Guest

    % 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
     
    Ben Giddings, Feb 16, 2005
    #1
    1. Advertising

  2. On Thu, 17 Feb 2005 06:37:54 +0900
    Ben Giddings <> 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=

    regards,

    Brian
     
    Brian Schröder, Feb 17, 2005
    #2
    1. Advertising

  3. Ben Giddings

    Ben Giddings Guest

    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?

    Ben
     
    Ben Giddings, Feb 17, 2005
    #3
  4. On Thu, 17 Feb 2005 23:24:11 +0900
    Ben Giddings <> 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?
    >


    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
     
    Brian Schröder, Feb 17, 2005
    #4
  5. Ben Giddings

    Ben Giddings Guest

    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
     
    Ben Giddings, Feb 17, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ivan
    Replies:
    2
    Views:
    434
    msnews.microsoft.com
    Apr 23, 2004
  2. Replies:
    6
    Views:
    508
    Alan Silver
    Sep 5, 2006
  3. yogesh
    Replies:
    1
    Views:
    379
    Victor Bazarov
    Mar 14, 2007
  4. Kenneth McDonald
    Replies:
    2
    Views:
    109
    Kenneth McDonald
    Sep 30, 2008
  5. Mike A
    Replies:
    17
    Views:
    269
    Dr John Stockton
    Nov 19, 2003
Loading...

Share This Page