Prepare indices
Previous: Weave: Write documentation pages ] [ Top: LPML alpha ] [ Next: Process arguments and open source file ]

In the first version of this app, I used a file named [[project>_index.html as the template for the index page of the application. This page had the following tags available:
  • itemlist
  • objectlist
However, once I had the <format> tag working, it turned out to be much cleaner simply to make those tags available for all pages, then allow an item named "index" to write out the index page. So instead of writing the index page in this block, I'm just going to build the tags and trust that the document will use them. And frankly, if not, no skin off my nose. In that case, the document will need some kind of explicitly generated navigation.

So let's build our item and object indices. Each of these is hardwired to be a bullet point list at the moment; that would be a nice thing to open up to configuration but that sort of enhancement will come later.

Since the index page is now a plain old item, I'm going to omit it from the table of contents. It's kind of jarring to see it there. On the other hand, since the index page is now a plain old item, I can use its label in further link formatting!

The use of the tags hash has to do with the way I do template printing.

The item list has a variable $level which keeps track of the table of contents level. Subitems are indented under their parents. When a non-subitem is encountered and the $level is 1, then we have to terminate the sublevel.
 
$level = 0;
$tags{itemlist} = "<ul>\n";
foreach $item (@items) {
   if ($item eq 'index') {
      $tags{indexlabel} = $label{$item};
   } else {
      if (!$level && $parent{$item} ne '') {
         $level = 1;
         $tags{itemlist} .= "<ul>\n";
      }
      if ($level && $parent{$item} eq '') {
         $level = 0;
         $tags{itemlist} .= "</ul>\n";
      }
      $tags{itemlist} .= "<li> <a href=\"$url{$item}\">$label{$item}</a>\n";
   }
}
$tags{itemlist} .= "</ul>\n";
$tags{objectlist} = "<ul>\n";
foreach $obj (@objects) {
   $tags{objectlist} .= "<li> <code>$obj</code>:";
   $tags{objectlist} .= "<a href=\"$url{$starter{$obj}}\">$label{$starter{$obj}}</a>\n";
}
$tags{objectlist} .= "</ul>\n";
Previous: Weave: Write documentation pages ] [ Top: lpml alpha ] [ Next: Process arguments and open source file ]


This code and documentation are released under the terms of the GNU license. They are copyright (c) 2000-2006, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.





Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.