On Tue, 9 Sep 2003 01:19:36 +0900
why the lucky stiff <ruby-talk / whytheluckystiff.net> wrote:

> On Monday 08 September 2003 06:58 am, Tobias Peters wrote:
> > Ryan Pavlik wrote:
> > >       method_info <<-DOC
> > >         !Method:   initialize
> > >         !Title:    Initialize
> > >         !Category: constructors
> > >         ... and so on ...
> >
> > I'd rather like
> >    method_info <<-DOC
> >      Create a new MyClass object giving optional defaults
> >      for "a" and "b".
> >
> >      Category: constructors
> >      ... and so on ...
> >
> 
> Looks like YAML just about.  Save yourself the parsing and go for:
> 
<snip>

Parsing the tags is a simple str.split operation.  The tricky bit is
parsing the content of the sections, which don't necessarily look like
YAML at all.  For instance:

   !param_flags foo: x=5, foo, bar=false

Of course, MetaTags is mostly for defining the set of tags you're using;
theoretically, you could subclass or dynamically modify TagSet to take a
YAML-preparsed string, and then apply the Section parsers to each YAML
string.

Parsing the given tag format is pretty trivial, though.  MetaTags just
makes it easy to define a set of tags and their corresponding parsers:

  text       = TextSection.new
  sym        = SymbolSection.new
  int        = IntegerSection.new
  ret        = ReturnSection.new
  par_long   = ParametersSection.new
  par_short  = ParamSection.new
  par_flags  = ParamFlagsSection.new

  TS = TagSet.new(["method",      "name",     sym, TAG_REQUIRED],
                  ["title",        nil,       text],
                  ["category",     nil,       sym],
                  ["order",        nil,       int],
                  ["desc",         nil,       text],
                  ["description", "desc",     text],
                  ["param",       "params",   par_short],
                  ["parameters",  "params",   par_long],
                  ["returns",      nil,       ret],
                  ["param_flags",  nil,       par_flags])

You could, if desired, do TS = MyTagSet(...) in your application, and
get a different input format.  What's mostly important is that you get
the same information out in the end, as opposed to the input format
(since people obviously have different preferences).

-- 
Ryan Pavlik <rpav / mephle.com>

"Another *perfectly* calculated space-time
 splice-n-splice. Now to get back to... wait a second.
 I forgot to carry the TWO!" - 8BT