You've already forked linux-packaging-mono
Imported Upstream version 5.2.0.179
Former-commit-id: a536d4f20e27294d8bbc2184d75f3a22364f7ba1
This commit is contained in:
parent
966bba02bb
commit
fad71374d0
156
external/api-doc-tools/monodoc/Monodoc/generators/HtmlGenerator.cs
vendored
Normal file
156
external/api-doc-tools/monodoc/Monodoc/generators/HtmlGenerator.cs
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Monodoc;
|
||||
|
||||
namespace Monodoc.Generators
|
||||
{
|
||||
using Html;
|
||||
|
||||
interface IHtmlExporter
|
||||
{
|
||||
string CssCode { get; }
|
||||
string Export (Stream input, Dictionary<string, string> extras);
|
||||
string Export (string input, Dictionary<string, string> extras);
|
||||
}
|
||||
|
||||
public class HtmlGenerator : IDocGenerator<string>
|
||||
{
|
||||
const string cachePrefix = "htmlcached#";
|
||||
|
||||
static string css_code;
|
||||
|
||||
IDocCache defaultCache;
|
||||
static Dictionary<DocumentType, IHtmlExporter> converters;
|
||||
|
||||
static HtmlGenerator ()
|
||||
{
|
||||
converters = new Dictionary<DocumentType, IHtmlExporter> {
|
||||
{ DocumentType.EcmaXml, new Ecma2Html () },
|
||||
{ DocumentType.Man, new Man2Html () },
|
||||
{ DocumentType.TocXml, new Toc2Html () },
|
||||
{ DocumentType.EcmaSpecXml, new Ecmaspec2Html () },
|
||||
{ DocumentType.ErrorXml, new Error2Html () },
|
||||
{ DocumentType.Html, new Idem () },
|
||||
{ DocumentType.MonoBook, new MonoBook2Html () },
|
||||
{ DocumentType.AddinXml, new Addin2Html () },
|
||||
{ DocumentType.PlainText, new Idem () },
|
||||
};
|
||||
}
|
||||
|
||||
public HtmlGenerator (IDocCache defaultCache)
|
||||
{
|
||||
this.defaultCache = defaultCache;
|
||||
}
|
||||
|
||||
public string Generate (HelpSource hs, string id, Dictionary<string, string> context)
|
||||
{
|
||||
string specialPage = null;
|
||||
if (context != null && context.TryGetValue ("specialpage", out specialPage) && specialPage == "master-root")
|
||||
return GenerateMasterRootPage (hs != null ? hs.RootTree : null);
|
||||
|
||||
if (id == "root:" && hs == null)
|
||||
return MakeEmptySummary ();
|
||||
|
||||
if (hs == null || string.IsNullOrEmpty (id))
|
||||
return MakeHtmlError (string.Format ("Your request has found no candidate provider [hs=\"{0}\", id=\"{1}\"]",
|
||||
hs == null ? "(null)" : hs.Name, id ?? "(null)"));
|
||||
|
||||
var cache = defaultCache ?? hs.Cache;
|
||||
if (cache != null && cache.IsCached (MakeCacheKey (hs, id, null)))
|
||||
return cache.GetCachedString (MakeCacheKey (hs, id, null));
|
||||
|
||||
IEnumerable<string> parts;
|
||||
if (hs.IsMultiPart (id, out parts))
|
||||
return GenerateMultiPart (hs, parts, id, context);
|
||||
|
||||
if (hs.IsRawContent (id))
|
||||
return hs.GetText (id) ?? string.Empty;
|
||||
|
||||
DocumentType type = hs.GetDocumentTypeForId (id);
|
||||
if (cache != null && context != null && cache.IsCached (MakeCacheKey (hs, id, context)))
|
||||
return cache.GetCachedString (MakeCacheKey (hs, id, context));
|
||||
|
||||
IHtmlExporter exporter;
|
||||
if (!converters.TryGetValue (type, out exporter))
|
||||
return MakeHtmlError (string.Format ("Input type '{0}' not supported",
|
||||
type.ToString ()));
|
||||
var result = hs.IsGeneratedContent (id) ?
|
||||
exporter.Export (hs.GetCachedText (id), context) :
|
||||
exporter.Export (hs.GetCachedHelpStream (id), context);
|
||||
|
||||
if (cache != null)
|
||||
cache.CacheText (MakeCacheKey (hs, id, context), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
string GenerateMultiPart (HelpSource hs, IEnumerable<string> ids, string originalId, Dictionary<string, string> context)
|
||||
{
|
||||
var sb = new StringBuilder ();
|
||||
foreach (var id in ids)
|
||||
sb.AppendLine (Generate (hs, id, context));
|
||||
|
||||
var cache = defaultCache ?? hs.Cache;
|
||||
if (cache != null)
|
||||
cache.CacheText (MakeCacheKey (hs, originalId, null), sb.ToString ());
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
string GenerateMasterRootPage (RootTree rootTree)
|
||||
{
|
||||
if (rootTree == null)
|
||||
return string.Empty;
|
||||
var assembly = System.Reflection.Assembly.GetAssembly (typeof (HtmlGenerator));
|
||||
var hpStream = assembly.GetManifestResourceStream ("home.html");
|
||||
var home = new StreamReader (hpStream).ReadToEnd ();
|
||||
var links = string.Join (Environment.NewLine,
|
||||
rootTree.RootNode.ChildNodes.Select (n => string.Format ("<li><a href=\"{0}\">{1}</a></li>", n.Element, n.Caption)));
|
||||
return home.Replace ("@@API_DOCS@@", links);
|
||||
}
|
||||
|
||||
public static string InlineCss {
|
||||
get {
|
||||
if (css_code != null)
|
||||
return css_code;
|
||||
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (HtmlGenerator));
|
||||
Stream str_css = assembly.GetManifestResourceStream ("base.css");
|
||||
StringBuilder sb = new StringBuilder ((new StreamReader (str_css)).ReadToEnd());
|
||||
sb.Replace ("@@FONT_FAMILY@@", "Sans Serif");
|
||||
sb.Replace ("@@FONT_SIZE@@", "100%");
|
||||
css_code = sb.ToString () + converters.Values
|
||||
.Select (c => c.CssCode)
|
||||
.Where (css => !string.IsNullOrEmpty (css))
|
||||
.DefaultIfEmpty (string.Empty)
|
||||
.Aggregate (string.Concat);
|
||||
return css_code;
|
||||
}
|
||||
set {
|
||||
css_code = value;
|
||||
}
|
||||
}
|
||||
|
||||
string MakeHtmlError (string error)
|
||||
{
|
||||
return string.Format ("<html><head></head><body><p><em>Error:</em> {0}</p></body></html>", error);
|
||||
}
|
||||
|
||||
string MakeEmptySummary ()
|
||||
{
|
||||
return @"<html><head></head><body><p><em>This node doesn't have a summary available</p></body></html>";
|
||||
}
|
||||
|
||||
string MakeCacheKey (HelpSource hs, string page, IDictionary<string,string> extraParams)
|
||||
{
|
||||
var key = cachePrefix + hs.SourceID + page;
|
||||
if (extraParams != null && extraParams.Count > 0) {
|
||||
var paramPart = string.Join ("-", extraParams.Select (kvp => kvp.Key + kvp.Value));
|
||||
key += '_' + paramPart;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
41
external/api-doc-tools/monodoc/Monodoc/generators/RawGenerator.cs
vendored
Normal file
41
external/api-doc-tools/monodoc/Monodoc/generators/RawGenerator.cs
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Monodoc;
|
||||
|
||||
namespace Monodoc.Generators
|
||||
{
|
||||
/// <summary>
|
||||
/// This generators returns the raw content of the HelpSource without any transformation
|
||||
/// </summary>
|
||||
public class RawGenerator : IDocGenerator<string>
|
||||
{
|
||||
public string Generate (HelpSource hs, string id, Dictionary<string, string> context)
|
||||
{
|
||||
if (hs == null || string.IsNullOrEmpty (id))
|
||||
return null;
|
||||
|
||||
IEnumerable<string> parts;
|
||||
if (hs.IsMultiPart (id, out parts))
|
||||
return GenerateMultiPart (hs, parts, id, context);
|
||||
|
||||
if (hs.IsRawContent (id))
|
||||
return hs.GetText (id) ?? string.Empty;
|
||||
|
||||
var result = hs.IsGeneratedContent (id) ? hs.GetCachedText (id) : new StreamReader (hs.GetCachedHelpStream (id)).ReadToEnd ();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
string GenerateMultiPart (HelpSource hs, IEnumerable<string> ids, string originalId, Dictionary<string, string> context)
|
||||
{
|
||||
var sb = new StringBuilder ();
|
||||
foreach (var id in ids)
|
||||
sb.AppendLine (Generate (hs, id, context));
|
||||
return sb.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
197
external/api-doc-tools/monodoc/Monodoc/generators/html/Addin2Html.cs
vendored
Normal file
197
external/api-doc-tools/monodoc/Monodoc/generators/html/Addin2Html.cs
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using System.Xml.XPath;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
public class Addin2Html : IHtmlExporter
|
||||
{
|
||||
public string CssCode {
|
||||
get {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public string Export (Stream stream, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
using (var reader = new StreamReader (stream))
|
||||
return Htmlize (GetAddin (reader, extraArgs["AddinID"]),
|
||||
extraArgs["show"],
|
||||
extraArgs["AddinID"],
|
||||
extraArgs["FileID"],
|
||||
extraArgs["NodeID"]);
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (GetAddin (new StringReader (input), extraArgs["AddinID"]),
|
||||
extraArgs["show"],
|
||||
extraArgs["AddinID"],
|
||||
extraArgs["FileID"],
|
||||
extraArgs["NodeID"]);
|
||||
}
|
||||
|
||||
XmlElement GetAddin (TextReader reader, string addinId)
|
||||
{
|
||||
XmlDocument doc = new XmlDocument ();
|
||||
doc.Load (reader);
|
||||
XmlElement addin = (XmlElement) doc.SelectSingleNode ("Addins/Addin[@fullId='" + addinId + "']");
|
||||
return addin != null ? addin : null;
|
||||
}
|
||||
|
||||
public string Htmlize (XmlElement addin, string urlType, string addinId, string fileId, string path)
|
||||
{
|
||||
if (urlType == Monodoc.Providers.AddinsHelpSource.AddinPrefix)
|
||||
return GetAddinTextFromUrl (addin, addinId, fileId);
|
||||
else if (urlType == Monodoc.Providers.AddinsHelpSource.ExtensionPrefix)
|
||||
return GetExtensionTextFromUrl (addin, addinId, fileId, path);
|
||||
else if (urlType == Monodoc.Providers.AddinsHelpSource.ExtensionNodePrefix)
|
||||
return GetExtensionNodeTextFromUrl (addin, addinId, fileId, path);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected string GetAddinTextFromUrl (XmlElement addin, string addinId, string fileId)
|
||||
{
|
||||
if (addin == null)
|
||||
return "<html>Add-in not found: " + addinId + "</html>";
|
||||
|
||||
StringBuilder sb = new StringBuilder ("<html>");
|
||||
sb.Append ("<h1>").Append (addin.GetAttribute ("name")).Append ("</h1>");
|
||||
XmlElement docs = (XmlElement) addin.SelectSingleNode ("Description");
|
||||
if (docs != null)
|
||||
sb.Append (docs.InnerText);
|
||||
|
||||
sb.Append ("<p><table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">");
|
||||
sb.AppendFormat ("<tr><td><b>Id</b></td><td>{0}</td></tr>", addin.GetAttribute ("addinId"));
|
||||
sb.AppendFormat ("<tr><td><b>Namespace</b></td><td>{0}</td></tr>", addin.GetAttribute ("namespace"));
|
||||
sb.AppendFormat ("<tr><td><b>Version</b></td><td>{0}</td></tr>", addin.GetAttribute ("version"));
|
||||
sb.Append ("</table></p>");
|
||||
sb.Append ("<p><b>Extension Points</b>:</p>");
|
||||
sb.Append ("<ul>");
|
||||
|
||||
foreach (XmlElement ep in addin.SelectNodes ("ExtensionPoint")) {
|
||||
sb.AppendFormat ("<li><a href=\"extension-point:{0}#{1}#{2}\">{3}</li>", fileId, addinId, ep.GetAttribute ("path"), ep.GetAttribute ("name"));
|
||||
}
|
||||
sb.Append ("</ul>");
|
||||
|
||||
sb.Append ("</html>");
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
protected string GetExtensionTextFromUrl (XmlElement addin, string addinId, string fileId, string path)
|
||||
{
|
||||
if (addin == null)
|
||||
return "<html>Add-in not found: " + addinId + "</html>";
|
||||
|
||||
XmlElement ext = (XmlElement) addin.SelectSingleNode ("ExtensionPoint[@path='" + path + "']");
|
||||
if (ext == null)
|
||||
return "<html>Extension point not found: " + path + "</html>";
|
||||
|
||||
StringBuilder sb = new StringBuilder ("<html>");
|
||||
sb.Append ("<h1>").Append (ext.GetAttribute ("name")).Append ("</h1>");
|
||||
|
||||
path = path.Replace ("/", " <b>/</b> ");
|
||||
sb.Append ("<p><b>Path</b>: ").Append (path).Append ("</p>");
|
||||
XmlElement desc = (XmlElement) ext.SelectSingleNode ("Description");
|
||||
if (desc != null)
|
||||
sb.Append (desc.InnerText);
|
||||
|
||||
sb.Append ("<p><b>Extension Nodes</b>:</p>");
|
||||
sb.Append ("<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">");
|
||||
|
||||
foreach (XmlElement en in ext.SelectNodes ("ExtensionNode")) {
|
||||
string nid = en.GetAttribute ("id");
|
||||
string nname = en.GetAttribute ("name");
|
||||
string sdesc = "";
|
||||
desc = (XmlElement) en.SelectSingleNode ("Description");
|
||||
if (desc != null)
|
||||
sdesc = desc.InnerText;
|
||||
|
||||
sb.AppendFormat ("<tr><td><a href=\"extension-node:{0}#{1}#{2}\">{3}</td><td>{4}</td></tr>", fileId, addinId, nid, nname, sdesc);
|
||||
}
|
||||
sb.Append ("</table>");
|
||||
|
||||
sb.Append ("</html>");
|
||||
return sb.ToString ();
|
||||
}
|
||||
|
||||
protected string GetExtensionNodeTextFromUrl (XmlElement addin, string addinId, string fileId, string nodeId)
|
||||
{
|
||||
if (addin == null)
|
||||
return "<html>Add-in not found: " + addinId + "</html>";
|
||||
|
||||
XmlElement node = (XmlElement) addin.SelectSingleNode ("ExtensionNodeType[@id='" + nodeId + "']");
|
||||
if (node == null)
|
||||
return "<html>Extension point not found: " + nodeId + "</html>";
|
||||
|
||||
StringBuilder sb = new StringBuilder ("<html>");
|
||||
sb.Append ("<h1>").Append (node.GetAttribute ("name")).Append ("</h1>");
|
||||
XmlElement desc = (XmlElement) node.SelectSingleNode ("Description");
|
||||
if (desc != null)
|
||||
sb.Append (desc.InnerText);
|
||||
|
||||
sb.Append ("<p><b>Attributes</b>:</p>");
|
||||
sb.Append ("<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\"><tr>");
|
||||
sb.Append ("<td><b>Name</b></td>");
|
||||
sb.Append ("<td><b>Type</b></td>");
|
||||
sb.Append ("<td><b>Required</b></td>");
|
||||
sb.Append ("<td><b>Localizable</b></td>");
|
||||
sb.Append ("<td><b>Description</b></td>");
|
||||
sb.Append ("<tr>");
|
||||
sb.Append ("<td>id</td>");
|
||||
sb.Append ("<td>System.String</td>");
|
||||
sb.Append ("<td></td>");
|
||||
sb.Append ("<td></td>");
|
||||
sb.Append ("<td>Identifier of the node.</td>");
|
||||
sb.Append ("</tr>");
|
||||
|
||||
foreach (XmlElement at in node.SelectNodes ("Attributes/Attribute")) {
|
||||
sb.Append ("<tr>");
|
||||
sb.AppendFormat ("<td>{0}</td>", at.GetAttribute ("name"));
|
||||
sb.AppendFormat ("<td>{0}</td>", at.GetAttribute ("type"));
|
||||
if (at.GetAttribute ("required") == "True")
|
||||
sb.Append ("<td>Yes</td>");
|
||||
else
|
||||
sb.Append ("<td></td>");
|
||||
if (at.GetAttribute ("localizable") == "True")
|
||||
sb.Append ("<td>Yes</td>");
|
||||
else
|
||||
sb.Append ("<td></td>");
|
||||
string sdesc = "";
|
||||
desc = (XmlElement) at.SelectSingleNode ("Description");
|
||||
if (desc != null)
|
||||
sdesc = desc.InnerText;
|
||||
|
||||
sb.AppendFormat ("<td>{0}</td>", sdesc);
|
||||
sb.Append ("</tr>");
|
||||
}
|
||||
sb.Append ("</table>");
|
||||
|
||||
XmlNodeList children = node.SelectNodes ("ChildNodes/ExtensionNode");
|
||||
if (children.Count > 0) {
|
||||
sb.Append ("<p><b>Child Nodes</b>:</p>");
|
||||
sb.Append ("<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">");
|
||||
|
||||
foreach (XmlElement en in children) {
|
||||
string nid = en.GetAttribute ("id");
|
||||
string nname = en.GetAttribute ("name");
|
||||
string sdesc = "";
|
||||
desc = (XmlElement) en.SelectSingleNode ("Description");
|
||||
if (desc != null)
|
||||
sdesc = desc.InnerText;
|
||||
|
||||
sb.AppendFormat ("<tr><td><a href=\"extension-node:{0}#{1}#{2}\">{3}</td><td>{4}</td></tr>", fileId, addinId, nid, nname, sdesc);
|
||||
}
|
||||
sb.Append ("</table>");
|
||||
}
|
||||
|
||||
sb.Append ("</html>");
|
||||
return sb.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
333
external/api-doc-tools/monodoc/Monodoc/generators/html/Ecma2Html.cs
vendored
Normal file
333
external/api-doc-tools/monodoc/Monodoc/generators/html/Ecma2Html.cs
vendored
Normal file
@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using System.Xml.XPath;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Mono.Documentation;
|
||||
using BF = System.Reflection.BindingFlags;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
public class Ecma2Html : IHtmlExporter
|
||||
{
|
||||
static string css_ecma;
|
||||
static string js;
|
||||
static XslCompiledTransform ecma_transform;
|
||||
readonly ExtensionObject ExtObject = new ExtensionObject ();
|
||||
|
||||
public Ecma2Html ()
|
||||
{
|
||||
}
|
||||
|
||||
public string CssCode {
|
||||
get {
|
||||
if (css_ecma != null)
|
||||
return css_ecma;
|
||||
var assembly = typeof(Ecma2Html).Assembly;
|
||||
Stream str_css = assembly.GetManifestResourceStream ("mono-ecma.css");
|
||||
css_ecma = (new StreamReader (str_css)).ReadToEnd();
|
||||
return css_ecma;
|
||||
}
|
||||
}
|
||||
|
||||
public string JsCode {
|
||||
get {
|
||||
if (js != null)
|
||||
return js;
|
||||
var assembly = typeof(Ecma2Html).Assembly;
|
||||
Stream str_js = assembly.GetManifestResourceStream ("helper.js");
|
||||
js = (new StreamReader (str_js)).ReadToEnd();
|
||||
return js;
|
||||
}
|
||||
}
|
||||
|
||||
public string Htmlize (XmlReader ecma_xml, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
var args = new XsltArgumentList ();
|
||||
args.AddExtensionObject("monodoc:///extensions", ExtObject);
|
||||
string specialPage;
|
||||
if (extraArgs.TryGetValue ("specialpage", out specialPage) && specialPage == "root") {
|
||||
extraArgs.Remove ("specialpage");
|
||||
extraArgs["show"] = "masteroverview";
|
||||
}
|
||||
|
||||
foreach (var kvp in extraArgs)
|
||||
args.AddParam (kvp.Key, string.Empty, kvp.Value);
|
||||
|
||||
return Htmlize (ecma_xml, args);
|
||||
}
|
||||
|
||||
public string Htmlize (XmlReader ecma_xml, XsltArgumentList args)
|
||||
{
|
||||
try{
|
||||
EnsureTransform ();
|
||||
|
||||
var output = new StringBuilder ();
|
||||
ecma_transform.Transform (ecma_xml,
|
||||
args,
|
||||
XmlWriter.Create (output, ecma_transform.OutputSettings),
|
||||
CreateDocumentResolver ());
|
||||
return output.ToString ();
|
||||
}
|
||||
catch(Exception x)
|
||||
{
|
||||
var msg = x.ToString ();
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual XmlResolver CreateDocumentResolver ()
|
||||
{
|
||||
// results in using XmlUrlResolver
|
||||
return null;
|
||||
}
|
||||
|
||||
public string Export (Stream stream, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (XmlReader.Create (new StreamReader(stream)), extraArgs);
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (XmlReader.Create (new StringReader(input)), extraArgs);
|
||||
}
|
||||
|
||||
|
||||
static void EnsureTransform ()
|
||||
{
|
||||
if (ecma_transform == null) {
|
||||
ecma_transform = new XslCompiledTransform ();
|
||||
var assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecma2Html));
|
||||
|
||||
Stream stream = assembly.GetManifestResourceStream ("mono-ecma-css.xsl");
|
||||
XmlReader xml_reader = new XmlTextReader (stream);
|
||||
XmlResolver r = new ManifestResourceResolver (".");
|
||||
ecma_transform.Load (xml_reader, XsltSettings.TrustedXslt, r);
|
||||
}
|
||||
}
|
||||
|
||||
public class ExtensionObject
|
||||
{
|
||||
bool quiet = true;
|
||||
Dictionary<string, System.Reflection.Assembly> assemblyCache = new Dictionary<string, System.Reflection.Assembly> ();
|
||||
|
||||
public string Colorize(string code, string lang)
|
||||
{
|
||||
return Mono.Utilities.Colorizer.Colorize(code,lang);
|
||||
}
|
||||
|
||||
// Used by stylesheet to nicely reformat the <see cref=> tags.
|
||||
public string MakeNiceSignature(string sig, string contexttype)
|
||||
{
|
||||
if (sig.Length < 3)
|
||||
return sig;
|
||||
if (sig[1] != ':')
|
||||
return sig;
|
||||
|
||||
char s = sig[0];
|
||||
sig = sig.Substring(2);
|
||||
|
||||
switch (s) {
|
||||
case 'N': return sig;
|
||||
case 'T': return ShortTypeName (sig, contexttype);
|
||||
|
||||
case 'C': case 'M': case 'P': case 'F': case 'E':
|
||||
string type, mem, arg;
|
||||
|
||||
// Get arguments
|
||||
int paren;
|
||||
if (s == 'C' || s == 'M')
|
||||
paren = sig.IndexOf("(");
|
||||
else if (s == 'P')
|
||||
paren = sig.IndexOf("[");
|
||||
else
|
||||
paren = 0;
|
||||
|
||||
if (paren > 0 && paren < sig.Length-1) {
|
||||
string[] args = sig.Substring(paren+1, sig.Length-paren-2).Split(',');
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
args[i] = ShortTypeName(args[i], contexttype);
|
||||
arg = "(" + String.Join(", ", args) + ")";
|
||||
sig = sig.Substring(0, paren);
|
||||
} else {
|
||||
arg = string.Empty;
|
||||
}
|
||||
|
||||
// Get type and member names
|
||||
int dot = sig.LastIndexOf(".");
|
||||
if (s == 'C' || dot <= 0 || dot == sig.Length-1) {
|
||||
mem = string.Empty;
|
||||
type = sig;
|
||||
} else {
|
||||
type = sig.Substring(0, dot);
|
||||
mem = sig.Substring(dot);
|
||||
}
|
||||
|
||||
type = ShortTypeName(type, contexttype);
|
||||
|
||||
return type + mem + arg;
|
||||
|
||||
default:
|
||||
return sig;
|
||||
}
|
||||
}
|
||||
|
||||
static string ShortTypeName(string name, string contexttype)
|
||||
{
|
||||
int dot = contexttype.LastIndexOf(".");
|
||||
if (dot < 0) return name;
|
||||
string contextns = contexttype.Substring(0, dot+1);
|
||||
|
||||
if (name == contexttype)
|
||||
return name.Substring(dot+1);
|
||||
|
||||
if (name.StartsWith(contextns))
|
||||
return name.Substring(contextns.Length);
|
||||
|
||||
return name.Replace("+", ".");
|
||||
}
|
||||
|
||||
string MonoImpInfo(string assemblyname, string typename, string membername, string arglist, bool strlong)
|
||||
{
|
||||
if (quiet)
|
||||
return string.Empty;
|
||||
|
||||
var a = new List<string> ();
|
||||
if (!string.IsNullOrEmpty (arglist)) a.Add (arglist);
|
||||
return MonoImpInfo(assemblyname, typename, membername, a, strlong);
|
||||
}
|
||||
|
||||
string MonoImpInfo(string assemblyname, string typename, string membername, XPathNodeIterator itr, bool strlong)
|
||||
{
|
||||
if (quiet)
|
||||
return string.Empty;
|
||||
|
||||
var rgs = itr.Cast<XPathNavigator> ().Select (nav => nav.Value).ToList ();
|
||||
|
||||
return MonoImpInfo (assemblyname, typename, membername, rgs, strlong);
|
||||
}
|
||||
|
||||
string MonoImpInfo(string assemblyname, string typename, string membername, List<string> arglist, bool strlong)
|
||||
{
|
||||
try {
|
||||
System.Reflection.Assembly assembly = null;
|
||||
|
||||
try {
|
||||
if (!assemblyCache.TryGetValue (assemblyname, out assembly)) {
|
||||
assembly = System.Reflection.Assembly.LoadWithPartialName(assemblyname);
|
||||
if (assembly != null)
|
||||
assemblyCache[assemblyname] = assembly;
|
||||
}
|
||||
} catch (Exception) {
|
||||
// nothing.
|
||||
}
|
||||
|
||||
if (assembly == null) {
|
||||
/*if (strlong) return "The assembly " + assemblyname + " is not available to MonoDoc.";
|
||||
else return string.Empty;*/
|
||||
return string.Empty; // silently ignore
|
||||
}
|
||||
|
||||
Type t = assembly.GetType(typename, false);
|
||||
if (t == null) {
|
||||
if (strlong)
|
||||
return typename + " has not been implemented.";
|
||||
else
|
||||
return "Not implemented.";
|
||||
}
|
||||
|
||||
// The following code is flakey and fails to find existing members
|
||||
return string.Empty;
|
||||
} catch (Exception) {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
string MonoImpInfo(System.Reflection.MemberInfo mi, string itemtype, bool strlong)
|
||||
{
|
||||
if (quiet)
|
||||
return string.Empty;
|
||||
|
||||
string s = string.Empty;
|
||||
|
||||
object[] atts = mi.GetCustomAttributes(true);
|
||||
int todoctr = 0;
|
||||
foreach (object att in atts) if (att.GetType().Name == "MonoTODOAttribute") todoctr++;
|
||||
|
||||
if (todoctr > 0) {
|
||||
if (strlong)
|
||||
s = "This " + itemtype + " is marked as being unfinished.<BR/>\n";
|
||||
else
|
||||
s = "Unfinished.";
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public string MonoImpInfo(string assemblyname, string typename, bool strlong)
|
||||
{
|
||||
if (quiet)
|
||||
return string.Empty;
|
||||
|
||||
try {
|
||||
if (assemblyname == string.Empty)
|
||||
return string.Empty;
|
||||
|
||||
System.Reflection.Assembly assembly;
|
||||
if (!assemblyCache.TryGetValue (assemblyname, out assembly)) {
|
||||
assembly = System.Reflection.Assembly.LoadWithPartialName(assemblyname);
|
||||
if (assembly != null)
|
||||
assemblyCache[assemblyname] = assembly;
|
||||
}
|
||||
|
||||
if (assembly == null)
|
||||
return string.Empty;
|
||||
|
||||
Type t = assembly.GetType(typename, false);
|
||||
if (t == null) {
|
||||
if (strlong)
|
||||
return typename + " has not been implemented.";
|
||||
else
|
||||
return "Not implemented.";
|
||||
}
|
||||
|
||||
string s = MonoImpInfo(t, "type", strlong);
|
||||
|
||||
if (strlong) {
|
||||
var mis = t.GetMembers (BF.Static | BF.Instance | BF.Public | BF.NonPublic);
|
||||
|
||||
// Scan members for MonoTODO attributes
|
||||
int mctr = 0;
|
||||
foreach (var mi in mis) {
|
||||
string mii = MonoImpInfo(mi, null, false);
|
||||
if (mii != string.Empty) mctr++;
|
||||
}
|
||||
if (mctr > 0) {
|
||||
s += "This type has " + mctr + " members that are marked as unfinished.<BR/>";
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
|
||||
} catch (Exception) {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MonoEditing ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsToBeAdded(string text)
|
||||
{
|
||||
return text.StartsWith ("To be added");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
66
external/api-doc-tools/monodoc/Monodoc/generators/html/Ecmaspec2Html.cs
vendored
Normal file
66
external/api-doc-tools/monodoc/Monodoc/generators/html/Ecmaspec2Html.cs
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using System.Xml.XPath;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
public class Ecmaspec2Html : IHtmlExporter
|
||||
{
|
||||
static string css_ecmaspec;
|
||||
static XslTransform ecma_transform;
|
||||
static XsltArgumentList args = new XsltArgumentList();
|
||||
|
||||
public string CssCode {
|
||||
get {
|
||||
if (css_ecmaspec != null)
|
||||
return css_ecmaspec;
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecmaspec2Html));
|
||||
Stream str_css = assembly.GetManifestResourceStream ("ecmaspec.css");
|
||||
css_ecmaspec = (new StreamReader (str_css)).ReadToEnd ();
|
||||
return css_ecmaspec;
|
||||
}
|
||||
}
|
||||
|
||||
class ExtObj
|
||||
{
|
||||
public string Colorize (string code, string lang)
|
||||
{
|
||||
return Mono.Utilities.Colorizer.Colorize (code, lang);
|
||||
}
|
||||
}
|
||||
|
||||
public string Export (Stream stream, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (new XPathDocument (stream));
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (new XPathDocument (new StringReader (input)));
|
||||
}
|
||||
|
||||
static string Htmlize (XPathDocument ecma_xml)
|
||||
{
|
||||
if (ecma_transform == null){
|
||||
ecma_transform = new XslTransform ();
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecmaspec2Html));
|
||||
Stream stream;
|
||||
stream = assembly.GetManifestResourceStream ("ecmaspec-html-css.xsl");
|
||||
|
||||
XmlReader xml_reader = new XmlTextReader (stream);
|
||||
ecma_transform.Load (xml_reader, null, null);
|
||||
args.AddExtensionObject ("monodoc:///extensions", new ExtObj ());
|
||||
}
|
||||
|
||||
if (ecma_xml == null) return "";
|
||||
|
||||
StringWriter output = new StringWriter ();
|
||||
ecma_transform.Transform (ecma_xml, args, output, null);
|
||||
|
||||
return output.ToString ();
|
||||
}
|
||||
}
|
||||
}
|
110
external/api-doc-tools/monodoc/Monodoc/generators/html/Error2Html.cs
vendored
Normal file
110
external/api-doc-tools/monodoc/Monodoc/generators/html/Error2Html.cs
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
public class Error2Html : IHtmlExporter
|
||||
{
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (new XPathDocument (new StringReader (input)));
|
||||
}
|
||||
|
||||
public string Export (Stream input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
return Htmlize (new XPathDocument (input));
|
||||
}
|
||||
|
||||
public string CssCode {
|
||||
get {
|
||||
return @"
|
||||
#error_ref {
|
||||
background: #debcb0;
|
||||
border: 2px solid #782609;
|
||||
}
|
||||
div.summary {
|
||||
font-size: 110%;
|
||||
font-weight: bolder;
|
||||
}
|
||||
div.details {
|
||||
font-size: 110%;
|
||||
font-weight: bolder;
|
||||
}
|
||||
div.code_example {
|
||||
background: #f5f5dd;
|
||||
border: 1px solid black;
|
||||
padding-left: 1em;
|
||||
padding-bottom: 1em;
|
||||
margin-top: 1em;
|
||||
white-space: pre;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
div.code_ex_title {
|
||||
position: relative;
|
||||
top: -1em;
|
||||
left: 30%;
|
||||
background: #cdcd82;
|
||||
border: 1px solid black;
|
||||
color: black;
|
||||
font-size: 65%;
|
||||
text-transform: uppercase;
|
||||
width: 40%;
|
||||
padding: 0.3em;
|
||||
text-align: center;
|
||||
}";
|
||||
}
|
||||
}
|
||||
|
||||
public string Htmlize (IXPathNavigable doc)
|
||||
{
|
||||
var navigator = doc.CreateNavigator ();
|
||||
var errorName = navigator.SelectSingleNode ("//ErrorDocumentation/ErrorName");
|
||||
var details = navigator.SelectSingleNode ("//ErrorDocumentation/Details");
|
||||
|
||||
StringWriter sw = new StringWriter ();
|
||||
XmlWriter w = new XmlTextWriter (sw);
|
||||
|
||||
WriteElementWithClass (w, "div", "header");
|
||||
w.WriteAttributeString ("id", "error_ref");
|
||||
WriteElementWithClass (w, "div", "subtitle", "Compiler Error Reference");
|
||||
WriteElementWithClass (w, "div", "title", "Error " + (errorName == null ? string.Empty : errorName.Value));
|
||||
w.WriteEndElement ();
|
||||
|
||||
if (details != null) {
|
||||
WriteElementWithClass (w, "div", "summary", "Summary");
|
||||
|
||||
var summary = details.SelectSingleNode ("/Summary");
|
||||
w.WriteValue (summary == null ? string.Empty : summary.Value);
|
||||
|
||||
WriteElementWithClass (w, "div", "details", "Details");
|
||||
var de = details.SelectSingleNode ("/Details");
|
||||
w.WriteValue (de == null ? string.Empty : de.Value);
|
||||
}
|
||||
|
||||
foreach (XPathNavigator xmp in navigator.Select ("//ErrorDocumentation/Examples/string")) {
|
||||
WriteElementWithClass (w, "div", "code_example");
|
||||
WriteElementWithClass (w, "div", "code_ex_title", "Example");
|
||||
w.WriteRaw (Mono.Utilities.Colorizer.Colorize (xmp.Value, "c#"));;
|
||||
w.WriteEndElement ();
|
||||
}
|
||||
|
||||
w.Close ();
|
||||
|
||||
return sw.ToString ();
|
||||
}
|
||||
|
||||
void WriteElementWithClass (XmlWriter w, string element, string cls, string content = null)
|
||||
{
|
||||
w.WriteStartElement (element);
|
||||
w.WriteAttributeString ("class", cls);
|
||||
if (!string.IsNullOrEmpty (content)) {
|
||||
w.WriteValue (content);
|
||||
w.WriteEndElement ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
external/api-doc-tools/monodoc/Monodoc/generators/html/Idem.cs
vendored
Normal file
34
external/api-doc-tools/monodoc/Monodoc/generators/html/Idem.cs
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
// Input is expected to be already HTML so just return it
|
||||
public class Idem : IHtmlExporter
|
||||
{
|
||||
public string CssCode {
|
||||
get {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public string Export (Stream input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
if (input == null)
|
||||
return null;
|
||||
return new StreamReader (input).ReadToEnd ();
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
if (string.IsNullOrEmpty (input))
|
||||
return null;
|
||||
return input;
|
||||
}
|
||||
}
|
||||
}
|
316
external/api-doc-tools/monodoc/Monodoc/generators/html/Man2Html.cs
vendored
Normal file
316
external/api-doc-tools/monodoc/Monodoc/generators/html/Man2Html.cs
vendored
Normal file
@ -0,0 +1,316 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
public class Man2Html : IHtmlExporter
|
||||
{
|
||||
public string CssCode {
|
||||
get {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public string Export (Stream input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
if (input == null)
|
||||
return null;
|
||||
return GetTextFromReader (new StreamReader (input));
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
if (string.IsNullOrEmpty (input))
|
||||
return null;
|
||||
return GetTextFromReader (new StringReader (input));
|
||||
}
|
||||
|
||||
public static string GetTextFromReader (TextReader file)
|
||||
{
|
||||
string line;
|
||||
StateInfo s = new StateInfo ();
|
||||
|
||||
while ((line = file.ReadLine ()) != null)
|
||||
ProcessLine (line, s);
|
||||
|
||||
return s.output.ToString ();
|
||||
}
|
||||
|
||||
enum ListState {
|
||||
None,
|
||||
Start,
|
||||
Title,
|
||||
}
|
||||
|
||||
class StateInfo {
|
||||
public ListState ls;
|
||||
public Stack<string> tags = new Stack<string> ();
|
||||
public StringBuilder output = new StringBuilder ();
|
||||
}
|
||||
|
||||
static void ProcessLine (string line, StateInfo s)
|
||||
{
|
||||
string[] parts = SplitLine (line);
|
||||
switch (parts [0]) {
|
||||
case ".\\\"": // comments
|
||||
case ".de": // define macro
|
||||
case ".if": // if
|
||||
case ".ne": // ???
|
||||
case "..": // end macro
|
||||
// ignore
|
||||
break;
|
||||
case ".I":
|
||||
s.output.Append ("<i>");
|
||||
Translate (parts, 1, s.output);
|
||||
s.output.Append ("</i>");
|
||||
break;
|
||||
case ".B":
|
||||
s.output.Append ("<b>");
|
||||
Translate (parts, 1, s.output);
|
||||
s.output.Append ("</b>");
|
||||
break;
|
||||
case ".br":
|
||||
Translate (parts, 1, s.output);
|
||||
s.output.Append ("<br />");
|
||||
break;
|
||||
case ".nf":
|
||||
Expect (s, "</p>");
|
||||
s.output.Append ("<pre>\n");
|
||||
s.tags.Push ("</pre>");
|
||||
break;
|
||||
case ".fi":
|
||||
Expect (s, "</pre>");
|
||||
break;
|
||||
case ".PP":
|
||||
Expect (s, "</p>", "</dd>", "</dl>");
|
||||
goto case ".Sp";
|
||||
case ".Sp":
|
||||
Expect (s, "</p>");
|
||||
s.output.Append ("<p>");
|
||||
Translate (parts, 1, s.output);
|
||||
s.tags.Push ("</p>");
|
||||
break;
|
||||
case ".RS":
|
||||
Expect (s, "</p>");
|
||||
s.output.Append ("<blockquote>");
|
||||
s.tags.Push ("</blockquote>");
|
||||
break;
|
||||
case ".RE":
|
||||
ClearUntil (s, "</blockquote>");
|
||||
break;
|
||||
case ".SH":
|
||||
ClearAll (s);
|
||||
s.output.Append ("<h2>");
|
||||
Translate (parts, 1, s.output);
|
||||
s.output.Append ("</h2>")
|
||||
.Append ("<blockquote>");
|
||||
s.tags.Push ("</blockquote>");
|
||||
break;
|
||||
case ".SS":
|
||||
s.output.Append ("<h3>");
|
||||
Translate (parts, 1, s.output);
|
||||
s.output.Append ("</h3>");
|
||||
break;
|
||||
case ".TH": {
|
||||
ClearAll (s);
|
||||
string name = "", extra = "";
|
||||
if (parts.Length >= 4 && parts [2].Trim ().Length == 0) {
|
||||
name = parts [1] + "(" + parts [3] + ")";
|
||||
if (parts.Length > 4) {
|
||||
int start = 4;
|
||||
if (parts [start].Trim ().Length == 0)
|
||||
++start;
|
||||
extra = string.Join ("", parts, start, parts.Length-start);
|
||||
}
|
||||
}
|
||||
else
|
||||
name = string.Join ("", parts, 1, parts.Length-1);
|
||||
s.output.Append ("<table width=\"100%\" bgcolor=\"#b0c4da\">" +
|
||||
"<tr colspan=\"2\"><td>Manual Pages</td></tr>\n" +
|
||||
"<tr><td><h3>");
|
||||
Translate (name, s.output);
|
||||
s.output.Append ("</h3></td><td align=\"right\">");
|
||||
Translate (extra, s.output);
|
||||
s.output.Append ("</td></tr></table>");
|
||||
break;
|
||||
}
|
||||
case ".TP":
|
||||
Expect (s, "</p>");
|
||||
if (s.tags.Count > 0 && s.tags.Peek ().ToString () != "</dd>") {
|
||||
s.output.Append ("<dl>");
|
||||
s.tags.Push ("</dl>");
|
||||
}
|
||||
else
|
||||
Expect (s, "</dd>");
|
||||
s.output.Append ("<dt>");
|
||||
s.tags.Push ("</dt>");
|
||||
s.ls = ListState.Start;
|
||||
break;
|
||||
default:
|
||||
Translate (line, s.output);
|
||||
break;
|
||||
}
|
||||
if (s.ls == ListState.Start)
|
||||
s.ls = ListState.Title;
|
||||
else if (s.ls == ListState.Title) {
|
||||
Expect (s, "</dt>");
|
||||
s.output.Append ("<dd>");
|
||||
s.tags.Push ("</dd>");
|
||||
s.ls = ListState.None;
|
||||
}
|
||||
s.output.Append ("\n");
|
||||
}
|
||||
|
||||
static string[] SplitLine (string line)
|
||||
{
|
||||
if (line.Length > 1 && line [0] != '.')
|
||||
return new string[]{null, line};
|
||||
|
||||
int i;
|
||||
for (i = 0; i < line.Length; ++i) {
|
||||
if (char.IsWhiteSpace (line, i))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == line.Length)
|
||||
return new string[]{line};
|
||||
|
||||
var pieces = new List<string> ();
|
||||
pieces.Add (line.Substring (0, i));
|
||||
bool inQuotes = false;
|
||||
bool prevWs = true;
|
||||
++i;
|
||||
int start = i;
|
||||
for ( ; i < line.Length; ++i) {
|
||||
char c = line [i];
|
||||
if (inQuotes) {
|
||||
if (c == '"') {
|
||||
Add (pieces, line, start, i);
|
||||
start = i+1;
|
||||
inQuotes = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (prevWs && c == '"') {
|
||||
Add (pieces, line, start, i);
|
||||
start = i+1;
|
||||
inQuotes = true;
|
||||
}
|
||||
else if (char.IsWhiteSpace (c)) {
|
||||
if (!prevWs) {
|
||||
Add (pieces, line, start, i);
|
||||
start = i;
|
||||
}
|
||||
prevWs = true;
|
||||
}
|
||||
else {
|
||||
if (prevWs) {
|
||||
Add (pieces, line, start, i);
|
||||
start = i;
|
||||
}
|
||||
prevWs = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (start > 0 && start != line.Length)
|
||||
pieces.Add (line.Substring (start, line.Length-start));
|
||||
return pieces.ToArray ();
|
||||
}
|
||||
|
||||
static void Add (List<string> pieces, string line, int start, int end)
|
||||
{
|
||||
if (start == end)
|
||||
return;
|
||||
pieces.Add (line.Substring (start, end-start));
|
||||
}
|
||||
|
||||
static void Expect (StateInfo s, params string[] expected)
|
||||
{
|
||||
string e;
|
||||
while (s.tags.Count > 0 &&
|
||||
Array.IndexOf (expected, (e = s.tags.Peek ().ToString ())) >= 0) {
|
||||
s.output.Append (s.tags.Pop ().ToString ());
|
||||
}
|
||||
}
|
||||
|
||||
static void ClearUntil (StateInfo s, string required)
|
||||
{
|
||||
string e = null;
|
||||
while (s.tags.Count > 0 &&
|
||||
(e = s.tags.Peek ().ToString ()) != required) {
|
||||
s.output.Append (s.tags.Pop ().ToString ());
|
||||
}
|
||||
if (e == required)
|
||||
s.output.Append (s.tags.Pop ().ToString ());
|
||||
}
|
||||
|
||||
static void ClearAll (StateInfo s)
|
||||
{
|
||||
while (s.tags.Count > 0)
|
||||
s.output.Append (s.tags.Pop ().ToString ());
|
||||
}
|
||||
|
||||
static void Translate (string[] lines, int startIndex, StringBuilder output)
|
||||
{
|
||||
if (lines.Length <= startIndex)
|
||||
return;
|
||||
do {
|
||||
Translate (lines [startIndex++], output);
|
||||
if (startIndex == lines.Length)
|
||||
break;
|
||||
} while (startIndex < lines.Length);
|
||||
}
|
||||
|
||||
static void Translate (string line, StringBuilder output)
|
||||
{
|
||||
string span = null;
|
||||
int start = output.Length;
|
||||
for (int i = 0; i < line.Length; ++i) {
|
||||
switch (line [i]) {
|
||||
case '\\': {
|
||||
if ((i+2) < line.Length && line [i+1] == 'f') {
|
||||
if (line [i+2] == 'I') {
|
||||
output.Append ("<i>");
|
||||
span = "</i>";
|
||||
}
|
||||
else if (line [i+2] == 'B') {
|
||||
output.Append ("<b>");
|
||||
span = "</b>";
|
||||
}
|
||||
else if (line [i+2] == 'R' || line [i+2] == 'P') {
|
||||
output.Append (span);
|
||||
}
|
||||
else
|
||||
goto default;
|
||||
i += 2;
|
||||
}
|
||||
else if ((i+1) < line.Length) {
|
||||
output.Append (line [i+1]);
|
||||
++i;
|
||||
}
|
||||
else
|
||||
goto default;
|
||||
break;
|
||||
}
|
||||
case '<':
|
||||
output.Append ("<");
|
||||
break;
|
||||
case '>':
|
||||
output.Append (">");
|
||||
break;
|
||||
case '&':
|
||||
output.Append ("&");
|
||||
break;
|
||||
default:
|
||||
output.Append (line [i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
87
external/api-doc-tools/monodoc/Monodoc/generators/html/MonoBook2Html.cs
vendored
Normal file
87
external/api-doc-tools/monodoc/Monodoc/generators/html/MonoBook2Html.cs
vendored
Normal file
@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
// Input is expected to be already HTML so just return it
|
||||
public class MonoBook2Html : IHtmlExporter
|
||||
{
|
||||
public string CssCode {
|
||||
get {
|
||||
return @" h3 {
|
||||
font-size: 18px;
|
||||
padding-bottom: 4pt;
|
||||
border-bottom: 2px solid #dddddd;
|
||||
}
|
||||
|
||||
.api {
|
||||
border: 1px solid;
|
||||
padding: 10pt;
|
||||
margin: 10pt;
|
||||
}
|
||||
|
||||
.api-entry {
|
||||
border-bottom: none;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.prototype {
|
||||
border: 1px solid;
|
||||
background-color: #f2f2f2;
|
||||
padding: 5pt;
|
||||
margin-top: 5pt;
|
||||
margin-bottom: 5pt;
|
||||
}
|
||||
|
||||
.header {
|
||||
border: 1px solid !important;
|
||||
padding: 0 0 5pt 5pt !important;
|
||||
margin: 10pt !important;
|
||||
white-space: pre !important;
|
||||
font-family: monospace !important;
|
||||
font-weight: normal !important;
|
||||
font-size: 1em !important;
|
||||
}
|
||||
|
||||
.code {
|
||||
border: 1px solid;
|
||||
padding: 0 0 5pt 5pt;
|
||||
margin: 10pt;
|
||||
white-space: pre;
|
||||
font-family: monospace;
|
||||
}
|
||||
";
|
||||
}
|
||||
}
|
||||
|
||||
public string Export (Stream input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
if (input == null)
|
||||
return null;
|
||||
return FromXmlReader (XmlReader.Create (input));
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
if (string.IsNullOrEmpty (input))
|
||||
return null;
|
||||
return FromXmlReader (XmlReader.Create (new StringReader (input)));
|
||||
}
|
||||
|
||||
public string FromXmlReader (XmlReader reader)
|
||||
{
|
||||
if (!reader.ReadToDescendant ("head"))
|
||||
return null;
|
||||
if (!reader.ReadToNextSibling ("body"))
|
||||
return null;
|
||||
|
||||
return reader.ReadInnerXml ();
|
||||
}
|
||||
}
|
||||
}
|
44
external/api-doc-tools/monodoc/Monodoc/generators/html/Toc2Html.cs
vendored
Normal file
44
external/api-doc-tools/monodoc/Monodoc/generators/html/Toc2Html.cs
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Xsl;
|
||||
using System.Xml.XPath;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Monodoc.Generators.Html
|
||||
{
|
||||
public class Toc2Html : IHtmlExporter
|
||||
{
|
||||
XslTransform transform;
|
||||
|
||||
public Toc2Html ()
|
||||
{
|
||||
transform = new XslTransform ();
|
||||
var assembly = Assembly.GetAssembly (typeof (Toc2Html));
|
||||
var stream = assembly.GetManifestResourceStream ("toc-html.xsl");
|
||||
XmlReader xml_reader = new XmlTextReader (stream);
|
||||
transform.Load (xml_reader, null, null);
|
||||
}
|
||||
|
||||
public string Export (Stream input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
var output = new StringWriter ();
|
||||
transform.Transform (new XPathDocument (input), null, output, null);
|
||||
return output.ToString ();
|
||||
}
|
||||
|
||||
public string Export (string input, Dictionary<string, string> extraArgs)
|
||||
{
|
||||
var output = new StringWriter ();
|
||||
transform.Transform (new XPathDocument (new StringReader (input)), null, output, null);
|
||||
return output.ToString ();
|
||||
}
|
||||
|
||||
public string CssCode {
|
||||
get {
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user