private static void AppendFunction(DocNode node, StringBuilder sb) { sb.AppendLine($"# {node.Header}"); LinkTable(node, sb); sb.AppendLine(CreateDescription(node)); if (node.Doc is FunctionDocumentation funcDoc && funcDoc != null && funcDoc.Params?.Count > 0) { sb.AppendLine($"### Parameters"); foreach (var paramTuple in funcDoc.Params) { sb.Append($"* **{paramTuple.Item1}**"); if (string.IsNullOrEmpty(paramTuple.Item2)) { sb.AppendLine(); } else { sb.AppendLine($": {paramTuple.Item2}"); } } } }
private static List <string> CreateDescriptionParagraphs(DocNode node, int maxLength = 0) { List <string> description; if (node.Doc?.Description != null) { description = new List <string>(node.Doc.Description); } else { description = new List <string>(); } if (!string.IsNullOrEmpty(node.Appendix)) { description.Add(node.Appendix); } // Truncate if necessary if (maxLength > 0 && description.Count > 0) { // Keep the first line and trim it to maxLength return(new List <string> { description[0].Substring(0, Math.Min(description[0].Length, maxLength)) }); } return(description); }
private static void CreateContentsSections(DocNode node, OrderedContent[] orderedContents, StringBuilder sb) { foreach (var orderedContent in orderedContents) { var typeChildren = node.Children.Where(c => c.DocNodeType == orderedContent.Type).OrderBy(tc => tc.Name).ToList(); if (typeChildren.Count > 0) { // Tables need some space sb.AppendLine(); sb.AppendLine($"| {orderedContent.Title} | Description |"); sb.AppendLine("| - | - |"); foreach (var child in typeChildren) { sb.AppendLine($"| {CreateLink(child)} | {string.Join(NewLine, CreateDescriptionParagraphs(child, 40))} |"); } sb.AppendLine(); foreach (var child in typeChildren) { orderedContent.WriteDocNode(child, sb); } } } }
private static void AppendValue(DocNode node, StringBuilder sb) { sb.AppendLine($"# {node.Header}"); LinkTable(node, sb); sb.AppendLine(CreateDescription(node)); }
private static void LinkTable(DocNode node, StringBuilder sb) { // Tables need some space sb.AppendLine(); sb.AppendLine($"| Parent | Module | Workspace |"); sb.AppendLine("| - | - | - |"); sb.AppendLine($"| {CreateLink(node.Parent)} | {CreateLink(node.Module)} | {CreateLink(node.Module.DocWorkspace)} |"); }
private static void AppendProperty(DocNode node, StringBuilder sb) { string desc = CreateDescription(node, false); if (!string.IsNullOrEmpty(desc)) { sb.AppendLine($"## {node.Header}"); sb.AppendLine(desc); } }
private static void AddInterface(DocNode node, StringBuilder sb) { var orderedContent = s_getOrderedInterfaceContents; sb.AppendLine($"# {node.Header}"); LinkTable(node, sb); sb.AppendLine(CreateDescription(node)); CreateContentsSections(node, orderedContent, sb); }
private static string CreateDescription(DocNode node, bool header = true) { List <string> desc = CreateDescriptionParagraphs(node); if (desc.Count > 0) { return($"{(header ? "### Definition" + NewLine : string.Empty)}{string.Join(NewLine, desc)}"); } return(string.Empty); }
private static void CollectAllNamespaces(DocNode current, List <DocNode> nodes) { if (current.DocNodeType != DocNodeType.Namespace) { nodes.Add(current); } if (current.DocNodeType == DocNodeType.Namespace) { foreach (var child in current.Children.OrderBy(child => child.FullName)) { CollectAllNamespaces(child, nodes); } } }
private static string CreateLink(DocNode docNode) { if (docNode == null) { return(string.Empty); } string linkAnchor = null; if (docNode.DocNodeType != DocNodeType.Namespace) { linkAnchor = docNode.Anchor; } return(CreateLink(docNode.FullName, CreateFileName(docNode), docNode.Module, linkAnchor)); }
/// <nodoc /> public DocNode(DocNodeType docNodeType, DocNodeVisibility visibility, string name, List <string> trivia, Module module, AbsolutePath specPath, DocNode parent, string appendix) { Contract.Assert(!string.IsNullOrEmpty(name)); Contract.Assert(module != null); DocNodeType = docNodeType; Visibility = visibility; Name = name; NodeId = module.GetNextNodeId(); Module = module; SpecPath = specPath; Parent = parent; Doc = Documentation.Parse(trivia, docNodeType); Appendix = appendix; }
private static void AppendEnum(DocNode node, StringBuilder sb) { sb.AppendLine($"# {node.Header}"); LinkTable(node, sb); sb.AppendLine(CreateDescription(node)); sb.AppendLine("### Values"); foreach (var child in node.Children.OrderBy(n => n.Name)) { sb.AppendLine($"* {child.Name}"); var description = CreateDescription(child, false); if (!string.IsNullOrEmpty(description)) { sb.AppendLine($" * {description.Replace(NewLine, NewLine + " * ")}"); } } }
private static void CreateContentsRow(DocNode node, StringBuilder sb) { sb.AppendLine($"| {CreateDocNodeTypeImage(node.DocNodeType)} | {CreateLink(node)} | {string.Join(NewLine, CreateDescriptionParagraphs(node, 40))} |"); }
private static string CreateFileName(DocNode docNode) { return(CreateFileName(docNode.Module)); }