I wanted a flat class listing, but it was too much work to write my own formatter for happydoc, so I wrote a short perl script to find all the classes and modify the index to link to them directly. below is that perl script. If the cut n paste job doesn't work email me at jackdied sourceforge users and I'll send a proper copy. I have a 'docs' directory where the happy doc generated files are, I invoke the script like this
'class_index.pl -dir docs'
#!/usr/bin/perl
use strict;
use Getopt::Long;
use DirHandle;
=comments
This is a simple perl script that creates a new index page for HappyDoc generated documents
It adds a class-based index to the index page which points to the HTML pages already
generated by HappyDoc. Doing this was easier than writing a whole new docset for HappyDoc
=cut
my $directory = '';
my $old_index = 'index.html';
my $new_index = '';
GetOptions('dir=s' => \$directory, 'index=s' => \$old_index, 'newindex=s' => \$new_index);
die("No directory specified") unless $directory;
$new_index ||= $old_index; # default to same file if none specified
my $dh = new DirHandle($directory) || die("Couldn't open '$directory' for reading");
my $classes = []; # list of class names
my $class_files = {}; # { classname => defined_in_sourcefile }
while (defined(my $fname = $dh->read())) {
local ($1, $2);
if ($fname =~ /((\w+)_(\w+).*html)/) { # Class_Class.html, HappyDoc class html
my $name = "${directory}/${2}.py.html";
if (-f $name) {
push(@$classes, $3);
$class_files->{$3} = $1;
}
}
}
undef $dh; # close the DirHandle
my $hdi = new HappyDocIndex($directory . '/' . $old_index, $classes, $class_files);
my $new_html = $hdi->gen_index();
my $new_index_fullpath = $directory . '/' . $new_index;
open(OF, ">$new_index_fullpath") || die("Couln't open '$new_index_fullpath' for writing");
print OF $new_html;
close(OF);
exit(0);
package HappyDocIndex;
sub new {
my $self = bless {}, shift;
$self->{filename} = shift;
my ($classes, $class_files) = @_;
I wanted a flat class listing, but it was too much work to write my own formatter for happydoc, so I wrote a short perl script to find all the classes and modify the index to link to them directly. below is that perl script. If the cut n paste job doesn't work email me at jackdied sourceforge users and I'll send a proper copy. I have a 'docs' directory where the happy doc generated files are, I invoke the script like this
'class_index.pl -dir docs'
#!/usr/bin/perl
use strict;
use Getopt::Long;
use DirHandle;
=comments
This is a simple perl script that creates a new index page for HappyDoc generated documents
It adds a class-based index to the index page which points to the HTML pages already
generated by HappyDoc. Doing this was easier than writing a whole new docset for HappyDoc
=cut
my $directory = '';
my $old_index = 'index.html';
my $new_index = '';
GetOptions('dir=s' => \$directory, 'index=s' => \$old_index, 'newindex=s' => \$new_index);
die("No directory specified") unless $directory;
$new_index ||= $old_index; # default to same file if none specified
my $dh = new DirHandle($directory) || die("Couldn't open '$directory' for reading");
my $classes = []; # list of class names
my $class_files = {}; # { classname => defined_in_sourcefile }
while (defined(my $fname = $dh->read())) {
local ($1, $2);
if ($fname =~ /((\w+)_(\w+).*html)/) { # Class_Class.html, HappyDoc class html
my $name = "${directory}/${2}.py.html";
if (-f $name) {
push(@$classes, $3);
$class_files->{$3} = $1;
}
}
}
undef $dh; # close the DirHandle
my $hdi = new HappyDocIndex($directory . '/' . $old_index, $classes, $class_files);
my $new_html = $hdi->gen_index();
my $new_index_fullpath = $directory . '/' . $new_index;
open(OF, ">$new_index_fullpath") || die("Couln't open '$new_index_fullpath' for writing");
print OF $new_html;
close(OF);
exit(0);
package HappyDocIndex;
sub new {
my $self = bless {}, shift;
$self->{filename} = shift;
my ($classes, $class_files) = @_;
$self->{classes} = $classes;
$self->{class_files} = $class_files;
{
open(FH, "<$self->{filename}") || die("Couldn't open '$self->{filename}' for reading");
my @text = <FH>;
$self->{html} = \@text;
close(FH);
}
return $self;
}
sub gen_index {
my $self = shift;
my $all_html = '';
my $table_cnt = 0;
my $i = 0;
while ($table_cnt < 2) {
if ($self->{html}->[$i] =~ /\<table/) {
$all_html .= $self->{html}->[$i] unless $table_cnt;
$table_cnt++;
} else {
$all_html .= $self->{html}->[$i];
}
$i++;
}
$i--; # backup to the <table> tag
$all_html .= $self->new_html();
while ($i < scalar(@{$self->{html}})) {
$all_html .= $self->{html}->[$i];
$i++;
}
return $all_html;
}
sub new_html {
my $self = shift;
my $top= <<'HTML';
<tr bgcolor="#88bbee">
<th rowspan="2"
valign="top"
align="left"
width="10%"><font color="#000000">HappyDoc Generated Documentation</font>
</th>
<th width="90%" align="right"><font color="#000000"> </font></th>
</tr>
<tr>
<td>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<th bgcolor="#99ccff"
rowspan="2"
valign="top"
align="left"
width="20%"
>
<font color="#000000">
<a name="Classes">Classes</a>
</font>
</th>
<th bgcolor="#99ccff"
valign="top"
align="left"
width="80%"
>
<font color="#000000"> </font>
</th>
</tr>
<th width="90%" align="right"><font color="#000000"> </font></th>
</tr>
<tr>
<td>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
<tr>
<th bgcolor="#99ccff"
rowspan="2"
valign="top"
align="left"
width="20%"
>
<font color="#000000">
<a name="Classes">Classes</a>
</font>
</th>
<th bgcolor="#99ccff"
valign="top"
align="left"
width="80%"
>
<font color="#000000"> </font>
</th>
</tr>
<tr>
<td>
<table border="0" cellpadding="3" cellspacing="0">
HTML
my $bottom = <<'HTML';
</table>
</td></tr>
HTML
my $myhtml = $top;
foreach my $class (@{$self->{classes}}) {
$myhtml .= $self->row_tag($class, $self->{class_files}->{$class});
}
$myhtml .= $bottom;
return $myhtml;
}
sub row_tag {
my $self = shift;
my ($classname, $classfile) = @_;
return "<tr><td valign=\"top\" align=\"left\"><a href=\"$classfile\">$classname</a></td><td valign=\"top\" align=\"left\"></td></tr>\n";
}
This looks interesting. I haven't tried running it, but is the output different from using the docset_usePackages=0 option on the command line?