]> mj.ucw.cz Git - libucw.git/blobdiff - build/doc-extract
ucw docs: Move the list of undocumented modules
[libucw.git] / build / doc-extract
index 8b512da9c9deaa7452ff50bb8d90587e292d790d..e20e7a941ce3c9b3088764a5950341c88b4885c6 100755 (executable)
@@ -24,17 +24,16 @@ if( defined $defdump ) {
 
 sub detect( $ ) {
        ( $_ ) = @_;
-       return( 'struct', 1, $1, "typedef struct { ... } $1;" ) if /^\s*typedef\s+struct\s*{.*}\s*(\w+)\s*;\s*$/s;
-       return( 'enum', 1, $1, "typedef enum { ... } $1;" ) if /^\s*typedef\s+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;
+       return( $1, 1, $2, $_ ) if /^\s*(struct|enum)\s+(\w+)\s*;\s*$/s;
        my $l = length;
        s/\n.*//s;
-       return( 'struct', 0, $1, $_ ) if /struct\s+(\w+)\s+{/;
-       return( 'enum', 0, $1, $_ ) if /enum\s+(\w+)\s+{/;
+       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( 'def', 0, $1, $_ ) if /#define\s+(\w+)/;
        return( 'type', 1, $2, $_ ) if /^\s*typedef[^()]+?(\(\s*?\*\s*?)?(\w+)(\s*\))?\s*\(.*\)/;
        return( 'fun', 1, $2, $1 ) if /^(.*?(\w+)\([^{]*\)[^{]*)/;
        return( 'type', 1, $1, $_ ) if /^\s*typedef.*?(\w+);/;
@@ -78,9 +77,18 @@ sub process( $ ) {
        my $buff;
        my $head;
        my $struct;
+       my $def;
        while( defined( $line = <FILE> ) ) {
                chomp $line;
-               if( $struct ) {
+               if( $def ) {
+                       $head .= "\n".$line;
+                       $line =~ s/(\/\*.*?\*\/|\/\/.*)//g;
+                       if( $line !~ /\\\s*$/ ) {
+                               formatNote( $head, $buff );
+                               $def = 0;
+                               $buff = $head = undef;
+                       }
+               } elsif( $struct ) {
                        $head .= "\n".$line;
                        if( $line =~ /}/ ) {
                                formatNote( $head, $buff );
@@ -105,7 +113,10 @@ sub process( $ ) {
                        }
                } else {
                        if( ( $line =~ /\S/ ) && ( defined $buff ) ) {
-                               if( $line =~ /\(/ || $line !~ /{/ ) {
+                               if( $line =~ /^\s*#define.*\\(\s*(\/\/.*|\/\*.*?\*\/|))*/ ) {
+                                       $head = $line;
+                                       $def = 1;
+                               } elsif( $line =~ /\(/ || $line !~ /{/ || $line =~ /^\s*#define/ ) {
                                        $_ = $line;
                                        s/^\s*\s?//;
                                        s/\/\/.*//;
@@ -124,7 +135,7 @@ sub process( $ ) {
                        } elsif( ( $head, $buff ) = ( $line =~ /^(.*)\/\*\*(.*)\*\*\// ) ) {
                                $buff =~ s/^\s*//;
                                $buff =~ s/\s*$//;
-                               if( $head =~ /\(/ || $head !~ /{/ ) {
+                               if( $head =~ /\(/ || $head !~ /{/ || $head =~/}/ ) {
                                        $head =~ s/^\s*//;
                                        $head =~ s/\/\*.*?\*\///gs;
                                        formatNote( $head, $buff );