12 my @files_content = ();
20 if ($ARGV[0] eq "-h") {
21 $sourcedir = $ARGV[1];
27 open (FILE, "$dir/api-style.css" || die "Did not find $dir/api-style.css");
32 if ($ARGV[0] eq "-t") {
38 opendir (D, "$sourcedir/sources/") || die "Can not open $dir";
39 while (my $n = readdir (D)) {
40 if ($n =~ /mono-api-.*\.html$/) {
41 open (IN, "$sourcedir/sources/$n") || die "Can not open $n";
42 $files[$filecount] = $n;
43 $files_content[$filecount] = '';
45 $files_content[$filecount] .= $_;
46 if (/name="api:(.*?)"/) {
47 $_ =~ s/.*name="api:(\w+?)".*/$1/;
48 $apis[$filecount] .= "$_";
61 #print "IGNORING: $_";
67 for (my $f = 0; $f < $filecount; $f++) {
68 my $name = $files[$f];
69 open (OUT, "> $dir/html/$name") || die "Can not create $dir/html/$name";
70 print "Merging: $name\n";
72 <?xml version="1.0" encoding="utf-8"?>
73 <html xmlns="http://www.w3.org/1999/xhtml">
76 <style type="text/css">
81 <div class="mapi-docs">
83 my @a = split (/\n/, $files_content[$f]);
87 for (my $ai = 0; $ai < $#a; $ai++) {
89 if (my ($api, $caption) = ($line =~ /<h4><a name=\"api:(\w+)\">(\w+)<\/a><\/h4>/)) {
90 if ($api_shown == 1) {
91 print OUT "</div> <!-- class=mapi -->\n\n";
92 if ($deprecated{$api}) {
93 $strike = "mapi-strike";
94 $strikeextra = "</div><br><div class='mapi-deprecated'><b>Deprecated:</b> " . $deprecated{$api};
101 my $proto = $prototype{$api} // $api;
104 <a name="api:$api"></a>
106 <div class="mapi-entry $strike"><code>$api$strikeextra</code></div>
107 <div class="mapi-height-container">
108 <div class="mapi-ptr-container"></div>
109 <div class="mapi-description">
110 <div class="mapi-ptr"></div>
112 <div class="mapi-declaration mapi-section">Syntax</div>
113 <div class="mapi-prototype">$proto</div>
116 if (exists ($arguments{$api})) {
117 my $ppars = $arguments{$api};
118 if ($ppars !~ /^[ \t]+$/) {
119 print OUT " <div class=\"mapi-section\">Parameters</div>\n";
120 print OUT " <table class=\"mapi-parameters\"><tbody>".${arguments{$api}}."</tbody></table>";
124 &opt_print ("Return value", $returns{$api}, 0);
125 &opt_print ("Description", $bodies{$api}, 0);
126 print OUT " </div><!--mapi-description-->\n </div><!--height container-->\n";
128 if ($line =~ /\@API_IDX\@/) {
129 my $apis_toc = &create_toc ($apis[$f]);
130 $line =~ s/\@API_IDX\@/$apis_toc/;
132 if ($line =~ /^<h4/) {
133 print OUT "</div>\n";
147 system ("$ENV{runtimedir}/mono-wrapper convert.exe $dir/html/$name $dir/html/x-$name");
150 # clean up the mess that AgilityPack does, it CDATAs our CSS
151 open HACK, "$dir/html/x-$name" || die "Could not open $dir/html/x-$name";
152 open HACKOUT, ">$dir/deploy/$name" || die "Could not open output";
157 print HACKOUT $last if ($doprint);
159 s/^\/\/<!\[CDATA\[//;
162 # Remove the junk <span> wrapper generated by AgilityPack
167 # Replace the CSS in the XHTML output with the original CSS
171 last if (/<\/style>/);
177 if (!($last =~ /span/)) {
181 # system ("cp.exe $dir/html/$name $dir/deploy/$name");
191 print "Function: $func\n" if (!$html);
199 s/NULL/<code>NULL<\/code>/g;
200 s/TRUE/<code>TRUE<\/code>/g;
201 s/FALSE/<code>FALSE<\/code>/g;
203 $body =~ s/\@(\w+)/<i>$1<\/i>/g;
204 $returns =~ s/\@(\w+)/<i>$1<\/i>/g;
205 $args =~ s/\@(\w+)/<i>$1<\/i>/g;
207 $body =~ s/#(\w+)/<code>$1<\/code>/g;
208 $returns =~ s/#(\w+)/<code>$1<\/code>/g;
209 $args =~ s/#(\w+)/<code>$1<\/code>/g;
211 $returns =~ s/\`([:.\w\*]+)\`/<code>$1<\/code>/g;
212 $args =~ s/\`([:.\w\*]+)\`/<code>$1<\/code>/g;
213 $body =~ s/\`([:.\w\*]+)\`/<code>$1<\/code>/g;
216 $bodies{$func} = $body;
217 $arguments{$func} = $args;
218 $deprecated{$func} = $deprecated;
219 $returns{$func} = $returns;
226 # clean it up a little, remove newlines, empty space at end
228 # Turn "Type * xxx" into "Type* xxx"
229 $proto =~ s/^(\w+)\W+\*/$1\*/;
230 $prototype{$func} = $proto;
235 $_ = "<p>" if (/^\s*$/);
238 if (/\s*(\w+):(.*)/) {
239 if ($1 eq "deprecated") {
242 # $args .= "<dt><i>$1:</i></dt><dd>$2</dd>";
243 $args .= "<tr><td><i>$1</i><td>$2</td></td></tr>";
251 } elsif ($inbody == 1) {
260 $returns .= "\n\t$_";
267 my ($apis_listed) = @_;
270 my ($ret, $xname, $args);
274 # Try to align things, so compute type size, method size, and arguments
275 foreach my $line (split /\n/, $apis_listed) {
276 if (exists ($prototype{$line})) {
277 my $p = $prototype{$line};
278 if (my ($ret, $xname, $args) = ($p =~ /(.*)\n(\w+)[ \t](.*)/)) {
279 my $tl = length ($ret);
280 my $pl = length ($xname);
281 $type_size = $tl if ($tl > $type_size);
282 $name_size = $pl if ($pl > $name_size);
290 foreach my $line (split /\n/, $apis_listed) {
292 if (exists($prototype{$line})) {
293 my $p = $prototype{$line};
294 if (my ($ret, $xname, $args) = ($p =~ /(.*)\n(\w+)[ \t](.*)/)) {
295 $xname = $line if $xname eq "";
296 my $rspace = " " x ($type_size - length ($ret));
297 my $nspace = " " x ($name_size - length ($xname));
298 $args = &format ($args, length ($ret . $rspace . $xname . $nspace), 60);
299 $apis_toc .= "$ret$rspace<a href=\"\#api:$line\">$xname</a>$nspace$args\n";
307 # Formats the rest of the arguments in a way that will fit in N columns
310 my ($args, $size, $limit) = @_;
313 # return $args if ((length (args) + size) < $limit);
315 my $remain = $limit - $size;
316 my @sa = split /,/, $args;
318 foreach my $arg (@sa) {
321 $linelen += length ($sret);
323 if ($linelen + length ($arg) < $limit) {
324 $sret .= "FITS" . $arg . ", ";
326 my $newline = " " x ($size) . $arg . ", ";
327 my $linelen = length ($newline);
328 $sret .= "\n" . $newline;
337 my ($caption, $opttext, $quote) = @_;
339 if (defined($opttext) && $opttext !~ /^[ \t]+$/) {
340 print OUT " <div class=\"mapi-section\">$caption</div>\n";
341 print OUT " <div>$opttext</div>\n";