> From what I've guessed I need to create my own formatter
> (RubyFormatter) by basically rewriting all private-formating methods
> (am I right here ?).

You can't probably reuse anything. I would just subclass
RBProgramNodeVisitor and implement all the #accept* methods.
RBFormatter is just an example of how that can be done.

> Then, I use the parser and the RubyFormatter. But what I want is
> export a package, ie. classes with their methods and extension
> methods. I can't parse directly a full class nor a package... can I
> directly ? I guess not

Yeah, that only converts a single method.

> So I need to parse each class definition (and class class definition),
> format them,  then parse/format each method source (probably better to
> get the code expressions from the MCWorkingCopy or PackageInfo I
> guess)...
>
> RBParser parseExpression: MyClass definition.

That's not what you want. Ruby classes look very different to
Smalltalk class definitions. I would do something like:

env := BrowserEnvironment new forPackageNames: #('MyPackage').
env classesDo: [ :class |
    stream := FileStream on: class name , '.rb'.
    " write header of class definition for 'class' "
    env selectorsForClass: class do: [ :selector |
       tree := class parseTreeFor: selector.
       RubyFormatter format: tree on: stream ].
    " write footer of class definition for 'class' "
    stream close ]

Lukas

-- 
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to