Merge pull request #3477 from Unity-Technologies/create-delegate-exception
[mono.git] / docs / exdoc
index ce35052443e77a1a28b1205906b12cd0e116a8b3..517956c3e6387b07137055ee91f9d5f64b62c09d 100644 (file)
@@ -7,6 +7,10 @@ if ($ARGV[0] eq "-h"){
     shift @ARGV;
     shift @ARGV;
 }
+open (FILE, "$dir/api-style.css" || die "Did not find $dir/api-style.css");
+while (<FILE>){
+    $css = $css . $_;
+}
 
 if ($ARGV[0] eq "-t"){
     $dir = $ARGV[1];
@@ -49,77 +53,27 @@ if ($html){
 <?xml version="1.0" encoding="utf-8"?>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-   <title>$name</title>
-   <style type="text/css">
-   h3 { 
-       font-size: 18px;
-       padding-bottom: 4pt;
-       border-bottom: 2px solid #dddddd;
-   }
-       
-   .api {
-     padding: 10pt;
-     margin: 10pt;
-     border: 3px solid #ddd;
-   } 
-
-   .api-entry { 
-       border-bottom: none;
-       font-size: 150%;
-       font-family: "Consolas", "Courier", monospace;
-       padding-bottom: .5em;
-   }
-
-   .prototype {
-     border: 3px solid #ecf0f1;
-     border-radius: 6px;
-     padding: .5em;
-     margin-top: 5pt;
-     margin-bottom: 5pt;
-     font-family: "Consolas", "Courier", monospace;
-     display: block;
-     overflow: auto;
-     background-color: #f9f9f9;
-   } 
-
-   .header {
-     
-     padding: 0 0 5pt 5pt;
-     margin: 10pt;
-     white-space: pre;
-       font-family: monospace;
-   }
-    
-   .code {
-     border: 1px solid;
-     padding: 0 0 5pt 5pt;
-     margin: 10pt;
-     white-space: pre;
-       font-family: monospace;
-   }
-
-   .strike {
-      text-decoration: line-through;
-   }
-       .deprecated {
-           color: red;
-       }
+    <title>$name</title>
+    <style type="text/css">
+$css
    </style>
 </head>
 <body>
+<div class="mapi-docs">
 EOF
        @a = split (/\n/, $files_content[$f]);
        $strikeextra = "";
+       $api_shown = 0;
        for ($ai = 0; $ai < $#a; $ai++){
            $line = $a[$ai];
            
            ($api,$caption) = $line =~  /<h4><a name=\"api:(\w+)\">(\w+)<\/a><\/h4>/;
            if ($api ne ""){
                if ($api_shown == 1){
-                   print OUT "</div>";
+                   print OUT "</div> <!-- class=mapi -->\n\n";
                    if ($deprecated{$api}){
-                       $strike = "strike";
-                       $strikeextra = "</div><br><div class='deprecated'><b>Deprecated:</b> " . $deprecated{$api};
+                       $strike = "mapi-strike";
+                       $strikeextra = "</div><br><div class='mapi-deprecated'><b>Deprecated:</b> " . $deprecated{$api};
                    } else {
                        $strike = "";
                        $strikeextra = "";
@@ -128,50 +82,85 @@ EOF
                $api_shown = 1;
                $proto = $prototype{$api};
                if ($proto eq ""){
-                   $proto = "Prototype: $api";
+                   $proto = "$api";
                }
 
-print OUT<<EOF;
- <a name="api:$api"></a>
- <div class="api">
-    <div class="api-entry $strike">$api$strikeextra</div>
-    <div><b>Syntax</b></div>
-    <div class="prototype">$proto</div>
-<p>
+                print OUT<<EOF;
+<a name="api:$api"></a>
+<div class="mapi">
+    <div class="mapi-entry $strike"><code>$api$strikeextra</code></div>
+    <div class="mapi-height-container">
+        <div class="mapi-ptr-container"></div>
+        <div class="mapi-description">
+            <div class="mapi-ptr"></div>
+
+            <div class="mapi-declaration mapi-section">Syntax</div>
+            <div class="mapi-prototype">$proto</div>
+            <p>
 EOF
-                   &opt_print ("Parameters", $arguments{$api}, 1);
-                   &opt_print ("Returns", $returns{$api}, 1);
-                   &opt_print ("Description", $bodies{$api}, 0);
-                   print OUT "\n";
+                $ppars = $arguments{$api};
+               if ($ppars ne "" && (!($ppars =~ /^[ \t]+$/))){
+                   print OUT "            <div class=\"mapi-section\">Parameters</div>\n";
+                   print OUT "            <table class=\"mapi-parameters\"><tbody>".${arguments{$api}}."</tbody></table>";
+               }
+           
+               &opt_print ("Return value", $returns{$api}, 0);
+               &opt_print ("Description", $bodies{$api}, 0);
+               print OUT "        </div><!--mapi-description-->\n    </div><!--height container-->\n";
            } else {
                if ($line =~ /@API_IDX@/){
                    $apis_toc = &create_toc ($apis[$f]);
                    $line =~ s/\@API_IDX\@/$apis_toc/;
                }
-               if ($line =~ /^<h/){
-                   print OUT "</div>";
+               if ($line =~ /^<h4/){
+                   print OUT "</div>\n";
                    $api_shown = 0;
                }
-
+               if ($line =~ /`/){
+               }
                print OUT "$line\n";
            }
        }
        print OUT<<EOF;
+   </div>
 </body>
 </html>
 EOF
        close OUT;
        system ("$ENV{runtimedir}/mono-wrapper 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";
 
+       $line = 0;
+       $doprint = 0;
        while (<HACK>){
+           print HACKOUT $last if ($doprint);
+           $line++;
            s/^\/\/<!\[CDATA\[//;
            s/^\/\/\]\]>\/\///;
-           print HACKOUT $_;
+
+           # Remove the junk <span> wrapper generated by AgilityPack
+           if ($line==1){
+               s/<span>//;
+           }
+           if (/<style type/){
+               # Replace the CSS in the XHTML output with the original CSS
+               print HACKOUT $_;
+               print HACKOUT $css;
+               while (<HACK>){
+                   last if (/<\/style>/);
+               }
+           }
+           $last = $_;
+           $doprint = 1;
+       }
+       if (!($last =~ /span/)){
+           print HACKOUT $last;
        }
+
        #system ("cp.exe $dir/html/$name $dir/deploy/$name");
     }
 }
@@ -189,14 +178,24 @@ sub process_doc {
        $body = "";
        $functions[$fn++] = $func;
        $deprecated = 0;
-       
        # Process arguments
        while (<>){
-               if (/^ \*\*?\//){
-                   $body =~ s/[@#](\w+)/<i>\1<\/i>/g;
-                   $returns =~ s/[@#](\w+)/<i>\1<\/i>/g;
-
+           s/NULL/<code>NULL<\/code>/g;
+           s/TRUE/<code>TRUE<\/code>/g;
+           s/FALSE/<code>FALSE<\/code>/g;
+           if (/^ \*\*?\//){
+                   $body =~ s/@(\w+)/<i>\1<\/i>/g;
+                   $returns =~ s/@(\w+)/<i>\1<\/i>/g;
                    $args =~ s/@(\w+)/<i>\1<\/i>/g;
+
+                   $body =~ s/#(\w+)/<code>\1<\/code>/g;
+                   $returns =~ s/#(\w+)/<code>\1<\/code>/g;
+                   $args =~ s/#(\w+)/<code>\1<\/code>/g;
+
+                   $returns =~ s/\`([:.\w\*]+)\`/<code>\1<\/code>/g;
+                   $args =~ s/\`([:.\w\*]+)\`/<code>\1<\/code>/g;
+                   $body =~ s/\`([:.\w\*]+)\`/<code>\1<\/code>/g;
+                   
                    $body =~ s/\n/ /;
                    $bodies{$func} = $body;
                    $arguments{$func} = $args;
@@ -217,18 +216,20 @@ sub process_doc {
                }
                chop;
                s/^\ \*//;
-               $_ = "\n<p>" if (/^\s+$/);
+               $_ = "<p>" if (/^\s*$/);
                                
                if ($inbody == 0){
                    if (/\s*(\w+):(.*)/){
                        if ($1 eq "deprecated"){
                            $deprecated = $2;
                        } else {
-                           $args .= "<dt><i>$1:</i></dt><dd>$2</dd>";
+                           #$args .= "<dt><i>$1:</i></dt><dd>$2</dd>";
+                           $args .= "<tr><td><i>$1</i><td>$2</td></td></tr>";
                        }
                    } else {
                        
                        $body = "\t$_\n";
+
                        $inbody = 1;
                    }
                } elsif ($inbody == 1) {
@@ -272,6 +273,9 @@ sub create_toc {
        chop;
        $p = $prototype{$line};
        ($ret, $xname, $args) = $p =~ /(.*)\n(\w+)[ \t](.*)/;
+       if ($xname eq ""){
+           $xname = $line;
+       }
        
        $rspace = " " x ($type_size - length ($ret));
        $nspace = " " x ($name_size - length ($xname));
@@ -315,11 +319,7 @@ sub opt_print {
     my ($caption, $opttext, $quote) = @_;
 
     if ($opttext ne "" && (!($opttext =~ /^[ \t]+$/))){
-       print OUT "<b>$caption</b>\n";
-       if ($quote == 1){
-           print OUT "<blockquote>$opttext</blockquote>\n";
-       } else {
-           print OUT "<p>$opttext\n";
-       }
+       print OUT "             <div class=\"mapi-section\">$caption</div>\n";
+        print OUT "             <div>$opttext</div>\n";
     }
 }