private DocFile ProcessSerialization(DocSerialization ser, DocAssembly assembly) { var result = new DocFile(ser.FileName); result.AddThenBlankLine(writer.WriteHeading1($"{ser.Name} Reference")); result.AddThenBlankLine(ParserUtils.ProcessBreadcrumb(assembly)); var table = new MarkdownTable("ExpressionType", "Serializer"); foreach (ExpressionType expressionType in Enum.GetValues(typeof(ExpressionType))) { var name = expressionType.ToString(); if (ser.Serializers.ContainsKey(expressionType)) { var entry = ser.Serializers[expressionType]; table.AddRow(name, writer.WriteLink(entry.Name.NameOnly(), entry.FileName)); } else { table.AddRow(name, "_Not Supported_"); } } writer.AddRange(result.Markdown, table.CloseTable()); return(result); }
public void TestAddInvalidRow() { var table = new MarkdownTable(new MarkdownTableHeader(3)); Assert.Throws <ArgumentException>(() => table.AddRow(new MarkdownTableRow("A", "B"))); Assert.Equal(0, table.RowsCount); }
public void TestAddRow() { var table = new MarkdownTable(new MarkdownTableHeader(3)); table.AddRow(new MarkdownTableRow("A", "B", "C")); Assert.Equal(1, table.RowsCount); }
public void TestGetRowAt() { var table = new MarkdownTable(new MarkdownTableHeader(3)); var row = new MarkdownTableRow("A", "B", "C"); table.AddRow(row); Assert.Equal(row, table.GetRowAt(0)); }
/// <summary> /// Parses a <see cref="DocNamespace"/> into a <see cref="DocFile"/>. /// </summary> /// <param name="ns">The <see cref="DocNamespace"/> to parse.</param> /// <returns>The transformed <see cref="DocFile"/>.</returns> private DocFile ProcessNamespace(DocNamespace ns) { var result = new DocFile(ns.FileName); result.AddThenBlankLine(writer.WriteHeading1($"{ns.Name} Namespace")); result.AddThenBlankLine(ParserUtils.ProcessBreadcrumb(ns)); if (ns.Types.Any(t => t.IsClass)) { result.AddThenBlankLine(writer.WriteHeading2("Classes")); var table = new MarkdownTable("Class", "Description"); foreach (var c in ns.Types.Where(t => t.IsClass).OrderBy(t => t.TypeRef.FriendlyName)) { table.AddRow(writer.WriteLink(c.TypeRef.FriendlyName, c.FileName), c.Description); result.Files.Add(ProcessType(c)); } writer.AddRange(result.Markdown, table.CloseTable()); result.AddBlankLine(); } if (ns.Types.Any(t => t.IsInterface)) { result.AddThenBlankLine(writer.WriteHeading2("Interfaces")); var table = new MarkdownTable("Interface", "Description"); foreach (var i in ns.Types.Where(t => t.IsInterface).OrderBy(t => t.TypeRef.FriendlyName)) { table.AddRow(writer.WriteLink(i.TypeRef.FriendlyName, i.FileName), i.Description); result.Files.Add(ProcessType(i)); } writer.AddRange(result.Markdown, table.CloseTable()); result.AddBlankLine(); } if (ns.Types.Any(t => t.IsEnum)) { result.AddThenBlankLine(writer.WriteHeading2("Enumerations")); var table = new MarkdownTable("Enumeration", "Description"); foreach (var i in ns.Types.Where(t => t.IsEnum).OrderBy(t => t.TypeRef.FriendlyName)) { table.AddRow(writer.WriteLink(i.TypeRef.FriendlyName.NameOnly(), i.FileName), i.Description); result.Files.Add(ProcessType(i)); } writer.AddRange(result.Markdown, table.CloseTable()); result.AddBlankLine(); } return(result); }
/// <summary> /// Sets up the documentation footer. /// </summary> private void SetupFooter(string version) { var copyrightInfo = GetType().Assembly .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false)[0] as AssemblyCopyrightAttribute; var copyright = copyrightInfo?.Copyright; var file = new DocFile("footer"); file.AddBlankLine(); file.AddDivider(); var table = new MarkdownTable("Generated", "Copyright", "Version"); table.SetAlignment(MarkdownColumnAlignment.Left, MarkdownColumnAlignment.Center, MarkdownColumnAlignment.Right); table.AddRow(DateTime.UtcNow.ToString(), copyright, version); foreach (var line in table.CloseTable()) { file.Add(line); } footer.AddRange(file.Markdown); }