Exemplo n.º 1
0
        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}");
                    }
                }
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
                    }
                }
            }
        }
Exemplo n.º 4
0
        private static void AppendValue(DocNode node, StringBuilder sb)
        {
            sb.AppendLine($"# {node.Header}");

            LinkTable(node, sb);

            sb.AppendLine(CreateDescription(node));
        }
Exemplo n.º 5
0
        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)} |");
        }
Exemplo n.º 6
0
        private static void AppendProperty(DocNode node, StringBuilder sb)
        {
            string desc = CreateDescription(node, false);

            if (!string.IsNullOrEmpty(desc))
            {
                sb.AppendLine($"## {node.Header}");
                sb.AppendLine(desc);
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
                }
            }
        }
Exemplo n.º 10
0
        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));
        }
Exemplo n.º 11
0
        /// <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;
        }
Exemplo n.º 12
0
        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 + "  * ")}");
                }
            }
        }
Exemplo n.º 13
0
 private static void CreateContentsRow(DocNode node, StringBuilder sb)
 {
     sb.AppendLine($"| {CreateDocNodeTypeImage(node.DocNodeType)} | {CreateLink(node)} | {string.Join(NewLine, CreateDescriptionParagraphs(node, 40))} |");
 }
Exemplo n.º 14
0
 private static string CreateFileName(DocNode docNode)
 {
     return(CreateFileName(docNode.Module));
 }