private void BuildPropertyHtml(IEnumerable <ReflectedPropertyInfo> properties) { var q = from p in properties where !p.IsInherited group p by p.Name into overloads select overloads; foreach (var memberOverloadsEnumerable in q) { XDoc html = null; string href = null; string path = null; string title = null; string assembly = null; var memberOverloads = memberOverloadsEnumerable.ToList(); foreach (var member in memberOverloads.OrderBy(x => x.DisplayName)) { var xmlDoc = GetDoc(member.Signature); if (html == null) { href = member.UriPath; if (string.IsNullOrEmpty(href)) { continue; } path = member.FilePath; title = member.Name + " Property"; html = NewHtmlDocument(title, true); assembly = member.Assembly; } html.StartSection(1, "property", member.DisplayName); html.CSharpBlock(member.CodeSignature) .Div("summary", xmlDoc["summary"]) .Section(2, "remarks", "Remarks", xmlDoc["remarks"]); if (member.IsIndexer) { BuildParameterTable(html, xmlDoc, member.IndexerParameters); } html.StartSection(2, "returns", "Value"); html.StartNameValueLine("type", "Type"); BuildParameterMarkup(html, member.ReturnType); html.EndNameValue() .Start("div") .Attr("class", "summary") .AddNodes(xmlDoc["returns"]) .End() .EndSection(); // returns section AddExceptionSection(html, xmlDoc); html.EndSection(); } if (html != null) { Save(html, title, href, path, assembly); } } }
private void BuildGenericParameterSection(int level, XDoc html, XDoc xmlDoc, IEnumerable <ReflectedGenericParameterInfo> genericParameters) { if (genericParameters.Any()) { html.StartSection(level, "genericparameters", "Generic Parameters"); foreach (var parameter in genericParameters.OrderBy(x => x.ParameterPosition)) { html.StartSection(level + 1, "genericparameter", "Parameter " + parameter.Name) .Div("description", xmlDoc[string.Format("typeparam[@name='{0}']", parameter.Name)]) .StartNameValueBlock("constraints", "Constraints"); var constraints = new List <string>(); if (parameter.MustBeReferenceType) { constraints.Add("class"); } if (parameter.MustBeValueType) { constraints.Add("struct"); } if (parameter.MustHaveDefaultConstructor) { constraints.Add("new()"); } if (constraints.Any() || parameter.Types.Any()) { html.Start("ul"); foreach (var constraint in constraints) { html.Start("li").Elem("b", constraint).End(); } foreach (var parameterType in parameter.Types) { html.Start("li"); BuildParameterMarkup(html, parameterType); html.End(); } html.End(); // ul } else { html.Elem("i", "none"); } html.EndNameValue() .EndSection(); } html.EndSection(); } }
private void BuildConstructorHtml(IEnumerable <ReflectedConstructorInfo> ctors) { XDoc html = null; string href = null; string path = null; string title = null; string assembly = null; foreach (var ctor in ctors.OrderBy(x => x.DisplayName)) { var xmlDoc = GetDoc(ctor.Signature); if (html == null) { href = ctor.UriPath; if (string.IsNullOrEmpty(href)) { continue; } path = ctor.FilePath; title = ctor.Type.Name + " Constructors"; html = NewHtmlDocument(title, true); assembly = ctor.Assembly; } html.StartSection(1, "ctor", ctor.DisplayName) .CSharpBlock(ctor.CodeSignature) .Div("summary", xmlDoc["summary"]) .Section(2, "remarks", "Remarks", xmlDoc["remarks"]); BuildParameterTable(html, xmlDoc, ctor.Parameters); AddExceptionSection(html, xmlDoc); html.EndSection(); } if (html != null) { Save(html, title, href, path, assembly); } }
private void AddMemberTables(XDoc html, ReflectedTypeInfo type) { if(!type.Constructors.Any() && !type.Fields.Any() && !type.Properties.Any() && !type.Methods.Any() && !type.Events.Any()) { return; } html.StartSection(1, "members", "Members"); if(type.Constructors.Any()) { html.StartSection(2, "ctors", "Constructors") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach(var member in type.Constructors.OrderBy(x => x.DisplayName)) { BuildConstructorRow(html, member); } html.End() // table .EndSection(); } if(type.Fields.Any()) { html.StartSection(2, "fields", "Fields") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach(var member in type.Fields.OrderBy(x => x.DisplayName)) { BuildFieldRow(html, member); } html.End() // table .EndSection(); } if(type.Properties.Any()) { html.StartSection(2, "properties", "Properties") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach(var member in type.Properties.OrderBy(x => x.DisplayName)) { BuildPropertyRow(html, member); } html.End() // table .EndSection(); } if(type.Methods.Any()) { html.StartSection(2, "methods", "Methods") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach(var member in type.Methods.OrderBy(x => x.DisplayName)) { BuildMethodRow(html, member); } html.End() // table .EndSection(); } if(type.Events.Any()) { html.StartSection(2, "events", "Events") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach(var member in type.Events.OrderBy(x => x.DisplayName)) { BuildEventRow(html, member); } html.End() // table .EndSection(); } html.EndSection(); //members }
private void BuildGenericParameterSection(int level, XDoc html, XDoc xmlDoc, IEnumerable<ReflectedGenericParameterInfo> genericParameters) { if(genericParameters.Any()) { html.StartSection(level, "genericparameters", "Generic Parameters"); foreach(var parameter in genericParameters.OrderBy(x => x.ParameterPosition)) { html.StartSection(level + 1, "genericparameter", "Parameter " + parameter.Name) .Div("description", xmlDoc[string.Format("typeparam[@name='{0}']", parameter.Name)]) .StartNameValueBlock("constraints", "Constraints"); var constraints = new List<string>(); if(parameter.MustBeReferenceType) { constraints.Add("class"); } if(parameter.MustBeValueType) { constraints.Add("struct"); } if(parameter.MustHaveDefaultConstructor) { constraints.Add("new()"); } if(constraints.Any() || parameter.Types.Any()) { html.Start("ul"); foreach(var constraint in constraints) { html.Start("li").Elem("b", constraint).End(); } foreach(var parameterType in parameter.Types) { html.Start("li"); BuildParameterMarkup(html, parameterType); html.End(); } html.End(); // ul } else { html.Elem("i", "none"); } html.EndNameValue() .EndSection(); } html.EndSection(); } }
private void AddMemberTables(XDoc html, ReflectedTypeInfo type) { if (!type.Constructors.Any() && !type.Fields.Any() && !type.Properties.Any() && !type.Methods.Any() && !type.Events.Any()) { return; } html.StartSection(1, "members", "Members"); if (type.Constructors.Any()) { html.StartSection(2, "ctors", "Constructors") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach (var member in type.Constructors.OrderBy(x => x.DisplayName)) { BuildConstructorRow(html, member); } html.End() // table .EndSection(); } if (type.Fields.Any()) { html.StartSection(2, "fields", "Fields") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach (var member in type.Fields.OrderBy(x => x.DisplayName)) { BuildFieldRow(html, member); } html.End() // table .EndSection(); } if (type.Properties.Any()) { html.StartSection(2, "properties", "Properties") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach (var member in type.Properties.OrderBy(x => x.DisplayName)) { BuildPropertyRow(html, member); } html.End() // table .EndSection(); } if (type.Methods.Any()) { html.StartSection(2, "methods", "Methods") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach (var member in type.Methods.OrderBy(x => x.DisplayName)) { BuildMethodRow(html, member); } html.End() // table .EndSection(); } if (type.Events.Any()) { html.StartSection(2, "events", "Events") .Start("table") .Start("tr").Elem("th", "Visibility").Elem("th", "Description").End(); foreach (var member in type.Events.OrderBy(x => x.DisplayName)) { BuildEventRow(html, member); } html.End() // table .EndSection(); } html.EndSection(); //members }
private void BuildMethodHtml(IEnumerable <ReflectedMethodInfo> methods) { var q = from m in methods where !m.IsInherited group m by m.Name into overloads select overloads; foreach (var memberOverloads in q) { XDoc html = null; string href = null; string path = null; string title = null; string assembly = null; foreach (var method in memberOverloads.OrderBy(x => x.DisplayName)) { var xmlDoc = GetDoc(method.Signature); if (html == null) { href = method.UriPath; if (string.IsNullOrEmpty(href)) { continue; } path = method.FilePath; title = method.Name + (method.IsExtensionMethod ? " Extension" : "") + " Method"; html = NewHtmlDocument(title, true); assembly = method.Assembly; } html .StartSection(1, "method", method.DisplayName) .CSharpBlock(method.CodeSignature) .Div("summary", xmlDoc["summary"]) .Section(2, "remarks", "Remarks", xmlDoc["remarks"]); BuildGenericParameterSection(2, html, xmlDoc, method.GenericParameters.Where(x => x.MethodParameter)); BuildParameterTable(html, xmlDoc, method.Parameters); html.StartSection(2, "returns", "Returns"); if (!method.ReturnType.IsGenericParameter && method.ReturnType.Type.Name == "Void") { html.Value("void"); } else { html.StartNameValueLine("type", "Type"); BuildParameterMarkup(html, method.ReturnType); html.EndNameValue() .Start("div") .Attr("class", "summary") .AddNodes(xmlDoc["returns"]) .End(); } html.EndSection(); // return section AddExceptionSection(html, xmlDoc); html.EndSection(); } if (html != null) { Save(html, title, href, path, assembly); } } }