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

Dearest monks,

First, a very happy 2007 to you all. May the new year bring more warming of world relations, less warming of the climate, and more exciting Perl in our lives.

I have been building documentation for my programs, and since I am lazy (I am 1/3 of the way there), I want to write my docs in one place only... POD to rescue. Then, I want to generate html, rtf, postscript, quarkexpress, and lithographs all at the click of a button.

I am finding POD to be, well, a bit too plain for my liking, and I am hoping you will assist me.

1. My documentation, when generated into html, follows the same hierarchy as my modules. So, lib::Foo::Bar::Baz.pm results in http://../lib/Foo/Bar/Baz.html. I want to build a breadcrumb trail, but the only way I can figure out to do that is to embed a

=for html <div id="title"> <img src="../../../../images/logo.gif" width="121" height="22"><br / +> My Documentation<br /> <span class="sub_title"><a href="../../../../index.html">Home</a> &g +t; lib &gt; Foo &gt; Bar &gt; Baz.pm</span> </div>

Obviously, this is less than satisfying as I have to do this in all the modules, adjust the path to index.html and the logo. The question here is -- is there any way I can embed variables in POD that get interpolated when POD (and, by extension, pod2html) is generated?

Lists in POD are less than satisfying as well. They result in

<ul> <li><p>item one</p></li> <li><p>item two</p></li> </ul>

What's with those p tags? Do I have to go tinker with POD::HTML?

Update 1: adjusted list items as per ikegami's suggestion. Really wanted to *not* have those p tags appear, but diddling with stylesheets is more or less satisfactory.

Then, even though I have enabled --noindex option, I get

<p><a name="__index__"></a></p> <!-- INDEX BEGIN --> <!-- <ul> <ul> <ul> <li><a href="#name">NAME</a></li> <li><a href="#version">VERSION</a></li> <li><a href="#synopsis">SYNOPSIS</a></li> .. </ul> </ul> </ul> --> <!-- INDEX END -->

The index is still generated, just that it is hidden. What's with that?

Update 2: Building a breadcrumb trail, and getting around the index at the top of the page was achieved by first writing out all the html files, then opening them again, and replacing the index with a header and breadcrumb trail, and writing them out again. Kludgy, but works.

There are several other issues, but I will stop here for now. I guess, in other words, I am looking for a tutorial on creating customized, beautiful html documentation, as well as RTF documentation from POD... Powerful One Documentation.

Many tia.

Update 3: Having stellar documentation tools to be able to create stellar documentation will be a great boon. I hope the new year will bring such tools into the world of Perl.
--

when small people start casting long shadows, it is time to go to bed

Replies are listed 'Best First'.
Re: Creating not so plain documentation
by brian_d_foy (Abbot) on Jan 08, 2007 at 19:46 UTC

    Check out the stuff I did with Pod for Mastering Perl. There's a chapter on messing with and extending Pod, and I wrote the book in O'Reilly's PseudoPod format (see Pod::PseudoPod), an extension of Pod that includes footnotes.

    The Pod chapter also talks about writing your own Pod translator. It's not as hard as you think. You start with one that's close to what you want and override the parts that you want to change. Look into Pod::Simple.

    Good luck :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: Creating not so plain documentation
by ikegami (Patriarch) on Jan 08, 2007 at 18:54 UTC

    What's with those p tags? Do I have to go tinker with POD::HTML?

    You can adjust the visual representation using CSS, if that's the problem.

    /* No margin for P inside of LI */ li p { margin: 0; }
Re: Creating not so plain documentation
by ww (Archbishop) on Jan 08, 2007 at 21:43 UTC
    and re "those <p> tags:
    inside the list items, they force (usually) a blank line which trails the content so that there's a blank line between bullets.

    eg:

    <ul> <li><p>foo</p></li> <li><p>foo1</p></li> <li>foo2</li> <li>foo3</li> </ul>
    will look like this:
    ∙ foo
    
    ∙ foo1
    
    ∙ foo2
    ∙ foo3
    

    And, as ikegami said, you can control the presentation with css -- http://www.w3schools.com/ has a decent tutorial if you're unfamiliar with style sheets. Once you have the basics, you may find it worthwhile to read the various css specs at http://www.w3.org/Style/CSS/.

    For a example (anything more is well outside the scope of the Monastery), change the display of those updated for clarity the content of the list-items with something like this (inline for ease of display):

    <ul> <li><p style="color: red; background-color: transparent; font-size: 1. +1em; font-weight:bold;">foo</p></li> <li><p style="color: #000000; background-color: #dddddd;; font-size: 1 +.1em; font-weight:bold;">foo1</p></li> <li style="color: blue; background-color: transparent; font-size: 1.1e +m; font-weight:bold;">foo2</li> <li style="font-size: 1.1em; font-weight:bold;">foo3</li> </ul>

    which would give you bold, slightly larger than normal-font-size type, with "foo" in red; "foo1" in black on a silver background; "foo2" in blue, and "foo3" in black again (assuming you had not used some other color as a default for the page.

    Update ikegami provides a more technical (and CORRECT) answer; however, if you're just starting with css the code and descriptions of the rendering are correct; the statement re the placement of the blank lines is imprecise ok, admit it! wrong.

      The blank space appears before the bullet instead of after because of collapsing margins.

      The bullet doesn't count as content, so the bottom margin of the previous P, the bottom margin of the previous LI, the top margin of the LI and the top margin of the P are collapsed into one margin whose size is the biggest of the 4 margins.

      ( Contrary to his claims, there's nothing wrong with what ww said. I was just expanding on it. )

Re: Creating not so plain documentation
by ikegami (Patriarch) on Jan 08, 2007 at 22:41 UTC
Re: Creating not so plain documentation
by planetscape (Chancellor) on Jan 09, 2007 at 09:00 UTC

    I may be way off base here, but...

    Personally, I recommend Doxygen.

    Doxygen generates JavaDoc-like documentation (all nicely linked) for projects in many languages, including C and C++. DoxygenFilter is a new take on an old project (DoxyFilt) that also handles ("filters") Perl code (including POD), and now promises support for multi-programming-language projects. See Examples of output generated by doxygen.

    HTH,

    planetscape
      When I was expressing a desire above for better documentation, I actually had Doxygen in mind. However, as far as I recalled, Doxygen did not work for Perl/Pod. Seems like I have something new to discover here. Yes, Doxygen generated docs are really quite good. Thanks for the tip.
      --

      when small people start casting long shadows, it is time to go to bed
Re: Creating not so plain documentation
by loris (Hermit) on Jan 09, 2007 at 09:38 UTC

    Hello punkish,

    I am not sure that this will really address any of your concerns and it is a completely different approach, but have you had a look at literate programming? I am no expert, but Literate Programming, simply put, allows the programmer to order code and comments in a way that makes most sense to him or her (rather than to the interpreter or compiler), and to print the resulting program out very prettily. Unfortunately there has not been much development in this area since the early 90s, which was when I discovered and tinkered around with it, although I did find this slightly more recent article, which contains an example using Perl.

    HTH or is at least of interest

    loris


    "It took Loris ten minutes to eat a satsuma . . . twenty minutes to get from one end of his branch to the other . . . and an hour to scratch his bottom. But Slow Loris didn't care. He had a secret . . ." (from "Slow Loris" by Alexis Deacon)
Re: Creating not so plain documentation
by wazoox (Prior) on Jan 09, 2007 at 21:50 UTC
    Somewhat similar to Doxygen, I personnally favor ROBODoc. It also works with most languages (Perl, C, HTML, ... ). I've even made a quick script ( see ROBODoc to Pod translator , also included in current ROBODoc distribution) to convert ROBODoc to POD, in case you need POD for your CPAN modules, or you have pod2... utilities but no ROBODoc installation at hand.