]> mj.ucw.cz Git - libucw.git/blobdiff - build/doc-extract
Opt: Documented opt and its interaction with conf
[libucw.git] / build / doc-extract
index 09145824a43c434c62bcc62596f4accf3fddfe8e..67fdd64cb070ab919fe7de69cc239c8bf39ccd2f 100755 (executable)
@@ -22,21 +22,33 @@ if( defined $defdump ) {
        $hasdump = 1;
 }
 
        $hasdump = 1;
 }
 
+# Function to guess type of statement
 sub detect( $ ) {
        ( $_ ) = @_;
 sub detect( $ ) {
        ( $_ ) = @_;
+       # typedef struct|enum { something } name;
        return( $1, 1, $2, "typedef $1 { ... } $2;" ) if /^\s*typedef\s+(struct|enum)\s*{.*}\s*(\w+)\s*;\s*$/s;
        return( $1, 1, $2, "typedef $1 { ... } $2;" ) if /^\s*typedef\s+(struct|enum)\s*{.*}\s*(\w+)\s*;\s*$/s;
+       # struct|enum name { something };
        return( $1, 1, $2, $_ ) if /^\s*(struct|enum)\s+(\w+)\s*;\s*$/s;
        my $l = length;
        s/\n.*//s;
        return( $1, 1, $2, $_ ) if /^\s*(struct|enum)\s+(\w+)\s*;\s*$/s;
        my $l = length;
        s/\n.*//s;
+       # struct|enum name {
+       #   something
+       # };
        return( $1, 0, $2, $_ ) if /(struct|enum)\s+(\w+)\s+{/;
        return( 'def', 0, $1, $_ ) if /#define\s+(\w+)/;
        if( $l > length ) {
                warn( "Unknown multiline statement $_\n" );
                return( '', 0, $_, $_ );
        }
        return( $1, 0, $2, $_ ) if /(struct|enum)\s+(\w+)\s+{/;
        return( 'def', 0, $1, $_ ) if /#define\s+(\w+)/;
        if( $l > length ) {
                warn( "Unknown multiline statement $_\n" );
                return( '', 0, $_, $_ );
        }
+       # typedef type (*function_type)(params);
        return( 'type', 1, $2, $_ ) if /^\s*typedef[^()]+?(\(\s*?\*\s*?)?(\w+)(\s*\))?\s*\(.*\)/;
        return( 'type', 1, $2, $_ ) if /^\s*typedef[^()]+?(\(\s*?\*\s*?)?(\w+)(\s*\))?\s*\(.*\)/;
+       # type (*function_var)(params);
+       return( 'var', 1, $1, $_ ) if /^.*?\(\*(\w+)\)\(.*\)/;
+       # type function(name);
        return( 'fun', 1, $2, $1 ) if /^(.*?(\w+)\([^{]*\)[^{]*)/;
        return( 'fun', 1, $2, $1 ) if /^(.*?(\w+)\([^{]*\)[^{]*)/;
+       # typedef something name;
        return( 'type', 1, $1, $_ ) if /^\s*typedef.*?(\w+);/;
        return( 'type', 1, $1, $_ ) if /^\s*typedef.*?(\w+);/;
+       # type name;
        return( 'var', 1, $1, $_ ) if /\s\**(\w+);/;
        warn( "Unknown statement $_\n" );
        return( '', 0, $_, $_ );
        return( 'var', 1, $1, $_ ) if /\s\**(\w+);/;
        warn( "Unknown statement $_\n" );
        return( '', 0, $_, $_ );
@@ -56,7 +68,7 @@ sub formatNote( $$ ) {
        $oneline =~ s/\s+$//;
        $oneline =~ s/;?$/;/ if( $semicolon );
        $head =~ s/;?\s*$/;/ if( $semicolon );
        $oneline =~ s/\s+$//;
        $oneline =~ s/;?$/;/ if( $semicolon );
        $head =~ s/;?\s*$/;/ if( $semicolon );
-       $head =~ s/(\.\.\.)/\\$1/g;
+       $head =~ s/(\s|,|\()(\.\.\.)/$1\\$2/g; # Do not convert tripple dot into ellipsis
        print OUT "[[${type}_$name]]\n";
        $head = $oneline if $type eq 'fun';#Remove { from inline functions
        # Remove the generic hack markup
        print OUT "[[${type}_$name]]\n";
        $head = $oneline if $type eq 'fun';#Remove { from inline functions
        # Remove the generic hack markup
@@ -147,9 +159,12 @@ sub process( $$ ) {
                                        $struct = $sdepth = 1;
                                }
                        } elsif( ( $buff ) = ( $line =~ /\/\*\*\*(.*)\*\*\*\// ) ) {
                                        $struct = $sdepth = 1;
                                }
                        } elsif( ( $buff ) = ( $line =~ /\/\*\*\*(.*)\*\*\*\// ) ) {
-                               $buff =~ s/\s?//;
+                               $buff =~ s/^\s?//;
                                print OUT "$buff\n\n";
                                $buff = undef;
                                print OUT "$buff\n\n";
                                $buff = undef;
+                       } elsif( ( $buff ) = ( $line =~ /^\s*\/\*\*(.*)\*\*\// ) ) {
+                               $buff =~ s/^\s*//;
+                               $buff .= "\n";
                        } elsif( ( $head, $buff ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
                                $buff =~ s/^\s*//;
                                $buff =~ s/\s*$//;
                        } elsif( ( $head, $buff ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
                                $buff =~ s/^\s*//;
                                $buff =~ s/\s*$//;