X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=build%2Fdoc-extract;h=09145824a43c434c62bcc62596f4accf3fddfe8e;hb=b56cd57bdce6b573ac0fc973ba4d16057c1e2ca5;hp=e20e7a941ce3c9b3088764a5950341c88b4885c6;hpb=8cb58409406045bf50c67f4b0988a2e7b189b550;p=libucw.git diff --git a/build/doc-extract b/build/doc-extract index e20e7a94..09145824 100755 --- a/build/doc-extract +++ b/build/doc-extract @@ -52,24 +52,36 @@ sub formatNote( $$ ) { print OUT "''''\n"; chomp $head; my( $type, $semicolon, $name, $oneline ) = detect( $head ); + # Just few transformations of the result $oneline =~ s/\s+$//; $oneline =~ s/;?$/;/ if( $semicolon ); $head =~ s/;?\s*$/;/ if( $semicolon ); $head =~ s/(\.\.\.)/\\$1/g; print OUT "[[${type}_$name]]\n"; $head = $oneline if $type eq 'fun';#Remove { from inline functions + # Remove the generic hack markup + $head =~ s/_OPEN_PAREN_/(/g; + $head =~ s/_CLOSE_PAREN_/)/g; print OUT "..................\n"; print OUT "$head\n"; print OUT "..................\n\n"; if( $hasdump ) { - print DUMP "$outname,${type}_$name,$type,$name,$oneline\n"; + $oneline =~ s/_OPEN_PAREN_/(/g; + $oneline =~ s/_CLOSE_PAREN_/)/g; + my $symname = $type.'_'.$name; + $name =~ s/_OPEN_PAREN_/(/g; + $name =~ s/_CLOSE_PAREN_/)/g; + print DUMP "$outname,$symname,$type,$name,$oneline\n"; $id ++; } + $comment =~ s/_OPEN_PAREN_/(/g; + $comment =~ s/_CLOSE_PAREN_/)/g; + $comment =~ s/_GENERIC_LINK_\|([^|]+)\|([^|]+)\|/${1}_OPEN_PAREN_${2}_CLOSE_PAREN_/g; print OUT "$comment\n\n"; } -sub process( $ ) { - my $file = shift; +sub process( $$ ) { + my( $file, $prefixes ) = @_; open FILE, $file or die "Could nod read $file ($!)\n"; my $line; my $active; @@ -78,8 +90,11 @@ sub process( $ ) { my $head; my $struct; my $def; + my $sdepth; while( defined( $line = ) ) { chomp $line; + # Generic macro hack - replaces the parenthesis so it is valid identifier + $line =~ s/$_\(([^()]+)\)/${_}_OPEN_PAREN_${1}_CLOSE_PAREN_/g foreach @{$prefixes}; if( $def ) { $head .= "\n".$line; $line =~ s/(\/\*.*?\*\/|\/\/.*)//g; @@ -90,7 +105,10 @@ sub process( $ ) { } } elsif( $struct ) { $head .= "\n".$line; - if( $line =~ /}/ ) { + my $cp = $line; + $sdepth += ($cp =~ tr/{//); + $sdepth -= ($cp =~ tr/}//); + if( !$sdepth ) { formatNote( $head, $buff ); $struct = 0; $buff = undef; @@ -126,7 +144,7 @@ sub process( $ ) { $buff = undef; } else { $head = $line; - $struct = 1; + $struct = $sdepth = 1; } } elsif( ( $buff ) = ( $line =~ /\/\*\*\*(.*)\*\*\*\// ) ) { $buff =~ s/\s?//; @@ -142,7 +160,7 @@ sub process( $ ) { $head = undef; $buff = undef; } else { - $struct = 1; + $struct = $sdepth = 1; } } elsif( $line =~ /\/\*\*\*/ ) { $verbatim = 1; @@ -157,9 +175,13 @@ sub process( $ ) { my $line; while( defined( $line = ) ) { chomp $line; - if( my( $fname ) = ( $line =~ /^!!\s*(.*\S)/ ) ) { + my $prefixes; + if( my( $fname, $prefixes ) = ( $line =~ /^!!\s*(\S+)(.*)/ ) ) { $fname = "$basedir/$fname" if( ( $fname !~ /^\// ) && defined $basedir ); - process( $fname ); + process( $fname, [ ( map( { + my( $result ) = /^\s*(.*\S)\s*$/; + $result; + } ( split /,/, $prefixes ) ) ) ] ); push @deps, $fname; } else { print OUT "$line\n";