diff --git a/RecipesPipeline/Project.toml b/RecipesPipeline/Project.toml index 66c01e158..918c2877a 100644 --- a/RecipesPipeline/Project.toml +++ b/RecipesPipeline/Project.toml @@ -1,4 +1,4 @@ -name = "RecipeUtils" +name = "RecipePipeline" uuid = "01d81517-befc-4cb6-b9ec-a95719d0359c" authors = ["Michael Krabbe Borregaard "] version = "0.1.0" diff --git a/RecipesPipeline/src/RecipeUtils.jl b/RecipesPipeline/src/RecipePipeline.jl similarity index 58% rename from RecipesPipeline/src/RecipeUtils.jl rename to RecipesPipeline/src/RecipePipeline.jl index ac4d91248..ceda55c57 100644 --- a/RecipesPipeline/src/RecipeUtils.jl +++ b/RecipesPipeline/src/RecipePipeline.jl @@ -1,6 +1,7 @@ -module RecipeUtils +module RecipePipeline import RecipesBase +include("pipeline.jl") include("process_recipes.jl") end # module diff --git a/RecipesPipeline/src/pipeline.jl b/RecipesPipeline/src/pipeline.jl index 0aae274c8..c89e08542 100644 --- a/RecipesPipeline/src/pipeline.jl +++ b/RecipesPipeline/src/pipeline.jl @@ -1,25 +1,56 @@ ## Stubs function _recipe_init!(plt, plotattributes, args) end function _recipe_after_user!(plt, plotattributes, args) end -function _recipe_after_plot!(plt, plotattributes, args) end -function _recipe_after_series!(plt, plotattributes, args, series_ind) end +function _recipe_after_plot!(plt, plotattributes, kw_list) end +function _recipe_before_series!(plt, kw, kw_list) end function _recipe_finish!(plt, plotattributes, args) end + ## # Here comes the specification of when which recipe is processed. # It contains functions before and after every stage for interaction with the plotting package. -function recipe_pipeline!(plt, # frontend specific representation of a plot - plotattributes, # current state of recipe keywords - args, # set of arguments passed by the user - ) - _recipe_init!(plt, plotattributes, args) - kw_list = _process_userrecipes(plt, plotattributes, args) - _recipe_after_user!(plt, plotattributes, args) - kw_list = _process_plotrecipes(plt, plotattributes, args) - _recipe_after_plot!(plt, plotattributes, args) - for (series_ind, series) in enumerate(series_list) - kw_list = _process_seriesrecipe(plt, plotattributes) - _recipe_after_series!(plt, plotattributes, series_ind) - end - _recipe_finish!((plt, plotattributes, args) +function recipe_pipeline!(plt, # frontend specific representation of a plot + plotattributes, # current state of recipe keywords + args; # set of arguments passed by the user + type_aliases) + + _recipe_init!(plt, plotattributes, args) + + # -------------------------------- + # "USER RECIPES" + # -------------------------------- + + kw_list = _process_userrecipes(plt, plotattributes, args) + _recipe_after_user!(plt, plotattributes, args) + + # -------------------------------- + # "PLOT RECIPES" + # -------------------------------- + + # "plot recipe", which acts like a series type, and is processed before + # the plot layout is created, which allows for setting layouts and other plot-wide attributes. + # we get inputs which have been fully processed by "user recipes" and "type recipes", + # so we can expect standard vectors, surfaces, etc. No defaults have been set yet. + still_to_process = kw_list + kw_list = Dict{Symbol,Any}[] + while !isempty(still_to_process) + next_kw = popfirst!(still_to_process) + _process_plotrecipe(plt, next_kw, kw_list, still_to_process; type_aliases=type_aliases) + end + + _recipe_after_plot!(plt, plotattributes, kw_list) + + # !!! note: At this point, kw_list is fully decomposed into individual series... one KW per series. !!! + # !!! The next step is to recursively apply series recipes until the backend supports that series type !!! + + # -------------------------------- + # "SERIES RECIPES" + # -------------------------------- + + for kw in kw_list + series_attr = _recipe_before_series!(plt, kw, kw_list) + kw_list = _process_seriesrecipe(plt, series_attr) + end + + _recipe_finish!(plt, plotattributes, args) end diff --git a/RecipesPipeline/src/process_recipes.jl b/RecipesPipeline/src/process_recipes.jl index 59f4db947..9d51ebb9e 100644 --- a/RecipesPipeline/src/process_recipes.jl +++ b/RecipesPipeline/src/process_recipes.jl @@ -1,5 +1,6 @@ _preprocess_args(p, args, s) = args #needs to modify still_to_process +_process_userrecipe(plt, kw_list, next_series) = nothing preprocessArgs!(p) = p is_st_supported(st) = true finalize_subplot!(plt, att) = nothing @@ -72,7 +73,7 @@ end # this method recursively applies series recipes when the seriestype is not supported # natively by the backend -function _process_seriesrecipe(plt, plotattributes::AbstractDict{Symbol,Any}; _typeAliases::AbstractDict{Symbol,Symbol}=Dict()) +function _process_seriesrecipe(plt, plotattributes::AbstractDict{Symbol,Any}; type_aliases::AbstractDict{Symbol,Symbol}) #println("process $(typeof(plotattributes))") # replace seriestype aliases st = Symbol(plotattributes[:seriestype]) diff --git a/RecipesPipeline/test/runtests.jl b/RecipesPipeline/test/runtests.jl index d62153096..bee6d15f9 100644 --- a/RecipesPipeline/test/runtests.jl +++ b/RecipesPipeline/test/runtests.jl @@ -1,6 +1,6 @@ -using RecipeUtils +using RecipePipeline using Test -@testset "RecipeUtils.jl" begin +@testset "RecipePipeline.jl" begin # Write your own tests here. end