docgen.pl
changeset 4 5770be2d5f3f
parent 0 84fdfb0344c9
child 17 ab4470465a0c
--- a/docgen.pl	Mon Feb 09 13:39:36 2009 +0200
+++ b/docgen.pl	Sat Feb 14 16:40:09 2009 +0200
@@ -6,6 +6,8 @@
 my %docs;
 my @tags;
 my $inside;
+my $harvest;
+my @values;
 
 foreach my $file (@ARGV) {
 	if ( not open SOURCE, '<', $file ) {
@@ -20,9 +22,21 @@
 			if ( not /^\/\/\// ) {
 				$inside = 0;
 				$chunk++;
+			} elsif ( /^\/\/\/ G:/ ) {
+				$inside = 0;
+				$harvest = 'V: ' . substr ( $_, 6 );
 			} else {
 				push @{$docs{$file}[$chunk]}, substr ( $_, 4 );
 			}
+		} elsif ( $harvest ) {
+			if ( /\{\s*NULL.*\}/ ) {
+				push @{$docs{$file}[$chunk]}, $harvest . ' ' . join ( ', ', @values );
+				$harvest = undef;
+				@values  = ();
+				$chunk++;
+			} elsif ( /\{\s*"(.+)".*\}/ ) {
+				push @values, $1;
+			}
 		} else {
 			next if not /^\/\/\//;
 
@@ -57,12 +71,24 @@
 	foreach my $chunk ( @{$docs{$file}} ) {
 		my $head = shift @$chunk;
 		my $tag  = $head;
+		my $list = undef;
 		$tag =~ s/_/./g;
 		print "<a name='$tag'></a><h2>$head</h2><p>";
 		foreach ( @$chunk ) {
 			s/^A: /<br\/>Arguments: /;
 			s/^R: /<br\/>Return values: /;
 			s/^V: /<br\/>Values: /;
+			if ( $list ) {
+				if ( /^\* / ) {
+					s/^\* /<\/li><li>/;
+				} else {
+					s/^/<\/li><\/ul> /;
+					$list = undef;
+				}
+			} elsif ( /^\* / ) {
+				s/^\* /<ul><li>/;
+				$list = 1;
+			}
 			foreach my $tag ( @tags ) {
 				# TODO quotemeta required, but for now
 				# this bug is rather desired...
@@ -71,6 +97,7 @@
 			}
 			print $_;
 		}
+		print "</li></ul>" if $list;
 		print "</p>"
 	}
 	print "<hr>";