From 1b948d534c6e1053e7a4c13baa056cc052ac2873 Mon Sep 17 00:00:00 2001 From: Michal Vaner Date: Sun, 7 Sep 2008 11:43:27 +0200 Subject: [PATCH] Documentation system: teach extractor dump defs If provided with another file name, it dumps all definitions with filename, id number and text --- build/extract-doc.pl | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/build/extract-doc.pl b/build/extract-doc.pl index b4ea259c..a8314a97 100755 --- a/build/extract-doc.pl +++ b/build/extract-doc.pl @@ -5,7 +5,7 @@ use strict; use warnings; -my( $inname, $outname, $depname, $basedir ) = @ARGV; +my( $inname, $outname, $depname, $basedir, $defdump ) = @ARGV; if( defined $inname ) { open IN, $inname or die "Could not read $inname ($!)\n"; } else { @@ -16,13 +16,14 @@ if( defined $outname ) { } else { open OUT, ">&STDOUT" or die "Could not write to stdout ($!)\n"; } -my $hasdep; -if( defined $depname ) { - open DEP, ">>$depname" or die "Could not write $depname ($!)\n"; - $hasdep = 1; +my $hasdump; +if( defined $defdump ) { + open DUMP, ">>$defdump" or die "Could not write definition dump $defdump ($!)\n"; + $hasdump = 1; } -print DEP "$outname:" if( $hasdep ); +my @deps; +my $id = 0; sub formatNote( $$ ) { my( $head, $comment ) = @_; @@ -30,6 +31,7 @@ sub formatNote( $$ ) { print OUT "\n"; print OUT "''''\n"; chomp $head; + print OUT "[[auto_$id]]\n"; if($head =~ /\w+\([^()]*\)/ && $head !~ /\n/) { print OUT "!!f!$head!!!\n\n"; } else { @@ -37,6 +39,11 @@ sub formatNote( $$ ) { print OUT "$head\n"; print OUT "..................\n\n"; } + if( $hasdump ) { + $head =~ s/\n.*//s; + print DUMP "$outname,$id,$head\n"; + $id ++; + } print OUT "$comment\n\n"; } @@ -124,14 +131,25 @@ while( defined( $line = ) ) { if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) { $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir ); process( $fname ); - print DEP " $fname" if( $hasdep ); + push @deps, $fname; } else { print OUT "$line\n"; } } -print DEP "\n" if( $hasdep ); +if( defined $depname ) { + open DEP, ">$depname" or die "Could not write dep file $depname ($!)\n"; + print DEP "$outname:"; + print DEP " $_" foreach( @deps ); + print DEP "\n"; + if( $hasdump ) { + print DEP "$defdump:"; + print DEP " $_" foreach( @deps ); + print DEP "\n"; + } + close DEP; +} close IN; close OUT; -close DEP; +close DUMP; -- 2.39.5