From: Michal Vaner Date: Wed, 10 Sep 2008 18:49:59 +0000 (+0200) Subject: Doc. system: detect type of definition X-Git-Tag: holmes-import~320 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=b5e77aab53699c98d342e91e91d89472efb53c33;p=libucw.git Doc. system: detect type of definition Just heuristics, detects type of the symbol and the name of the symbol. It is used to add semicolon to inline functions what do not have one, but more use of the detection is expected. --- diff --git a/build/doc-extract b/build/doc-extract index ca4e42e2..5373a5a2 100755 --- a/build/doc-extract +++ b/build/doc-extract @@ -22,6 +22,23 @@ if( defined $defdump ) { $hasdump = 1; } +sub detect( $ ) { + ( $_ ) = @_; + my $l = length; + s/\n.*//s; + return( 'struct', 0, $1 ) if( /struct\s+(\w+)\s+{/ ); + return( 'enum', 0, $1 ) if( /enum\s+(\w+)\s+{/ ); + if( $l > length ) { + warn( "Unknown statemen $_\n" ); + return( '', 0, $_ ); + } + return( 'define', 0, $1 ) if( /#define\s+(\w+)/ ); + return( 'function', 1, $1 ) if( /(\w+)\(.*\)/ ); + return( 'variable', 1, $1 ) if( /\s(\w+);/ ); + warn( "Unknown statemen $_\n" ); + return( '', 0, $_ ); +} + my @deps; my $id = 0; @@ -32,7 +49,9 @@ sub formatNote( $$ ) { print OUT "''''\n"; chomp $head; print OUT "[[auto_$id]]\n"; - if($head =~ /\w+\([^()]*\)/ && $head !~ /\n/) { + my( $type, $semicolon, $name ) = detect( $head ); + $head =~ s/;?\s+$/;/ if( $semicolon ); + if( $type eq 'function' ) { print OUT "!!f!$head!!!\n\n"; } else { print OUT "..................\n";