#!/usr/bin/perl if ($ARGV[0] eq "-h"){ $dir = $ARGV[1]; $html = 1; shift @ARGV; shift @ARGV; } if ($html){ opendir (D, "$dir/sources/") || die "Can not open $dir"; while ($n = readdir (D)){ if ($n =~ /mono-api-.*\.html$/){ open (IN, "$dir/sources/$n") || die "Can not open $n"; $files[$filecount] = $n; while (){ @files_content[$filecount] .= $_; } $filecount++; close IN; } } } while (){ if (/\/\*\* *\n/){ &process_doc; } else { #print "IGNORING: $_"; } } if ($html){ for ($f = 0; $f < $filecount; $f++){ $name = $files[$f]; open (OUT, "> $dir/html/$name") || die "Can not create $dir/html/$name"; print "Merging: $name\n"; print OUT< $name EOF @a = split (/\n/, $files_content[$f]); for ($ai = 0; $ai < $#a; $ai++){ $line = $a[$ai]; ($api,$caption) = $line =~ /

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

$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 "
"; } print OUT "\n"; print OUT ""; } else { print OUT "$line\n"; } } print OUT< EOF close OUT; system ("mono convert.exe $dir/html/$name $dir/deploy/$name"); } } sub process_doc { $doc = ""; $func = <>; chop $func; $func =~ s/^ \* //; $func =~ s/:$//; print "Function: $func\n" if (!$html); $args = ""; $inbody = 0; $returns = ""; $body = ""; $functions[$fn++] = $func; # Process arguments while (<>){ if (/^ \*\*?\//){ $body =~ s/[@#](\w+)/\1<\/i>/g; $returns =~ s/[@#](\w+)/\1<\/i>/g; $args =~ s/@(\w+)/\1<\/i>/g; $bodies{$func} = $body; $arguments{$func} = $args; $returns{$func} = $returns; $proto = ""; while (<>){ $proto .= $_; last if (/\{/); } $proto =~ s/{//; $prototype{$func} = $proto; return; } chop; s/^\ \*//; $_ = "\n

" if (/^\s+$/); if ($inbody == 0){ if (/\s*(\w+):(.*)/){ $args .= "

$1:
$2
"; } else { $body = "\t$_\n"; $inbody = 1; } } elsif ($inbody == 1) { if (/Returns:/){ s/Returns://; $returns = "\t$_\n"; $inbody = 2; } else { $body .= "\n\t$_"; } } else { $returns .= "\n\t$_"; } } }