Esempio n. 1
0
        private DocumentationDocumentType BuildDocumentationSubTree(DirectoryInfo directoryInfo, DirectoryInfo topDirectoryInfo, IDocumentationProject project)
        {
            DocumentationDocumentType subTreeDocumentType = DocumentationDocumentType.Folder;

            project.Path = directoryInfo.FullName;

            foreach (var file in directoryInfo.EnumerateFiles())
            {
                var docType = DocumentationHelper.GetDocumentationDocumentTypeFromName(file.Name);

                switch (docType)
                {
                case DocumentationDocumentType.Markdown:
                    if (!_Options.Documents?.Markdown?.Enabled ?? false)
                    {
                        break;
                    }
                    // The markdown pipeline isn't needed for the content extraction.
                    project.Documents.Add(new MarkdownDocument(null)
                    {
                        Path       = file.FullName,
                        LastUpdate = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Word:
                    if (!_Options.Documents?.Word?.Enabled ?? false)
                    {
                        break;
                    }
                    project.Documents.Add(new WordDocument
                    {
                        Path       = file.FullName,
                        LastUpdate = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Pdf:
                    if (!_Options.Documents?.Pdf?.Enabled ?? false)
                    {
                        break;
                    }
                    project.Documents.Add(new DocumentationDocument
                    {
                        Path         = file.FullName,
                        DocumentType = docType,
                        LastUpdate   = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Html:
                    if (!_Options.Documents?.Html?.Enabled ?? false)
                    {
                        break;
                    }
                    project.Documents.Add(new DocumentationDocument
                    {
                        Path         = file.FullName,
                        DocumentType = docType,
                        LastUpdate   = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Drawio:
                    if (!_Options.Documents?.Drawio?.Enabled ?? false)
                    {
                        break;
                    }
                    project.Documents.Add(new DocumentationDocument
                    {
                        Path         = file.FullName,
                        DocumentType = docType,
                        LastUpdate   = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.DrawioSvg:
                    if (!_Options.Documents?.DrawioSvg?.Enabled ?? false)
                    {
                        break;
                    }
                    project.Documents.Add(new DocumentationDocument
                    {
                        Path         = file.FullName,
                        DocumentType = docType,
                        LastUpdate   = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Folder:
                    project.Documents.Add(new DocumentationDocument
                    {
                        Path         = file.FullName,
                        DocumentType = docType,
                        LastUpdate   = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Project:
                    subTreeDocumentType = DocumentationDocumentType.Project;
                    break;

                case DocumentationDocumentType.Unknown:
                    break;

                default:
                    break;
                }
            }

            foreach (var directory in directoryInfo.EnumerateDirectories())
            {
                IDocumentationProject subProject = new DocumentationProject(_Options.DefaultDocuments, _Options.LandingPageDocument, project.KeyPath);
                var subDocumentType = BuildDocumentationSubTree(directory, topDirectoryInfo, subProject);

                if (subDocumentType == DocumentationDocumentType.Project)
                {
                    project.SubProjects.Add(subProject);
                }
                else
                {
                    var documentationDirectory = new DocumentationDocument
                    {
                        DocumentType = subDocumentType,
                        Path         = directory.FullName,
                        LastUpdate   = directory.LastWriteTimeUtc
                    };

                    if (subProject.Documents.Any())
                    {
                        documentationDirectory.SubDocuments = subProject.Documents.OrderBy(o => o.Name).ToArray();
                        project.Documents.Add(documentationDirectory);
                    }
                }
            }

            return(subTreeDocumentType);
        }
Esempio n. 2
0
        private DocumentationDocumentType BuildDocumentationSubTree(DirectoryInfo directoryInfo, DirectoryInfo topDirectoryInfo, IDocumentationProject project)
        {
            DocumentationDocumentType subTreeDocumentType = DocumentationDocumentType.Folder;

            project.Path = directoryInfo.FullName;

            foreach (var file in directoryInfo.EnumerateFiles())
            {
                var docType = DocumentationHelper.GetDocumentationDocumentTypeFromExtension(Path.GetExtension(file.FullName));

                switch (docType)
                {
                case DocumentationDocumentType.Markdown:
                    project.Documents.Add(new MarkdownDocument(_MarkdownPipeline)
                    {
                        Path       = file.FullName,
                        LastUpdate = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Pdf:
                    project.Documents.Add(new PdfDocument
                    {
                        Path       = file.FullName,
                        LastUpdate = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Html:
                    project.Documents.Add(new HtmlDocument
                    {
                        Path       = file.FullName,
                        LastUpdate = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Word:
                case DocumentationDocumentType.Folder:
                    project.Documents.Add(new GenericDocumentationDocument
                    {
                        Path         = file.FullName,
                        DocumentType = docType,
                        LastUpdate   = file.LastWriteTimeUtc
                    });
                    break;

                case DocumentationDocumentType.Project:
                    subTreeDocumentType = DocumentationDocumentType.Project;
                    break;

                case DocumentationDocumentType.Unknown:
                    break;

                default:
                    break;
                }
            }

            foreach (var directory in directoryInfo.EnumerateDirectories())
            {
                IDocumentationProject subProject = new DocumentationProject(_Options, project.KeyPath);
                var subDocumentType = BuildDocumentationSubTree(directory, topDirectoryInfo, subProject);

                if (subDocumentType == DocumentationDocumentType.Project)
                {
                    project.SubProjects.Add(subProject);
                }
                else
                {
                    var documentationDirectory = new GenericDocumentationDocument
                    {
                        DocumentType = subDocumentType,
                        Path         = directory.FullName,
                        LastUpdate   = directory.LastWriteTimeUtc
                    };

                    if (subProject.Documents.Any())
                    {
                        documentationDirectory.SubDocuments = subProject.Documents.OrderBy(o => o.Name).ToArray();
                        project.Documents.Add(documentationDirectory);
                    }
                }
            }

            return(subTreeDocumentType);
        }