]> git.sur5r.net Git - bacula/docs/blobdiff - docs/tools/translatedoc.pl
This patch fix the bug referenced as https://bugs.baculasystems.com/view.php?id=23...
[bacula/docs] / docs / tools / translatedoc.pl
index 4b11848e4074932647f6ca7bf0db49834973ca57..282052650c45c972399edb23dc90cf72cf4b38d9 100755 (executable)
@@ -57,89 +57,6 @@ sub debugdump {
     }
 }
 #
-# Build a references list
-# Needed to link text and tables, images and so on (see figure xxx)
-# with an HTML href
-# IN: root dir and reference filename
-# OUT: a reference file (ako hash)
-# =======================
-sub build_references {
-    my $root = $_[0] ;
-    my $referencefile = $_[1] ;
-    print "Root dir: $root\n" ;
-    print "References file: $referencefile" ;
-    my %references ;
-    my @content ;
-    local *FH ;
-    for my $i (`find $root -iname "[a-zA-Z0-9]*.aux"`) {
-       print "Building references for $i\n" ;
-       open FH, "< $i" or die "Unable to open file $i\n" ;
-       @content = <FH> ;
-       close FH ;
-       for $l (@content) {
-           if ($l =~ /newlabel/) {
-### \newlabel{figbs6:fdstorageaddress}{{2.1}{15}{Backup Over WAN\relax \relax }{figure.caption.15}{}}
-               my @elts = split('{|}',$l) ;
-               if ($#elts >4) {
-                   if ($elts[1] ne "" and $elts[4] ne "") {
-                       print "Clef: $elts[1]\n" ;
-                       chomp($i) ;
-                       chomp($elts[1]) ;
-                       chomp($elts[4]) ;
-                       $references{$elts[1]}{anchor} = $elts[4] ;
-                       $references{$elts[1]}{file} = "" ;
-                       $references{$elts[4]}{latexref} = $elts[1] ;
-                   }
-               }
-           }
-       }
-    }
-    for my $i (`find $root -iname "[a-zA-Z0-9]*.html"`) {
-       print "Building anchors for $i\n" ;
-       open FH, "< $i" or die "Unable to open file $i\n" ;
-       @content = <FH> ;
-       close FH ;
-       foreach $l (@content) {
-#          print "ligne: $l\n" ;
-           if ($l =~ m/<A [^>]*NAME *= *"([^>]*)"/) {
-               chomp($l) ;
-               print "L matche: $l / $1\n" ;
-               if (exists $references{$1}{latexref}) {
-                   print "Bingo: $i --- " . $references{$1}{latexref} . "\n" ;
-                   $references{$references{$1}{latexref}}{file} = $i ;
-               }
-           }
-       }
-    }
-    print "Writing references\n" ;
-    open FH,"> $referencefile" or die "Unable to create file $referencefile\n" ;
-    foreach $k (keys %references) {
-       if ($references{$k}{file} ne "") {
-           print "Key: $k\n" ;
-           print FH $k . " " . $references{$k}{file} . " " . $references{$k}{anchor} . "\n" ;
-       }
-    }
-    close FH ;
-    return %references ;
-}
-#
-# References reading method
-# To be able to handle references accross HTML files
-# =========================
-sub read_references {
-    my $referencefile = $_[0] ;
-    my %references ;
-    local *FH ;
-    open FH, "< $referencefile" or die "Unable to open $referencefile\n" ;
-    while (<FH>) {
-       our($k,$f,$v) = split / /,$_ ;
-       $refences{$k}{file} = $f ;
-       $refences{$k}{anchor} = $v ;
-    }
-    close FH ;
-    return %refences ;
-}
-#
 # Args to Vars
 our($inputfile,$outputfile,$help,$debug,$mytree,$extractmenu,$picturesdir,
     $cssdir,$javascriptdir,$manualname,$sourcedir) ;
@@ -182,14 +99,6 @@ if (! defined $manualname) {
     $manualname = "main" ;
 }
 my $MENUFILE="./wholemenu_" . $manualname . ".html" ;
-# my $REFERENCEFILE="./references_to_build.txt" ;
-# my %references ;
-# if (defined $sourcedir) {
-#     %references = build_references($sourcedir,$REFERENCEFILE) ;
-# }
-# else {
-#     %references = read_references($REFERENCEFILE) ;
-# }
 #
 # Build HTML Tree of existing page
 $mytree = HTML::TreeBuilder->new ;
@@ -509,34 +418,27 @@ foreach $childlinks (@images) {
        $img =~ s/\.\/// ;
        $img = $picturesdir . '/' . $img ;
        $childlinks->attr('src',$img) ;
-       print "img: " . $img . "\n" ;
+#      print "img: " . $img . "\n" ;
+    }
+}
+#
+# Locate all <a name="whatever_but_SECTION...">
+my @atags = $mytree->look_down('_tag','a') ;
+local *AFH ;
+open AFH, ">> list-of-anchors" or die "Unable to append to list-of-anchors file\n"; 
+foreach $childlinks (@atags) {
+    my $atagname ;
+    if ($atagname = $childlinks->attr('name')) {
+       print AFH $manualname . "\t" . basename($inputfile) . "\t" . $atagname . "\n" ;
     }
 }
+close AFH ;
 # This li is at first level
 if ($outputfile) {
     local *FH ;
     open FH, ">" . $outputfile or die "Unable to create $outputfile: $!\n" ;
     print FH $mytree->as_HTML("<>","\t",{}) ;
     close FH ;
-#     open FH, "< $outputfile" or die "Unable to open $outputfile\n" ;
-#     my @content ;
-#     while (my $l = <FH>) {
-#      foreach my $k (keys %references) {
-# #        print "==> The Clef: $k\n" ;
-#          my $anchor = sprintf("<a href=\"%s#%s\">%s</a>",
-#                               $references{$k}{file},
-#                               $references{$k}{anchor},
-#                               $k) ;
-#          $l =~ s/$k/$anchor/g ;
-#      }
-#      push @content,$l ;
-#     }
-#     close FH ;
-#     open FH, ">" . $outputfile or die "Unable to create $outputfile: $!\n" ;
-#     for $l (@content) {
-#      print FH $l ;
-#     }
-#     close FH ;
 }
 else {
     print $mytree->as_HTML("","\t",{}) ;