/// <summary>Generates the category section for the members info.</summary> /// <param name="sectionInfoTypes">The section kind.</param> /// <param name="categoryHeader">The category header name.</param> /// <param name="tableName">The table name.</param> /// <param name="settings">The image directory.</param> /// <param name="items">The table row items.</param> /// <returns>The <see cref="string"/>.</returns> private static string GenerateSection(MemberInfoTypes sectionInfoTypes, string categoryHeader, string tableName, ReportSettings settings, List <HierarchyNode> items) { const string DescriptionHeader = "Description"; const string ValuesHeader = "Values"; string basePath; char pathDivider; if (settings.FileRepositoryIsUrl) { pathDivider = Path.AltDirectorySeparatorChar; // Retrieve the trimmed relative path string parentUrl = TextUtil.GetParentUriString(new Uri(settings.ImageRepository)); string relativePath = TextUtil.GetRelativeURIPath(parentUrl, settings.ImageRepository); string formattedPath = relativePath.Substring(1, relativePath.Length - 2); // Formats the path to a url from string basePath = $@"{formattedPath}"; } else { pathDivider = Path.DirectorySeparatorChar; // Return the relative path string dirPath = Path.GetDirectoryName(settings.BuildPath); string relativePath = TextUtil.GetRelativePath(settings.ImageRepository, dirPath); // Format the path to scope into the image directory for retrieving the images from the local system. basePath = $@".\{relativePath}"; } string imageSource = $@"{basePath}{pathDivider}{tableName}{Constants.ImageFilePNGExtension}"; string memberImageText = HtmlUtil.GenerateHTMLImageCode(imageSource, tableName, new Size(16, 16)); // Create the markdown table layout. var columns = new List <string>(); var rows = new List <string>(); // Create the top left section. Add an empty buffer image to keep the table cells at a minimum size to prevent hiding the image cells when during text wrapping. columns.Add(string.Format("<img src={0}file://null{0} width={0}{1}{0} height={0}0{0} alt ={0}{0} />", Constants.Quotes, 64)); columns.Add(tableName); columns.Add(DescriptionHeader); // Determine the member kind. switch (sectionInfoTypes) { case MemberInfoTypes.Class: { // Create section separators. const string sectionSeparators = TableDividerSet0; rows.Add(sectionSeparators); // Create section items content. foreach (HierarchyNode entry in items) { string itemName = entry.Name; string itemDescription = DocumentationExtensions.GetSummary(entry.NodeType); if (string.IsNullOrEmpty(itemDescription)) { itemDescription = MissingDocumentationText; } string rowItemName = $"{memberImageText} {MarkdownSeparator} {itemName} {MarkdownSeparator} {itemDescription}"; rows.Add(rowItemName); } break; } case MemberInfoTypes.Delegate: { // Create section separators. const string sectionSeparators = TableDividerSet0; rows.Add(sectionSeparators); // Create section items content. foreach (HierarchyNode entry in items) { string itemName = entry.Name; string itemDescription = DocumentationExtensions.GetSummary(entry.NodeType); if (string.IsNullOrEmpty(itemDescription)) { itemDescription = MissingDocumentationText; } string rowItemName = $"{memberImageText} {MarkdownSeparator} {itemName} {MarkdownSeparator} {itemDescription}"; rows.Add(rowItemName); } break; } case MemberInfoTypes.Enumerator: { columns.Add(ValuesHeader); // Create section separators. const string sectionSeparators = TableDividerSet1; rows.Add(sectionSeparators); // Create section items content. foreach (HierarchyNode entry in items) { string itemName = entry.Name; string itemDescription = DocumentationExtensions.GetSummary(entry.NodeType); if (string.IsNullOrEmpty(itemDescription)) { itemDescription = MissingDocumentationText; } string enumValues = TypesUtil.GetEnumeratorValues(entry.NodeType); string rowItemName = $"{memberImageText} {MarkdownSeparator} {itemName} {MarkdownSeparator} {itemDescription} {MarkdownSeparator} {enumValues}."; rows.Add(rowItemName); } break; } case MemberInfoTypes.Structure: { // Create section separators. const string sectionSeparators = TableDividerSet0; rows.Add(sectionSeparators); // Create section items content. foreach (HierarchyNode entry in items) { string itemName = entry.Name; string itemDescription = DocumentationExtensions.GetSummary(entry.NodeType); if (string.IsNullOrEmpty(itemDescription)) { itemDescription = MissingDocumentationText; } string rowItemName = $"{memberImageText} {MarkdownSeparator} {itemName} {MarkdownSeparator} {itemDescription}"; rows.Add(rowItemName); } break; } case MemberInfoTypes.Interface: { // Create section separators. const string sectionSeparators = TableDividerSet0; rows.Add(sectionSeparators); // Create section items content. foreach (HierarchyNode entry in items) { string itemName = entry.Name; string itemDescription = DocumentationExtensions.GetSummary(entry.NodeType); if (string.IsNullOrEmpty(itemDescription)) { itemDescription = MissingDocumentationText; } string rowItemName = $"{memberImageText} {MarkdownSeparator} {itemName} {MarkdownSeparator} {itemDescription}"; rows.Add(rowItemName); } break; } default: { throw new ArgumentOutOfRangeException(nameof(sectionInfoTypes), sectionInfoTypes, null); } } // Generate markdown table. StringBuilder sectionBuilder = new StringBuilder(); // Create the header. sectionBuilder.AppendLine(MarkdownHeader.CreateHeader(categoryHeader, 3)); // Create the table. string table = new MarkdownTable(columns, rows).MarkdownContentText; sectionBuilder.Append(table); return(sectionBuilder.ToString()); }