public MarkdownType BuildType(MarkdownType type, MarkdownNamespace namespaceItem, IEnumerable <XmlDocumentComment> comments) { Constants.Logger?.LogTrace("Building Markdown Item for Type {typeName}", type.Name); MarkdownRepo.TryAdd(type); type.NamespaceItem = namespaceItem; type.Summary = comments.FirstOrDefault(x => x.MemberName == type.Name || x.MemberName.StartsWith(type.Name))?.Summary ?? ""; Constants.Logger?.LogTrace("Getting Markdown Fields for Type {typeName}", type.Name); BuildFields(type, comments, type.GetFields().Together(type.GetStaticFields()).ToArray()); Constants.Logger?.LogTrace("Getting Markdown Properties for Type {typeName}", type.Name); BuildProperties(type, comments, type.GetProperties().Together(type.GetStaticProperties()).ToArray()); Constants.Logger?.LogTrace("Getting Markdown Methods for Type {typeName}", type.Name); BuildMethods(type, comments, type.GetMethods().Together(type.GetStaticMethods()).ToArray()); Constants.Logger?.LogTrace("Getting Markdown Events for Type {typeName}", type.Name); BuildEvents(type, comments, type.GetEvents().Together(type.GetStaticEvents()).ToArray()); Constants.Logger?.LogTrace("Getting Markdown Constructors for Type {typeName}", type.Name); BuildConstructors(type, comments, type.GetConstructors().Together(type.GetStaticConstructors()).ToArray()); Constants.Logger?.LogTrace("Completed Building Markdown Type {typeName}", type.Name); return(type); }
public List <MarkdownNamespace> BuildTypes(MarkdownType[] types, ILookup <string, XmlDocumentComment> comments) { List <MarkdownNamespace> namespaces = new List <MarkdownNamespace>(); foreach (var type in types) { var tempNamespace = new MarkdownNamespace(type.InternalType.Namespace); var myNamespace = MarkdownRepo.TryGetOrAdd(type.InternalType.Namespace, tempNamespace); var typeComments = comments[type.FullName]; if (!type.InternalType.IsEnum) { var builtType = BuildType(type, myNamespace, typeComments); myNamespace.Types.Add(builtType); } else { var enumType = BuildEnum(type, myNamespace, typeComments); myNamespace.Enums.Add(enumType); } namespaces.Add(myNamespace); } return(namespaces); }
/// <summary> /// Builds Namespace Pages with the given MarkdownNamespace Item /// </summary> /// <param name="item">The MarkdownNamespace item to build the page with</param> /// <returns>A string of the markdown content or "" if no page created</returns> public string BuildPage(MarkdownNamespace item) { if (!_options.BuildNamespacePages) { return(""); } return(_namespaceBuilder.BuildPage(item)); }
/// <summary> /// Builds the markdown content for the namespace page /// </summary> /// <param name="item">The markdown namespace item</param> /// <returns>The markdown content</returns> public string BuildPage(MarkdownNamespace item) { DefaultTheme.ThemeLogger?.LogDebug("Building Namespace Page"); var namespaceBuilder = new MarkdownBuilder(); namespaceBuilder.HeaderWithLink(1, item.FullName, item.To(item)); namespaceBuilder.AppendLine(); var summary = ""; if (!string.IsNullOrEmpty(item.Summary)) { summary = item.Summary; } else if (_options.NamespaceSummaries.ContainsKey(item.FullName)) { summary = _options.NamespaceSummaries[item.FullName]; } if (!string.IsNullOrEmpty(summary)) { namespaceBuilder.Header(2, "Summary"); namespaceBuilder.AppendLine(summary).AppendLine(); } namespaceBuilder.Header(2, "Types").AppendLine(); foreach (var type in item.Types.OrderBy(x => x.Name)) { var sb = new StringBuilder(); if (!String.IsNullOrEmpty(type.FileName)) { namespaceBuilder.List(Cleaner.CreateFullTypeWithLinks(item, type.InternalType, false, true)); } else { namespaceBuilder.List(item.Name); } if (!string.IsNullOrEmpty(type.Summary)) { namespaceBuilder.Tab().List(type.Summary); } } namespaceBuilder.AppendLine(); return(namespaceBuilder.ToString()); }
public MarkdownEnum BuildEnum(MarkdownType type, MarkdownNamespace namespaceItem, IEnumerable <XmlDocumentComment> comments) { Constants.Logger?.LogTrace("Building Markdown Item for Enum {enumName}", type.Name); MarkdownEnum me = new MarkdownEnum(); me.NamespaceItem = namespaceItem; me.InternalType = type.InternalType; me.Comments = comments; me.Summary = comments.FirstOrDefault(x => x.MemberName == me.Name || x.MemberName.StartsWith(me.Name + "`"))?.Summary ?? ""; MarkdownRepo.TryAdd(me); Constants.Logger?.LogTrace("Completed Building Markdown Enum {typeName}", me.Name); return(me); }