[svn:parrot] r37052 - in trunk: lib/Parrot/Docs tools/docs

fperrad at svn.parrot.org fperrad at svn.parrot.org
Sat Feb 28 22:11:37 UTC 2009


Author: fperrad
Date: Sat Feb 28 22:11:37 2009
New Revision: 37052
URL: https://trac.parrot.org/parrot/changeset/37052

Log:
[chm] generate the full ToC

Modified:
   trunk/lib/Parrot/Docs/Group.pm
   trunk/tools/docs/mk_chm.pl

Modified: trunk/lib/Parrot/Docs/Group.pm
==============================================================================
--- trunk/lib/Parrot/Docs/Group.pm	Sat Feb 28 22:01:30 2009	(r37051)
+++ trunk/lib/Parrot/Docs/Group.pm	Sat Feb 28 22:11:37 2009	(r37052)
@@ -190,6 +190,54 @@
     return @contents;
 }
 
+sub build_toc_chm {
+    my $self = shift;
+    my $source = shift;
+    my $indent = shift || q{ } x 6;
+
+    my $toc = q{};
+    $toc .= qq{$indent<LI> <OBJECT type="text/sitemap">\n};
+    $toc .= qq{$indent    <param name="Name" value="$self->{NAME}">\n};
+    $toc .= qq{$indent    <param name="Local" value="$self->{INDEX_PATH}">\n}
+        if (exists $self->{INDEX_PATH});
+    $indent .= q{ } x 2;
+    $toc .= qq{$indent</OBJECT>\n};
+    $toc .= qq{$indent<UL>\n};
+    foreach my $content ( @{ $self->{CONTENTS} } ) {
+        if ( ref $content ) {
+            if ( $content->isa('Parrot::Docs::Group') ) {
+                $toc .= $content->build_toc_chm( $source, $indent );
+            }
+            else {
+                foreach my $item ( @{ $content->{CONTENTS} } ) {
+                    my @rel_paths  = $self->file_paths_relative_to_source( $source, $item );
+                    foreach my $rel_path (@rel_paths) {
+                        my $file = $source->file_with_relative_path($rel_path);
+                        next if ( !$file->contains_pod && !$file->is_docs_link );
+                        $toc .= qq{$indent  <LI> <OBJECT type="text/sitemap">\n};
+                        $toc .= qq{$indent      <param name="Name" value="$rel_path">\n};
+                        $toc .= qq{$indent      <param name="Local" value="$rel_path.html">\n};
+                        $toc .= qq{$indent    </OBJECT>\n};
+                    }
+                }
+            }
+        }
+        else {
+            my @rel_paths  = $self->file_paths_relative_to_source( $source, $content );
+            foreach my $rel_path (@rel_paths) {
+                my $file = $source->file_with_relative_path($rel_path);
+                next if ( !$file->contains_pod && !$file->is_docs_link );
+                $toc .= qq{$indent  <LI> <OBJECT type="text/sitemap">\n};
+                $toc .= qq{$indent      <param name="Name" value="$rel_path">\n};
+                $toc .= qq{$indent      <param name="Local" value="$rel_path.html">\n};
+                $toc .= qq{$indent    </OBJECT>\n};
+            }
+        }
+    }
+    $toc .= qq{$indent</UL>\n};
+    return $toc;
+}
+
 =back
 
 =head1 SEE ALSO

Modified: trunk/tools/docs/mk_chm.pl
==============================================================================
--- trunk/tools/docs/mk_chm.pl	Sat Feb 28 22:01:30 2009	(r37051)
+++ trunk/tools/docs/mk_chm.pl	Sat Feb 28 22:11:37 2009	(r37052)
@@ -27,6 +27,7 @@
 use File::Copy;
 use File::Find;
 use Parrot::Config;
+use Parrot::Docs::Section::Parrot;
 
 copy('docs/resources/parrot.css', 'docs/html/parrot.css');
 copy('docs/resources/parrot_logo.png', 'docs/html/parrot_logo.png');
@@ -39,23 +40,11 @@
 
 my $version = $PConfig{VERSION} . $PConfig{DEVEL};
 
-my $filename = 'docs/html/index.html';
-open my $IN, '<', $filename
-    or die "Can't open $filename ($!)";
-my $toc;
-while (<$IN>) {
-    if (/^<a href=\"(\w+\.\w+)\">(.*)<\/a>/) {
-        $toc .= <<"TEXT";
-          <LI> <OBJECT type="text/sitemap">
-              <param name="Name" value="$2">
-              <param name="Local" value="$1">
-            </OBJECT>
-TEXT
-    }
-}
-close $IN;
+my $docs = Parrot::Docs::Section::Parrot->new;
+my $dist = Parrot::Distribution->new;
+my $toc  = $docs->build_toc_chm( $dist );
 
-$filename = 'docs/html/parrot.hhp';
+my $filename = 'docs/html/parrot.hhp';
 open my $OUT, '>', $filename
     or die "Can't open $filename ($!)";
 print $OUT <<"TEXT";
@@ -108,16 +97,9 @@
       <param name="ImageType" value="Folder">
     </OBJECT>
     <UL>
-      <LI> <OBJECT type="text/sitemap">
-          <param name="Name" value="Contents">
-          <param name="Local" value="index.html">
-          <param name="ImageNumber" value="1">
-        </OBJECT>
-        <UL>
-$toc        </UL>
+$toc
       <LI> <OBJECT type="text/sitemap">
           <param name="Name" value="Book">
-          <param name="ImageNumber" value="1">
         </OBJECT>
         <UL>
           <LI> <OBJECT type="text/sitemap">


More information about the parrot-commits mailing list