amackey has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to develop a script/tool/module that will aid in the automatic synchronization of POD documentation between functional base class, abstract/virtual base classes and implementation (sub)-classes. The goals include:

An example: let's say that MyClassI.pm is an purely virtual, interface class: it specifies that classes that implement MyClassI.pm must provide the following methods: "do_foo" and "get_bar", and provides "fundamental" documentation describing these two methods.

Implementation class MyClass.pm provides methods for "do_foo" and "get_bar", but the author does not write any documentation for the methods; the "autodoc" tool dynamically writes the necessary POD. Small variation: MyClass.pm needs slightly more specific/modified documentation for "get_bar" (as only certain kinds of bar's are actually handled by this implementation); the author modifies the automatically provided POD, and somehow informs the tool not to overwrite their changes during the next "sync".

Subclass MySubClass.pm isa MyClass.pm, providing a few additional methods, and not overriding do_foo nor get_bar. The autodoc tool should "copy" MyClass.pm's method documentation into MySubClass.pm (perhaps in an =head1 Appendix). Small variant: MySubClass.pm overrides do_foo, but needs no change to the documentation: MyClass.pm documentation (which itself is MyClassI.pm documentation) gets used. Small variant #2: MySubClass.pm overrides do_foo, but now does have its own specific docs, and doesn't want to be overwritten during the next sync.

I think all the necessary tools are already in place (Pod::Constants, interface.pm, etc), but before I embarked I thought I'd bounce the design principles around here for awhile; I'd also love to be told that solution already exists!

Thanks,

-Aaron

Replies are listed 'Best First'.
Re: synchronized documentation
by IlyaM (Parson) on Mar 01, 2003 at 22:46 UTC
    Take a look on pod_merge.pl script from Alzabo distro. It is simplier than the system you have described but it does help automating maintainance of documentation for subclasses.

    --
    Ilya Martynov, ilya@iponweb.net
    CTO IPonWEB (UK) Ltd
    Quality Perl Programming and Unix Support UK managed @ offshore prices - http://www.iponweb.net
    Personal website - http://martynov.org

Re: synchronized documentation
by Aristotle (Chancellor) on Mar 02, 2003 at 12:04 UTC

    Cool idea. I suggest you use the =begin or =for directives for the purpose; you could then f.ex write =for autodoc and follow either a regular paragraph of POD or maybe a line of autodoc-specific commands. All other current POD parsers will ignore =for and =begin sections addressed at other parsers.

    A good place to start might be the Pod::Simple documentation, which includes a perlpodspec POD.

    Makeshifts last the longest.

Re: synchronized documentation
by Mr. Muskrat (Canon) on Mar 01, 2003 at 19:14 UTC

    This sounds like a very good thing to do. I do not know if it has been done before because I haven't really tried my hand at module (or class) creation. When I do, I'd like to make the documentation as easy (and quick) to write as possible.

Re: synchronized documentation
by bsb (Priest) on Mar 02, 2003 at 07:48 UTC
    Maybe look a similar tools for other languages.
    See how they do it.