]> mj.ucw.cz Git - libucw.git/blobdiff - build/doc-extract
Doc. system: export type and name do deflists
[libucw.git] / build / doc-extract
index ca4e42e2874fb771ae0b5b0d7aba25206093dafb..85c3ba299e6e99b26f1e6e333a85fc9e7983f2a9 100755 (executable)
@@ -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";
@@ -41,7 +60,7 @@ sub formatNote( $$ ) {
        }
        if( $hasdump ) {
                $head =~ s/\n.*//s;
-               print DUMP "$outname,$id,$head\n";
+               print DUMP "$outname,$id,$type,$name,$head\n";
                $id ++;
        }
        print OUT "$comment\n\n";
@@ -88,8 +107,6 @@ sub process( $ ) {
                                        s/^\s*\s?//;
                                        s/\/\/.*//;
                                        s/\/\*.*?\*\///gs;
-                                       s/([;{]).*/";"x length( $1 )/e;
-                                       s/\)\s*;$/);/;
                                        formatNote( $_, $buff );
                                        $head = undef;
                                        $buff = undef;
@@ -107,8 +124,6 @@ sub process( $ ) {
                                if( $head =~ /\(/ || $head !~ /{/ ) {
                                        $head =~ s/^\s*//;
                                        $head =~ s/\/\*.*?\*\///gs;
-                                       $head =~ s/([;{]).*/";"x length( $1 )/e;
-                                       $head =~ s/\)\s*;$/);/;
                                        formatNote( $head, $buff );
                                        $head = undef;
                                        $buff = undef;