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); }