From: Eric Hodel Date: 2010-04-15T06:32:16+09:00 Subject: Re: OT(?): Adapting rdoc to produce documentation for something other than ruby or c--advisable? On Apr 14, 2010, at 09:00, rpardee@gmail.com wrote: > In my day job I'm a sas (www.sas.com) programmer. I've got a plain > text file of sas macros (roughly equivalent to ruby's methods) for > which I would love to have rdoc-style documentation. Specifically, > I'd like a list of the macros, the params they take, the explanatory > comments that precede each one & the expandable code listing when you > click a method name. > > A brief troll through the RDoc::Markup docs makes me wonder if I > couldn't learn to drive that sufficiently to get rdoc to do this for > me. > > Can anybody give me a sense for how badly RDoc & I would have to > torture one another to get this to work? > > In case it's helpful, sas has c-style comments: '*' starts a comment > until the first following ';' char. Macro definitions are preceded by > the keyword %macro, followed by a name & an optional parenthesized, > comma-delimited list of paraameters. All lines up to the first > following %mend keyword are the body of the macro. If you've got input files that aren't already handled (ruby, C, text, perl are handled built-in, fortan is available via an extension) you'll want to look at writing a parser. RDoc::Parser::C is a pile of regular expressions (which would probably work best to start), or if you can find (or write) a real parser for SAS macros you can use that instead. An RDoc::Parser will turn an input document (like your SAS file) into a tree of code built around an RDoc::TopLevel (a file) and it's various descendents (lib/rdoc/code_objects.rb has the list). You'll need to decide on a mapping from the elements of SAS macros to classes, modules, and methods.