X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fdocscripts%2Fexdoc;h=7369f97c7c61e6893c01f40d481d7d723ff20094;hb=881f83658281916d8f0784df7c726ecb7cc289db;hp=93824405a04fa1468d52e35e68af22bdea7401b7;hpb=c4a3b30460c7ea1a1fb3c97cfc8478555714af2f;p=mono.git diff --git a/mono/docscripts/exdoc b/mono/docscripts/exdoc index 93824405a04..7369f97c7c6 100644 --- a/mono/docscripts/exdoc +++ b/mono/docscripts/exdoc @@ -15,6 +15,10 @@ if ($html){ $files[$filecount] = $n; while (){ @files_content[$filecount] .= $_; + if (/name="api:(.*?)"/){ + $_ =~ s/.*name="api:(\w+?)".*/\1/; + $apis[$filecount] .= "$_"; + } } $filecount++; close IN; @@ -40,6 +44,48 @@ if ($html){ $name + EOF @@ -47,58 +93,40 @@ EOF for ($ai = 0; $ai < $#a; $ai++){ $line = $a[$ai]; - + ($api,$caption) = $line =~ /

(\w+)<\/a><\/h4>/; if ($api ne ""){ + if ($api_shown == 1){ + print OUT ""; + } + $api_shown = 1; $proto = $prototype{$api}; if ($proto eq ""){ $proto = "Prototype: $api"; } print OUT< - - - -
-

$api

-
- -
- - -
- - -
-

$proto

-
-
-
+ +
+
$api
+ +
$proto

EOF - if ($arguments{$api} ne ""){ - print OUT "

Parameters

"; - print OUT "
"; - - print OUT "$arguments{$api}\n"; - print OUT "
"; - } - if ($returns{$api} ne ""){ - print OUT "

Returns

"; - print OUT "
"; - print OUT "$returns{$api}\n"; - print OUT "
"; - } - if ($bodies{$api} ne ""){ - print OUT "

Remarks

"; - print OUT "
"; - print OUT "$bodies{$api}\n"; - print OUT "
"; - } + &opt_print ("Parameters", $arguments{$api}, 1); + &opt_print ("Returns", $returns{$api}, 1); + &opt_print ("Remarks", $bodies{$api}, 0); print OUT "\n"; - print OUT ""; } else { + if ($line =~ /@API_IDX@/){ + $apis_toc = &create_toc ($apis[$f]); + $line =~ s/\@API_IDX\@/$apis_toc/; + } + if ($line =~ /^"; + $api_shown = 0; + } + print OUT "$line\n"; } } @@ -107,7 +135,18 @@ EOF EOF close OUT; - system ("mono convert.exe $dir/html/$name $dir/deploy/$name"); + system ("mono convert.exe $dir/html/$name $dir/html/x-$name"); + + # clean up the mess that AgilityPack does, it CDATAs our CSS + open HACK, "$dir/html/x-$name" || die "Could not open $dir/html/x-$name"; + open HACKOUT, ">$dir/deploy/$name" || die "Could not open output"; + + while (){ + s/^\/\/\/\///; + print HACKOUT $_; + } + #system ("cp.exe $dir/html/$name $dir/deploy/$name"); } } @@ -131,6 +170,7 @@ sub process_doc { $returns =~ s/[@#](\w+)/\1<\/i>/g; $args =~ s/@(\w+)/\1<\/i>/g; + $body =~ s/\n/ /; $bodies{$func} = $body; $arguments{$func} = $args; $returns{$func} = $returns; @@ -140,6 +180,10 @@ sub process_doc { last if (/\{/); } $proto =~ s/{//; + # clean it up a little, remove newlines, empty space at end + $proto =~ s/ +$//; + # Turn "Type * xxx" into "Type* xxx" + $proto =~ s/^(\w+)\W+\*/\1\*/; $prototype{$func} = $proto; return; } @@ -156,8 +200,8 @@ sub process_doc { $inbody = 1; } } elsif ($inbody == 1) { - if (/Returns:/){ - s/Returns://; + if (/Returns?:/){ + s/Returns?://; $returns = "\t$_\n"; $inbody = 2; } else { @@ -169,3 +213,81 @@ sub process_doc { } } + +sub create_toc { + my ($apis_listed) = @_; + my $type_size = 0; + my $name_size = 0; + my $ret, $xname, $args, $line; + $apis_toc = ""; + + + # Try to align things, so compute type size, method size, and arguments + foreach $line (split /\n/, $apis_listed){ + $p = $prototype{$line}; + ($ret, $xname, $args) = $p =~ /(.*)\n(\w+)[ \t](.*)/; + $tl = length ($ret); + $pl = length ($xname); + + $type_size = $tl if ($tl > $type_size); + $name_size = $pl if ($pl > $name_size); + } + + $type_size++; + $name_size++; + + foreach $line (split /\n/, $apis_listed){ + chop; + $p = $prototype{$line}; + ($ret, $xname, $args) = $p =~ /(.*)\n(\w+)[ \t](.*)/; + + $rspace = " " x ($type_size - length ($ret)); + $nspace = " " x ($name_size - length ($xname)); + $args = &format ($args, length ($ret . $rspace . $xname . $nspace), 60); + $apis_toc .= "$ret$rspace$xname$nspace$args\n"; + } + return $apis_toc; +} + +# +# Formats the rest of the arguments in a way that will fit in N columns +# +sub format { + my ($args, $size, $limit) = @_; + my $sret = ""; + +# return $args if ((length (args) + size) < $limit); + + $remain = $limit - $size; + @sa = split /,/, $args; + $linelen = $size; + foreach $arg (@sa){ + if ($sret eq ""){ + $sret = $arg . ", "; + $linelen += length ($sret); + } else { + if ($linelen + length ($arg) < $limit){ + $sret .= "FITS" . $arg . ", "; + } else { + $newline = " " x ($size) . $arg . ", "; + $linelen = length ($newline); + $sret .= "\n" . $newline; + } + } + } + $sret =~ s/, $/;/; + return $sret; +} + +sub opt_print { + my ($caption, $opttext, $quote) = @_; + + if ($opttext ne "" && (!($opttext =~ /^[ \t]+$/))){ + print OUT "$caption\n"; + if ($quote == 1){ + print OUT "
$opttext
\n"; + } else { + print OUT "

$opttext\n"; + } + } +}