[xml/sgml-commit] [SCM] linuxdoc-tools package for Debian. branch, experimental, updated. debian/0.9.60-12-g5a91351

Agustin Martin Domingo agmartin at debian.org
Mon Apr 27 23:22:47 UTC 2009


The following commit has been merged in the experimental branch:
commit 5a91351f963aad46a4f3aec86f27cde268c14478
Author: Agustin Martin Domingo <agmartin at debian.org>
Date:   Tue Apr 28 01:16:56 2009 +0200

    InfoUtils.pm: Make menu building more robust. Handle depth 5. Minor changes for clarity.
    
    * Simplify menu info gathering and make it more robust.
    * Handle depth 5. I still do not like how the result look.
    * Send debugging info to STDERR.
    * New 'orig' field.
    * Minor changes for clarity.

diff --git a/perl5lib/LinuxDocTools/InfoUtils.pm b/perl5lib/LinuxDocTools/InfoUtils.pm
index ec146e5..272ae9f 100644
--- a/perl5lib/LinuxDocTools/InfoUtils.pm
+++ b/perl5lib/LinuxDocTools/InfoUtils.pm
@@ -113,7 +113,6 @@ sub info_parse_raw_file {
 	'menu'     => []}
       );
 
-  my %menu      = ();
   my %levellast = (0 => "Top");
   my %labels    = ();
   my %docdata   =   # Some misc data for the document
@@ -132,20 +131,15 @@ sub info_parse_raw_file {
   while (<$INPUT>){
     chomp;
     if ( s/^\@SUB\s+// ){
-      my $updepth = $depth;
+      my $updepth   = $depth;
+      my $uppernode = $levellast{$updepth};
       $depth++;
       $sort++;
 
       my @levelmenu = ();
 
-      if ( $lastdepth > $depth ){
-	$nodedata{$levellast{$depth}}->{'menu'}     = $menu{$depth};
-	delete $menu{$depth};
-	@levelmenu = ();
-      }
-
-      if ( defined $menu{$updepth} ){
-	@levelmenu = @{ $menu{$updepth} };
+      if ( defined $nodedata{$uppernode}->{'menu'} ){
+	@levelmenu = @{ $nodedata{$uppernode}->{'menu'} };
       }
 
       my $nodetext = info_normalize_node_text($_);
@@ -155,16 +149,17 @@ sub info_parse_raw_file {
       $nodedata{'Top'}->{'next'} = $nodename if ( $lastdepth eq 0);
 
       # Fill info for current node (and 'next' for last one in level)
+      $nodedata{$nodename}->{'orig'}          = $_;
       $nodedata{$nodename}->{'text'}          = $nodetext;
       $nodedata{$nodename}->{'depth'}         = $depth;
       $nodedata{$nodename}->{'previous'}      =
 	defined $levellast{$depth} ? $levellast{$depth} : "";
       $nodedata{$levellast{$depth}}->{'next'} = $nodename
 	if defined $levellast{$depth};
-      $nodedata{$nodename}->{'up'}            = $levellast{$updepth};
+      $nodedata{$nodename}->{'up'}            = $uppernode;
       $nodedata{$nodename}->{'sort'}          = $sort;
       $nodedata{$nodename}->{'debug'}         =
-	"updepth: $updepth, lastdepth:  $lastdepth, up: $levellast{$updepth}";
+	"updepth: $updepth, lastdepth:  $lastdepth, up: $uppernode";
 
       # Keep this defined in case tbere is no next node in the same level.
       $nodedata{$nodename}->{'next'}          = "";
@@ -175,7 +170,7 @@ sub info_parse_raw_file {
       # Prepare things for next @SUB entry found
       $levellast{$depth}   = $lastnode        = $nodename;
       $lastdepth                              = $depth;
-      $menu{$updepth}                         = \@levelmenu;
+      $nodedata{$uppernode}->{'menu'}         = \@levelmenu;
 
     } elsif ( s/^\@ENDSUB// ){
       $depth--;
@@ -195,11 +190,6 @@ sub info_parse_raw_file {
   }
   close $INPUT;
 
-  # Flush pending menus
-  foreach (0..5){
-    $nodedata{$levellast{$_}}->{'menu'}  = $menu{$_} if defined $menu{$_};
-  }
-
   $docdata{'nodedata'}  = \%nodedata;
   $docdata{'labels'}    = \%labels;
   $docdata{'inputtext'} = \@inputtext;
@@ -226,7 +216,7 @@ sub info_write_preprocessed_file {
 
   my $OUTFILE;
 
-  # check_parsed_data($nodedata);
+  # info_check_parsed_data($nodedata);
 
   my %sections = ( 1 => "\@chapter",
 		   2 => "\@section",
@@ -266,8 +256,10 @@ sub info_write_preprocessed_file {
 	$texinfo .= $txt;
 	$lastdepth = $depth;
 	$lastnode  = $key;
+      } elsif ( $depth eq 5 ){
+	$texinfo .= "** $key\n";
       } else {
-	die "info-postASP:$key has wrong depth $depth\n";
+	die "info-postASP: Entry \"$key\" has wrong depth $depth\n";
       }
     } elsif (s/^\@REF\s+//){
       if ( defined $labels->{$_} ){
@@ -305,15 +297,16 @@ sub info_check_parsed_data {
 
   foreach ( @sections ){
     my $ref = $tmpnodedata->{$_};
-    print "$_\n";
-    print "  text: $ref->{'text'}\n";
-    print "  debug: $ref->{'debug'}\n";
-    print "  up: $ref->{'up'}\n";
-    print "  depth: $ref->{'depth'}\n";
-    print "  previous: $ref->{'previous'}\n";
-    print "  next: $ref->{'next'}\n";
-    print "  sort: $ref->{'sort'}\n";
-    print "  menu:\n   * " . join("\n   * ",@{$ref->{'menu'}}) . "\n" if defined $ref->{'menu'};
+    print STDERR "Node: $_\n";
+    print STDERR "  orig: $ref->{'orig'}\n";
+    print STDERR "  text: $ref->{'text'}\n";
+    print STDERR "  debug: $ref->{'debug'}\n";
+    print STDERR "  up: $ref->{'up'}\n";
+    print STDERR "  depth: $ref->{'depth'}\n";
+    print STDERR "  previous: $ref->{'previous'}\n";
+    print STDERR "  next: $ref->{'next'}\n";
+    print STDERR "  sort: $ref->{'sort'}\n";
+    print STDERR "  menu:\n   * " . join("\n   * ",@{$ref->{'menu'}}) . "\n" if defined $ref->{'menu'};
   }
 }
 

-- 
linuxdoc-tools package for Debian.



More information about the debian-xml-sgml-commit mailing list