[runtime] Disable some tests in full-aot mode which cannot be AOTed because of type...
[mono.git] / mcs / class / monodoc / Monodoc / generators / html / Ecmaspec2Html.cs
1 using System;
2 using System.IO;
3 using System.Xml;
4 using System.Xml.Xsl;
5 using System.Xml.XPath;
6 using System.Collections.Generic;
7
8 namespace Monodoc.Generators.Html
9 {
10         public class Ecmaspec2Html : IHtmlExporter
11         {
12                 static string css_ecmaspec;
13                 static XslTransform ecma_transform;
14                 static XsltArgumentList args = new XsltArgumentList();
15
16                 public string CssCode {
17                         get {
18                                 if (css_ecmaspec != null)
19                                         return css_ecmaspec;
20                                 System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecmaspec2Html));
21                                 Stream str_css = assembly.GetManifestResourceStream ("ecmaspec.css");
22                                 css_ecmaspec = (new StreamReader (str_css)).ReadToEnd ();
23                                 return css_ecmaspec;
24                         }
25                 }
26
27                 class ExtObj
28                 {
29                         public string Colorize (string code, string lang)
30                         {
31                                 return Mono.Utilities.Colorizer.Colorize (code, lang);
32                         }
33                 }
34
35                 public string Export (Stream stream, Dictionary<string, string> extraArgs)
36                 {
37                         return Htmlize (new XPathDocument (stream));
38                 }
39
40                 public string Export (string input, Dictionary<string, string> extraArgs)
41                 {
42                         return Htmlize (new XPathDocument (new StringReader (input)));
43                 }
44
45                 static string Htmlize (XPathDocument ecma_xml)
46                 {
47                         if (ecma_transform == null){
48                                 ecma_transform = new XslTransform ();
49                                 System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecmaspec2Html));
50                                 Stream stream;
51                                 stream = assembly.GetManifestResourceStream ("ecmaspec-html-css.xsl");
52
53                                 XmlReader xml_reader = new XmlTextReader (stream);
54                                 ecma_transform.Load (xml_reader, null, null);
55                                 args.AddExtensionObject ("monodoc:///extensions", new ExtObj ()); 
56                         }
57                 
58                         if (ecma_xml == null) return "";
59
60                         StringWriter output = new StringWriter ();
61                         ecma_transform.Transform (ecma_xml, args, output, null);
62                 
63                         return output.ToString ();
64                 }
65         }
66 }