コード例 #1
0
        public void Generate(string mdDirectoryPath, string newDirectoryPath = null, string attachementsPath = null)
        {
            SourceTree = FileTree.GetTree(mdDirectoryPath, ".*\\.md|\\.order", new string[] { ".git", ".attachments" });
            string newDir = newDirectoryPath ?? $"{SourceTree.Path}_html";

            Console.WriteLine($"Generating html wiki from {mdDirectoryPath} into {newDir}");

            Crawl(SourceTree, newDir);

            Console.WriteLine($"Generating navigation and index page");
            string homeHtml = File.Exists($"{newDir}\\Home.html") ? File.ReadAllText($"{newDir}\\Home.html") : File.ReadAllText(Directory.GetFiles(newDir).FirstOrDefault(f => !f.StartsWith("index")));

            File.WriteAllText($"{newDir}\\index.html", new Index(GenerateNavigation(SourceTree, newDir).ToString(), "Wiki", homeHtml).Html);

            var attachmementsSource = attachementsPath ?? $"{mdDirectoryPath}\\.attachments";
            var attachmementsTarget = $"{newDir}\\.attachments";

            CopyFilesRecursively(new DirectoryInfo(attachmementsSource), new DirectoryInfo(attachmementsTarget));
        }