Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        public Program()
        {
            //Test DotNet namespace
            string outputFolder = Path.Combine(GetMainDirectory(), "DataFiles");

            outputFolder = Path.Combine(outputFolder, "bin");
            outputFolder = Path.Combine(outputFolder, "Release");
            outputFolder = Path.Combine(outputFolder, Properties.Settings.Default.NetVersion);
            string xmlFilename = Path.Combine(outputFolder, "WithoutHaste.DataFiles.XML");
            string dllFilename = Path.Combine(outputFolder, "WithoutHaste.DataFiles.dll");
            DotNetDocumentationFile docFile = new DotNetDocumentationFile(xmlFilename);

            docFile.AddAssemblyInfo(dllFilename);
            Console.WriteLine("Found {0} types in assembly", docFile.Types.Count);

            //Test Markdown namespace
            MarkdownFile mdFile = new MarkdownFile();

            mdFile.AddSection("A Header");
            string mdText = mdFile.ToMarkdownString();

            Console.WriteLine("Some markdown: {0}", mdText);

            Console.WriteLine("Done");
            Console.ReadLine();
        }
Ejemplo n.º 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);
        }