10 open (FILE, "$dir/api-style.css" || die "Did not find $dir/api-style.css");
15 if ($ARGV[0] eq "-t"){
21 opendir (D, "$sourcedir/sources/") || die "Can not open $dir";
22 while ($n = readdir (D)){
23 if ($n =~ /mono-api-.*\.html$/){
24 open (IN, "$sourcedir/sources/$n") || die "Can not open $n";
25 $files[$filecount] = $n;
27 @files_content[$filecount] .= $_;
28 if (/name="api:(.*?)"/){
29 $_ =~ s/.*name="api:(\w+?)".*/\1/;
30 $apis[$filecount] .= "$_";
43 #print "IGNORING: $_";
48 for ($f = 0; $f < $filecount; $f++){
50 open (OUT, "> $dir/html/$name") || die "Can not create $dir/html/$name";
51 print "Merging: $name\n";
53 <?xml version="1.0" encoding="utf-8"?>
54 <html xmlns="http://www.w3.org/1999/xhtml">
57 <style type="text/css">
62 <div class="mapi-docs">
64 @a = split (/\n/, $files_content[$f]);
66 for ($ai = 0; $ai < $#a; $ai++){
69 ($api,$caption) = $line =~ /<h4><a name=\"api:(\w+)\">(\w+)<\/a><\/h4>/;
72 print OUT "</div> <!-- class=mapi -->\n\n";
73 if ($deprecated{$api}){
74 $strike = "mapi-strike";
75 $strikeextra = "</div><br><div class='mapi-deprecated'><b>Deprecated:</b> " . $deprecated{$api};
82 $proto = $prototype{$api};
88 <a name="api:$api"></a>
90 <div class="mapi-entry $strike"><code>$api$strikeextra</code></div>
91 <div class="mapi-height-container">
92 <div class="mapi-ptr-container"></div>
93 <div class="mapi-description">
94 <div class="mapi-ptr"></div>
96 <div class="mapi-declaration mapi-section">Syntax</div>
97 <div class="mapi-prototype">$proto</div>
100 $ppars = $arguments{$api};
101 if ($ppars ne "" && (!($ppars =~ /^[ \t]+$/))){
102 print OUT " <div class=\"mapi-section\">Parameters</div>\n";
103 print OUT " <table class=\"mapi-parameters\"><tbody>".${arguments{$api}}."</tbody></table>";
106 &opt_print ("Return value", $returns{$api}, 0);
107 &opt_print ("Description", $bodies{$api}, 0);
108 print OUT " </div><!--mapi-description-->\n </div><!--height container-->\n";
110 if ($line =~ /@API_IDX@/){
111 $apis_toc = &create_toc ($apis[$f]);
112 $line =~ s/\@API_IDX\@/$apis_toc/;
114 if ($line =~ /^<h4/){
115 print OUT "</div>\n";
129 system ("$ENV{runtimedir}/mono-wrapper convert.exe $dir/html/$name $dir/html/x-$name");
132 # clean up the mess that AgilityPack does, it CDATAs our CSS
133 open HACK, "$dir/html/x-$name" || die "Could not open $dir/html/x-$name";
134 open HACKOUT, ">$dir/deploy/$name" || die "Could not open output";
139 s/^\/\/<!\[CDATA\[//;
142 # Remove the junk <span> wrapper generated by AgilityPack
147 # Replace the CSS in the XHTML output with the original CSS
151 last if (/<\/style>/);
157 #system ("cp.exe $dir/html/$name $dir/deploy/$name");
167 print "Function: $func\n" if (!$html);
172 $functions[$fn++] = $func;
177 s/NULL/<code>NULL<\/code>/g;
178 s/TRUE/<code>TRUE<\/code>/g;
179 s/FALSE/<code>FALSE<\/code>/g;
181 $body =~ s/@(\w+)/<i>\1<\/i>/g;
182 $returns =~ s/@(\w+)/<i>\1<\/i>/g;
183 $args =~ s/@(\w+)/<i>\1<\/i>/g;
185 $body =~ s/#(\w+)/<code>\1<\/code>/g;
186 $returns =~ s/#(\w+)/<code>\1<\/code>/g;
187 $args =~ s/#(\w+)/<code>\1<\/code>/g;
189 $returns =~ s/\`([:\w\*]+)\`/<code>\1<\/code>/g;
190 $args =~ s/\`([:\w\*]+)\`/<code>\1<\/code>/g;
191 $body =~ s/\`([:\w\*]+)\`/<code>\1<\/code>/g;
194 $bodies{$func} = $body;
195 $arguments{$func} = $args;
196 $deprecated{$func} = $deprecated;
197 $returns{$func} = $returns;
204 # clean it up a little, remove newlines, empty space at end
206 # Turn "Type * xxx" into "Type* xxx"
207 $proto =~ s/^(\w+)\W+\*/\1\*/;
208 $prototype{$func} = $proto;
213 $_ = "\n<p>" if (/^\s+$/);
216 if (/\s*(\w+):(.*)/){
217 if ($1 eq "deprecated"){
220 #$args .= "<dt><i>$1:</i></dt><dd>$2</dd>";
221 $args .= "<tr><td><i>$1</i><td>$2</td></td></tr>";
228 } elsif ($inbody == 1) {
237 $returns .= "\n\t$_";
244 my ($apis_listed) = @_;
247 my $ret, $xname, $args, $line;
251 # Try to align things, so compute type size, method size, and arguments
252 foreach $line (split /\n/, $apis_listed){
253 $p = $prototype{$line};
254 ($ret, $xname, $args) = $p =~ /(.*)\n(\w+)[ \t](.*)/;
256 $pl = length ($xname);
258 $type_size = $tl if ($tl > $type_size);
259 $name_size = $pl if ($pl > $name_size);
265 foreach $line (split /\n/, $apis_listed){
267 $p = $prototype{$line};
268 ($ret, $xname, $args) = $p =~ /(.*)\n(\w+)[ \t](.*)/;
273 $rspace = " " x ($type_size - length ($ret));
274 $nspace = " " x ($name_size - length ($xname));
275 $args = &format ($args, length ($ret . $rspace . $xname . $nspace), 60);
276 $apis_toc .= "$ret$rspace<a href=\"\#api:$line\">$xname</a>$nspace$args\n";
282 # Formats the rest of the arguments in a way that will fit in N columns
285 my ($args, $size, $limit) = @_;
288 # return $args if ((length (args) + size) < $limit);
290 $remain = $limit - $size;
291 @sa = split /,/, $args;
296 $linelen += length ($sret);
298 if ($linelen + length ($arg) < $limit){
299 $sret .= "FITS" . $arg . ", ";
301 $newline = " " x ($size) . $arg . ", ";
302 $linelen = length ($newline);
303 $sret .= "\n" . $newline;
312 my ($caption, $opttext, $quote) = @_;
314 if ($opttext ne "" && (!($opttext =~ /^[ \t]+$/))){
315 print OUT " <div class=\"mapi-section\">$caption</div>\n";
316 print OUT " <div>$opttext</div>\n";