Пример #1
0
        private MarkdownFile GenerateTableOfContents(DotNetDocumentationFile xmlDocumentation, DotNetQualifiedClassNameTreeNode node)
        {
            List <DotNetType>     types      = xmlDocumentation.Types.Where(t => t.Name.FullNamespace == node.Value).ToList();
            List <DotNetDelegate> _delegates = xmlDocumentation.Delegates.Where(d => d.Name.FullNamespace == node.Value).ToList();

            MarkdownFile markdown = new MarkdownFile();
            string       header   = "Contents of " + node.Value.FullName;

            if (node.Parent != null)
            {
                header = String.Format("Contents of [{0}]({1}).{2}", node.Parent.Value.FullName, TableOfContentsFilename(node.Parent.Value), node.Value.LocalName);
            }

            MarkdownSection section = markdown.AddSection(header);

            if (node.Children.Count > 0)
            {
                MarkdownSection childNamespacesSection = section.AddSection("Namespaces");
                foreach (DotNetQualifiedClassNameTreeNode child in node.Children)
                {
                    section.AddInLine(new MarkdownInlineLink(MarkdownText.Bold(child.Value.FullName), TableOfContentsFilename(child.Value)));
                }
            }

            AddTableOfContentsSection(section, "Concrete Types", types.Where(t => t.Category == TypeCategory.Normal).ToList());
            AddTableOfContentsSection(section, "Static Types", types.Where(t => t.Category == TypeCategory.Static).ToList());
            AddTableOfContentsSection(section, "Abstract Types", types.Where(t => t.Category == TypeCategory.Abstract).ToList());
            AddTableOfContentsSection(section, "Interfaces", types.Where(t => t.Category == TypeCategory.Interface).ToList());
            AddTableOfContentsSection(section, "Enums", types.Where(t => t.Category == TypeCategory.Enum).ToList());
            AddTableOfContentsSection(section, "Structs", types.Where(t => t.Category == TypeCategory.Struct).ToList());
            AddTableOfContentsSection(section, "Delegates", _delegates);
            AddTableOfContentsSection(section, "Exceptions", types.Where(t => t.Category == TypeCategory.Exception).ToList());

            return(markdown);
        }
        public void MarkdownSection_ToMarkdown_TextThenSection()
        {
            //arrange
            MarkdownSection sectionA = new MarkdownSection("A");
            MarkdownText    text     = new MarkdownText("Text");

            sectionA.Add(text);
            MarkdownSection sectionB = sectionA.AddSection("B");
            //act
            string result = sectionA.ToMarkdownString();

            //assert
            Assert.AreEqual("# A\n\nText\n\n## B\n\n", result);
        }
Пример #3
0
        private void GenerateTableOfContents(DotNetDocumentationFile xmlDocumentation, string directory)
        {
            List <DotNetQualifiedClassName> _namespaces = new List <DotNetQualifiedClassName>();

            foreach (DotNetType type in xmlDocumentation.Types)
            {
                _namespaces.Add(type.ClassName.FullClassNamespace);
            }
            foreach (DotNetDelegate _delegate in xmlDocumentation.Delegates)
            {
                _namespaces.Add(_delegate.MethodName.FullClassNamespace);
            }
            _namespaces = _namespaces.Distinct().ToList();
            DotNetQualifiedClassNameTreeNode root = DotNetQualifiedClassNameTreeNode.Generate(_namespaces);

            GenerateAndSaveTableOfContents(xmlDocumentation, root, directory);

            //master table of contents
            MarkdownFile    markdown = new MarkdownFile();
            MarkdownSection section  = markdown.AddSection("Table of Contents");

            if (root.Value == null)
            {
                foreach (DotNetQualifiedClassNameTreeNode node in root.Children)
                {
                    MarkdownSection subsection = BuildMasterSummary(xmlDocumentation, node);
                    section.AddSection(subsection);
                }
            }
            else
            {
                MarkdownSection subsection = BuildMasterSummary(xmlDocumentation, root);
                section.AddSection(subsection);
            }
            Save(markdown, directory, "TableOfContents" + Ext.MD);
        }
Пример #4
0
        private void AddTableOfContentsSection(MarkdownSection parent, string header, List <DotNetDelegate> _delegates)
        {
            if (_delegates.Count == 0)
            {
                return;
            }

            MarkdownSection section = parent.AddSection(header);

            foreach (DotNetDelegate _delegate in _delegates.OrderBy(t => t.Name.LocalName))
            {
                section.AddInLine(new MarkdownInlineLink(MarkdownText.Bold(_delegate.Name.LocalName), FormatFilename(_delegate.Name.FullName + Ext.MD)));
                section.Add(ConvertDotNet.DotNetCommentGroupToMarkdown(_delegate.SummaryComments, _delegate));
                section.Add(new MarkdownLine());
            }
        }
Пример #5
0
        private MarkdownSection BuildMasterSummary(DotNetDocumentationFile xmlDocumentation, DotNetQualifiedClassNameTreeNode node)
        {
            string            header  = (new MarkdownInlineLink(node.Value, TableOfContentsFilename(node.Value))).ToMarkdownString(null);
            MarkdownSection   section = new MarkdownSection(header);
            List <DotNetType> types   = xmlDocumentation.Types.Where(t => t.Name.FullNamespace == node.Value).ToList();

            foreach (DotNetType type in types.OrderBy(t => t.Name))
            {
                section.Add(new MarkdownLine(new MarkdownInlineLink(type.Name, FormatFilename(type.Name + Ext.MD))));
            }
            List <DotNetDelegate> _delegates = xmlDocumentation.Delegates.Where(d => d.Name.FullNamespace == node.Value).ToList();

            foreach (DotNetDelegate _delegate in _delegates.OrderBy(d => d.Name))
            {
                section.Add(new MarkdownLine(new MarkdownInlineLink(_delegate.Name, FormatFilename(_delegate.Name + Ext.MD))));
            }
            foreach (DotNetQualifiedClassNameTreeNode child in node.Children.OrderBy(c => c.Value))
            {
                section.AddSection(BuildMasterSummary(xmlDocumentation, child));
            }
            return(section);
        }