[runtime] Disable some tests in full-aot mode which cannot be AOTed because of type...
[mono-project.git] / mcs / class / monodoc / Monodoc / generators / html / Error2Html.cs
blob67e6c9c4899e4dc0d332afa13244c77f34432f9a
1 using System;
2 using System.IO;
3 using System.Linq;
4 using System.Xml;
5 using System.Xml.XPath;
6 using System.Collections.Generic;
8 namespace Monodoc.Generators.Html
10 public class Error2Html : IHtmlExporter
12 public string Export (string input, Dictionary<string, string> extraArgs)
14 return Htmlize (new XPathDocument (new StringReader (input)));
17 public string Export (Stream input, Dictionary<string, string> extraArgs)
19 return Htmlize (new XPathDocument (input));
22 public string CssCode {
23 get {
24 return @"
25 #error_ref {
26 background: #debcb0;
27 border: 2px solid #782609;
29 div.summary {
30 font-size: 110%;
31 font-weight: bolder;
33 div.details {
34 font-size: 110%;
35 font-weight: bolder;
37 div.code_example {
38 background: #f5f5dd;
39 border: 1px solid black;
40 padding-left: 1em;
41 padding-bottom: 1em;
42 margin-top: 1em;
43 white-space: pre;
44 margin-bottom: 1em;
46 div.code_ex_title {
47 position: relative;
48 top: -1em;
49 left: 30%;
50 background: #cdcd82;
51 border: 1px solid black;
52 color: black;
53 font-size: 65%;
54 text-transform: uppercase;
55 width: 40%;
56 padding: 0.3em;
57 text-align: center;
58 }";
62 public string Htmlize (IXPathNavigable doc)
64 var navigator = doc.CreateNavigator ();
65 var errorName = navigator.SelectSingleNode ("//ErrorDocumentation/ErrorName");
66 var details = navigator.SelectSingleNode ("//ErrorDocumentation/Details");
68 StringWriter sw = new StringWriter ();
69 XmlWriter w = new XmlTextWriter (sw);
71 WriteElementWithClass (w, "div", "header");
72 w.WriteAttributeString ("id", "error_ref");
73 WriteElementWithClass (w, "div", "subtitle", "Compiler Error Reference");
74 WriteElementWithClass (w, "div", "title", "Error " + (errorName == null ? string.Empty : errorName.Value));
75 w.WriteEndElement ();
77 if (details != null) {
78 WriteElementWithClass (w, "div", "summary", "Summary");
80 var summary = details.SelectSingleNode ("/Summary");
81 w.WriteValue (summary == null ? string.Empty : summary.Value);
83 WriteElementWithClass (w, "div", "details", "Details");
84 var de = details.SelectSingleNode ("/Details");
85 w.WriteValue (de == null ? string.Empty : de.Value);
88 foreach (XPathNavigator xmp in navigator.Select ("//ErrorDocumentation/Examples/string")) {
89 WriteElementWithClass (w, "div", "code_example");
90 WriteElementWithClass (w, "div", "code_ex_title", "Example");
91 w.WriteRaw (Mono.Utilities.Colorizer.Colorize (xmp.Value, "c#"));;
92 w.WriteEndElement ();
95 w.Close ();
97 return sw.ToString ();
100 void WriteElementWithClass (XmlWriter w, string element, string cls, string content = null)
102 w.WriteStartElement (element);
103 w.WriteAttributeString ("class", cls);
104 if (!string.IsNullOrEmpty (content)) {
105 w.WriteValue (content);
106 w.WriteEndElement ();