Exemplo n.º 1
0
        public void Generate(string applicationPath, IEnumerable <DocumentationCategory> categories, string outputFolder)
        {
            if (!string.IsNullOrEmpty(CodePath))
            {
                var root  = Path.Combine(applicationPath, CodePath);
                var files = Directory.EnumerateFiles(root, "*.cs", SearchOption.AllDirectories);
                var file  = new StringBuilder();

                var roots = categories.Where(category => category.IncludeInTableOfContents).Select(category => new Category
                {
                    Name          = category.Name,
                    NiceName      = DocumentationGenerator.GetNiceName(category.Name),
                    Id            = DocumentationGenerator.GetId(category.Name),
                    Documentation = category,
                    Sections      = Sections
                                    .Select(sectionName => new Section
                    {
                        Name     = sectionName,
                        NiceName = DocumentationGenerator.GetNiceName(sectionName),
                        Id       = DocumentationGenerator.GetId(sectionName),
                        Types    = GetTypes(category, sectionName, files)
                    })
                                    .ToList()
                });

                foreach (var category in roots)
                {
                    var contents = GenerateCategory(category);
                    file.Append(contents);
                }

                var tableOfContents = Templates.File.Replace(_categoriesTag, file.ToString());
                DocumentationGenerator.WriteFile(outputFolder, OutputFile, tableOfContents);
            }
        }
        /// <summary>
        /// Get list of all the sections
        /// </summary>
        /// <param name="pDoc"></param>
        /// <returns></returns>
        private List <Section> GetListOfSections(PresentationDocument pDoc)
        {
            var sections = new List <Section>();

            if (pDoc.PresentationPart == null)
            {
                return(sections);
            }

            SectionList sectionList = pDoc.PresentationPart.Presentation.PresentationExtensionList.Descendants <SectionList>().FirstOrDefault();

            if (sectionList == null)
            {
                return(sections);
            }

            sections.AddRange(sectionList.Select(section => section as Section));

            return(sections);
        }