[Doc-SIG] How to traverse a document object
David Goodger
goodger@users.sourceforge.net
Thu, 25 Oct 2001 23:21:55 -0400
Paul Moore wrote:
> But why does all my tree walking stuff (and Tibs') spend its time switching
> on tagname then? Actually, I know the answer to this - coding a "proper"
> object-oriented tree-walk is hard.
I don't know about that. I've got the inkling of an elegant structure
glimmering in my mind (including a judicious use of a __getattr__ method for
default behaviour). I just haven't needed it yet. Maybe you can beat me to
it!
> It's probably significant that most of the classes in the DPS doc tree
> are of the form
>
> class paragraph(_TextElement): pass
>
> There's no polymorphism here. The class name is *only* relevant in
> setting the tagname attribute via introspection.
So far, perhaps so. There's a lot of infrastructure to be added yet.
> I do wonder about your comment "especially when you can customize
> the ``nodes.list`` class with specialized behaviour". Agreed, it's a
> valid advantage. But you don't *use* that advantage.
Not *yet*.
> I had started from the assumption that the DPS doc tree was pretty much
> inviolate, and I should work with it as it stands.
Aha! Nothing could be further from the truth. You must leave such
assumptions behind!
> It looks like there are probably changes needed to support output. I'm
> a bit nervous about fiddling with something that central, though...
That's where SourceForge patches and peer review work their magic.
--
David Goodger goodger@users.sourceforge.net Open-source projects:
- Python Docstring Processing System: http://docstring.sourceforge.net
- reStructuredText: http://structuredtext.sourceforge.net
- The Go Tools Project: http://gotools.sourceforge.net