diff --git a/.gitignore b/.gitignore index 4b207ab4c9..5703759fe8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +src/cookbook/output nuget.exe ## Ignore Visual Studio temporary files, build results, and diff --git a/src/tests/Cookbook/Generate.cs b/src/tests/Cookbook/Generate.cs index 3adc424484..41c962dcb0 100644 --- a/src/tests/Cookbook/Generate.cs +++ b/src/tests/Cookbook/Generate.cs @@ -1,106 +1,32 @@ using NUnit.Framework; using ScottPlot.Cookbook; -using ScottPlot.Cookbook.Website; -using ScottPlot.Cookbook.Website.Pages; -using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace ScottPlotTests.Cookbook { class Generate { - /// - /// Source folder containing the original .cs files that will be parsed to get recipe source code - /// - const string SourceFolder = "../../../../cookbook/ScottPlot.Cookbook"; - - /// - /// The folder that will store isolated code example text files - /// - const string RecipeFolder = "./cookbook/source"; - - /// - /// The folder to put the website into - /// - const string WebsitePath = "./website"; + const string COOKBOOK_PROJECT_FOLDER = "../../../../cookbook/ScottPlot.Cookbook"; + const string COOKBOOK_OUTPUT_FOLDER = "../../../../cookbook/output"; [OneTimeSetUp] - public void Setup() - { - CreateFolder(RecipeFolder); - CreateFolder(WebsitePath); - } - - private static void CreateFolder(string path) - { - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - } - - [Test] - public void Test_Cookbook_ImagesAndCode() - { - Chef.CreateCookbookImages(Path.Join(WebsitePath, "images")); - Chef.CreateCookbookSource(SourceFolder, RecipeFolder); - } - - [Test] - public void Test_Webpage_CookbookCategoryPages() - { - string cookbookFolder = Path.Combine(WebsitePath, "category"); - CreateFolder(cookbookFolder); - foreach (var categoryName in Locate.GetCategories()) - { - var page = new CookbookCategoryPage(categoryName); - - string categoryFolder = Path.Combine(cookbookFolder, Page.Sanitize(categoryName)); - CreateFolder(categoryFolder); - string mdFilePath = Path.Combine(categoryFolder, "index.md"); - page.SaveMarkdown(mdFilePath); - Console.WriteLine(Path.GetFullPath(mdFilePath)); - } - } - - [Test] - public void Test_Webpage_CookIndexPage() + public void OneTimeSetup() { - var page = new CookbookHomePage(); - string mdPath = Path.Combine(WebsitePath, "index.md"); - page.SaveMarkdown(mdPath); - Console.WriteLine(Path.GetFullPath(mdPath)); + if (Directory.Exists(COOKBOOK_OUTPUT_FOLDER)) + Directory.Delete(COOKBOOK_OUTPUT_FOLDER, recursive: true); + Directory.CreateDirectory(COOKBOOK_OUTPUT_FOLDER); } [Test] - public void Test_Webpage_PlotApi() + public void Test_Generate_RecipeImages() { - var page = new PlotApiPage(); - string mdFilePath = Path.Combine(WebsitePath, "api/plot/index.md"); - CreateFolder(Path.GetDirectoryName(mdFilePath)); - page.SaveMarkdown(mdFilePath); - Console.WriteLine(); - Console.WriteLine(Path.GetFullPath(mdFilePath)); + Chef.CreateCookbookImages(Path.Join(COOKBOOK_OUTPUT_FOLDER, "images")); } [Test] - public void Test_Webpage_ForEveryPlottable() + public void Test_Generate_RecipeSourceJson() { - string plottableFolder = WebsitePath + "/api/plottable"; - CreateFolder(plottableFolder); - foreach (var plottableType in Locate.GetPlottableTypes()) - { - var page = new PlottableApiPage(plottableType); - string thisPlottableFolder = plottableFolder + "/" + Page.Sanitize(plottableType.Name); - CreateFolder(thisPlottableFolder); - string mdPath = thisPlottableFolder + "/index.md"; - //CreateFolder(thisPlottableFolder); - page.SaveMarkdown(mdPath); - Console.WriteLine(Path.GetFullPath(mdPath)); - } + Chef.CreateRecipesJson(COOKBOOK_PROJECT_FOLDER, Path.Join(COOKBOOK_OUTPUT_FOLDER, "recipes.json")); } } }