private string CreateFragmentLinkForType(string cref) { if (string.IsNullOrWhiteSpace(cref)) { return string.Empty; } var typeName = SlashdocIdentifierProvider.GetTypeName(cref); if (typeName == null) { if (cref.Length > 2 && cref[1] == ':') { return cref.Substring(2); } else { return string.Empty; } } var type = _assemblyReflector.LookupType(typeName); if (type != null) { return string.Format( CultureInfo.InvariantCulture, "<a href=\"#{0}\">{1}</a>", XmlEscape(_language.GetDisplayName(type)), XmlEscape(_language.GetShortDisplayName(type))); } else { return XmlEscape(typeName); } }
private void WriteTypesOverviewTable(IAssemblyReflector assembly, SlashdocSummaryHtmlFormatter formatter) { WriteDescriptionTableHeader("Types"); foreach (var type in assembly.Types .Where(t => ReflectionHelper.IsVisible(t)) .OrderBy(t => _language.GetDisplayName(t))) { var displayName = _language.GetDisplayName(type); _writer.WriteStartElement("tr"); _writer.WriteStartElement("td"); _writer.WriteStartElement("a"); _writer.WriteAttributeString("href", "#" + displayName); _writer.WriteString(displayName); _writer.WriteEndElement(); // a _writer.WriteString(" " + _language.GetMetaTypeName(type)); _writer.WriteEndElement(); // td _writer.WriteStartElement("td"); var slashdocSummaryHtml = formatter.FormatSummary(LookupXmlDescription( SlashdocIdentifierProvider.GetId(type), displayName + " " + _language.GetMetaTypeName(type))); _writer.WriteRaw(slashdocSummaryHtml); _writer.WriteEndElement(); // td _writer.WriteEndElement(); // tr } WriteDescriptionTableFooter(); }
private static HashSet <string> GetSlashdocIdsForAllVisibleTypesAndMembers(IAssemblyReflector assembly) { var ids = new HashSet <string>(); foreach (var type in assembly.Types .Where(t => ReflectionHelper.IsVisible(t))) { ids.Add(SlashdocIdentifierProvider.GetId(type)); if (type.IsEnum) { AddSlashdocIds(ReflectionHelper.GetEnumMembers(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); } else { AddSlashdocIds(ReflectionHelper.GetVisibleConstructors(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); AddSlashdocIds(ReflectionHelper.GetVisibleProperties(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); AddSlashdocIds(ReflectionHelper.GetVisibleMethods(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); AddSlashdocIds(ReflectionHelper.GetVisibleOperators(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); AddSlashdocIds(ReflectionHelper.GetVisibleFields(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); AddSlashdocIds(ReflectionHelper.GetVisibleEvents(type), (x) => SlashdocIdentifierProvider.GetId(x), ids); } } return(ids); }
public void DescribeType(Type type, SlashdocSummaryHtmlFormatter formatter) { if (type == null) { throw new ArgumentNullException("type"); } _writer.WriteStartElement("div"); _writer.WriteAttributeString("id", _language.GetDisplayName(type)); var displayName = _language.GetShortDisplayName(type); var metaType = _language.GetMetaTypeName(type); WriteTypeHeader(type, displayName, metaType, formatter); if (type.IsEnum) { var values = ReflectionHelper.GetEnumMembers(type) .OrderBy(x => x.GetRawConstantValue()); WriteSection("Members", values, (x) => x.Name, (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); } else if (!HideMembers(type)) { WriteTextElement("p", string.Format(CultureInfo.InvariantCulture, "The {0} {1} exposes the following members.", displayName, metaType)); var constructors = ReflectionHelper.GetVisibleConstructors(type) .OrderBy(x => SlashdocIdentifierProvider.GetId(x)); WriteSection("Constructors", constructors, (x) => _language.GetSignature(x), (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); var properties = ReflectionHelper.GetVisibleProperties(type) .OrderBy(x => SlashdocIdentifierProvider.GetId(x)); WriteSection("Properties", properties, (x) => _language.GetSignature(x), (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); var methods = ReflectionHelper.GetVisibleMethods(type) .Where(x => !ReflectionHelper.IsTrivialMethod(x)) .OrderBy(x => SlashdocIdentifierProvider.GetId(x)); WriteSection("Methods", methods, (x) => _language.GetSignature(x), (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); var operators = ReflectionHelper.GetVisibleOperators(type) .OrderBy(x => SlashdocIdentifierProvider.GetId(x)); WriteSection("Operators", operators, (x) => _language.GetSignature(x), (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); var fields = ReflectionHelper.GetVisibleFields(type) .OrderBy(x => SlashdocIdentifierProvider.GetId(x)); WriteSection("Fields", fields, (x) => _language.GetSignature(x), (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); var events = ReflectionHelper.GetVisibleEvents(type) .OrderBy(x => SlashdocIdentifierProvider.GetId(x)); WriteSection("Events", events, (x) => _language.GetSignature(x), (x) => SlashdocIdentifierProvider.GetId(x), (x) => displayName + "." + x.Name, formatter); } _writer.WriteEndElement(); // div }
private void WriteTypeHeader(Type type, string displayName, string metaType, SlashdocSummaryHtmlFormatter formatter) { WriteTextElement("h2", string.Format(CultureInfo.InvariantCulture, "{0} {1}", displayName, metaType)); _writer.WriteStartElement("table"); _writer.WriteAttributeString("class", "typeheader"); _writer.WriteStartElement("tr"); _writer.WriteStartElement("td"); var slashdocSummaryHtml = formatter.FormatSummary(LookupXmlDescription( SlashdocIdentifierProvider.GetId(type), _language.GetDisplayName(type) + " " + _language.GetMetaTypeName(type))); _writer.WriteRaw(slashdocSummaryHtml); WriteInfo("Namespace", type.Namespace); WriteInfo("Signature", _language.GetSignature(type)); _writer.WriteEndElement(); // td _writer.WriteEndElement(); // tr _writer.WriteEndElement(); // table }