On Mon, 26 Feb 2001, Dave Thomas wrote:

> 'ri' displays information about Ruby methods etc. It holds these
> descriptions in a set of marshaled objects, one per class or
> module. These marshaled objects ae prepared as I ship ri, using a
> simplified form of the XML used to generate the online book.

Convert the XML to Ruby, then Ruby can parse it.

Eg, auto-generate the code to do something like:

  class Array
    def help(arg = nil)
      case arg
        when nil
          puts "Array blah blah, contains blah blah"
        when 'assoc'
          puts "blah blah"
        when 'at'
          ...
      end
    end
  end

which would allow the user to do:

  Array.help
  Array.help 'assoc'

(using Ruby as the parser and the user interface).

Another possibility would be to autogenerate MVC code, using a global
hash for the Model, and a VMS 'help' style user interface:

HELP> Array
Array: obj [ blah ] > blah
  Array is a class that implements blah blah blah

  assoc   at    blah  blah  blah  blah  blah  blah
  blah    blah  blah  blah  blah  blah  blah  blah
Array> assoc
Array::assoc    array.assoc {blah blah}

etc. This would make it easy to add a GUI help interface a bit later on.

Still, as you advise, don't design for future capabilities, so I guess it's
the first way. :)

> To do that with the current scheme would require that every client
> have the Ruby xmlparser module installed, which in turn requires Jim
> Clark's expat library. This seems onerous!

Once converted to Ruby, it could become part of the source tree and
maintained along with the code, as a form of literate programming?

If only. :)

This requirement seems OK for developers. End users would just load the
auto-generated Ruby code.

-- 
  spwhite / chariot.net.au