From 4e4cdebe0e76d1fdacb15a2d4eaa8daaed51951c Mon Sep 17 00:00:00 2001 From: davidanthoff <1036561+davidanthoff@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:56:03 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 74 ++--- src/VegaLite.jl | 2 +- .../dsl_vlplot_function.jl | 14 +- src/dsl_vlplot_function/shorthandparser.jl | 10 +- src/dsl_vlplot_macro/dsl_vlplot_macro.jl | 2 +- src/rendering/fileio.jl | 2 +- src/rendering/io.jl | 4 +- src/rendering/render.jl | 265 +++++++++--------- src/rendering/show.jl | 10 +- src/vlspec.jl | 20 +- test/test_base.jl | 8 +- test/test_inlinedata.jl | 8 +- test/test_io.jl | 11 +- test/test_macro.jl | 28 +- test/test_positional.jl | 10 +- test/test_show.jl | 4 +- test/test_spec.jl | 12 +- test/test_vg.jl | 2 +- test/test_vlplot_macro.jl | 22 +- 19 files changed, 259 insertions(+), 249 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 9d1d3c78..fef84fe0 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -3,52 +3,52 @@ using Documenter, VegaLite, UUIDs function Base.show(io::IO, m::MIME"text/html", v::VegaLite.VLSpec) divid = string("vl", replace(string(uuid4()), "-" => "")) print(io, "
") - print(io, "") end makedocs( - modules=[VegaLite], - sitename="VegaLite.jl", - pages=[ - "Home" => "index.md", - "Getting Started" => Any[ - "Installation" => "gettingstarted/installation.md", - "Tutorial" => "gettingstarted/tutorial.md" - ], - "User Guide" => Any[ - "Vega-lite specifications" => "userguide/vlspec.md", - "The @vlplot command" => "userguide/vlplotmacro.md", - "Data sources" => "userguide/data.md" - ], - "Examples" => Any[ - "Single-View Plots" => Any[ - "Bar Charts" => "examples/examples_barcharts.md", - "Histograms, Density Plots, and Dot Plots" => "examples/examples_histograms.md", - "Scatter & Strip Plots" => "examples/examples_scatter_strip_plots.md", - "Line Charts" => "examples/examples_line_charts.md", - "Area Charts & Streamgraphs" => "examples/examples_area_Charts_streamgraphs.md", - "Table-based Plots" => "examples/examples_table_based_plots.md", - "Circular Plots" => "examples/examples_circular_plots.md", - "Advanced Calculations" => "examples/examples_advancedcalculations.md" + modules=[VegaLite], + sitename="VegaLite.jl", + pages=[ + "Home" => "index.md", + "Getting Started" => Any[ + "Installation"=>"gettingstarted/installation.md", + "Tutorial"=>"gettingstarted/tutorial.md" ], - "Composite Mark" => Any[ - "Error Bars & Error Bands" => "examples/examples_error_bars_bands.md", - "Box Plots" => "examples/examples_box_plots.md" + "User Guide" => Any[ + "Vega-lite specifications"=>"userguide/vlspec.md", + "The @vlplot command"=>"userguide/vlplotmacro.md", + "Data sources"=>"userguide/data.md" ], - "Multi-View Displays" => Any[ - "Faceting (Trellis Plot / Small Multiples)" => "examples/examples_faceting.md", - "Repeat & Concatenation" => "examples/examples_repeat_concatenation.md" + "Examples" => Any[ + "Single-View Plots"=>Any[ + "Bar Charts"=>"examples/examples_barcharts.md", + "Histograms, Density Plots, and Dot Plots"=>"examples/examples_histograms.md", + "Scatter & Strip Plots"=>"examples/examples_scatter_strip_plots.md", + "Line Charts"=>"examples/examples_line_charts.md", + "Area Charts & Streamgraphs"=>"examples/examples_area_Charts_streamgraphs.md", + "Table-based Plots"=>"examples/examples_table_based_plots.md", + "Circular Plots"=>"examples/examples_circular_plots.md", + "Advanced Calculations"=>"examples/examples_advancedcalculations.md" + ], + "Composite Mark"=>Any[ + "Error Bars & Error Bands"=>"examples/examples_error_bars_bands.md", + "Box Plots"=>"examples/examples_box_plots.md" + ], + "Multi-View Displays"=>Any[ + "Faceting (Trellis Plot / Small Multiples)"=>"examples/examples_faceting.md", + "Repeat & Concatenation"=>"examples/examples_repeat_concatenation.md" + ], + "Maps (Geographic Displays)"=>"examples/examples_maps.md" ], - "Maps (Geographic Displays)" => "examples/examples_maps.md" - ], - "Reference Manual" => [ - "Global settings" => "referencemanual/global.md", - "Outputs" => "referencemanual/output.md", - "Performance tips" => "referencemanual/performance.md", + "Reference Manual" => [ + "Global settings" => "referencemanual/global.md", + "Outputs" => "referencemanual/output.md", + "Performance tips" => "referencemanual/performance.md", ] - ] + ] ) deploydocs( diff --git a/src/VegaLite.jl b/src/VegaLite.jl index 1e572b08..76052bbe 100644 --- a/src/VegaLite.jl +++ b/src/VegaLite.jl @@ -32,7 +32,7 @@ export deletedata, deletedata! vegalite_app_path(args...) = joinpath(artifact"vegalite_app", args...) const vegaliate_app_includes_canvas = Ref{Bool}() -const vlschema = Ref{Dict{String, Any}}() +const vlschema = Ref{Dict{String,Any}}() function __init__() vegaliate_app_includes_canvas[] = ispath(vegalite_app_path("node_modules", "canvas")) diff --git a/src/dsl_vlplot_function/dsl_vlplot_function.jl b/src/dsl_vlplot_function/dsl_vlplot_function.jl index 71758d89..29d592cf 100644 --- a/src/dsl_vlplot_function/dsl_vlplot_function.jl +++ b/src/dsl_vlplot_function/dsl_vlplot_function.jl @@ -96,7 +96,7 @@ function fix_shortcut_level_data(spec_frag) if TableTraits.isiterabletable(spec_frag) it = IteratorInterfaceExtensions.getiterator(spec_frag) return VLFrag([], OrderedDict{String,Any}("values" => Vega.DataValuesNode(it))) -else + else return spec_frag end end @@ -105,7 +105,7 @@ function fix_shortcut_level_spec(spec_frag::VLFrag) spec = copy(spec_frag.named) if length(spec_frag.positional) > 0 - spec["mark"] = spec_frag.positional[1] + spec["mark"] = spec_frag.positional[1] elseif length(spec_frag.positional) > 3 error("More than three positional element specified at the spec level.") end @@ -119,7 +119,7 @@ function fix_shortcut_level_spec(spec_frag::VLFrag) encodings_to_be_moved = filter( i -> i != "facet", collect(keys(vlschema[]["definitions"]["FacetedEncoding"]["properties"])), - ) + ) for k in collect(keys(spec)) if string(k) in encodings_to_be_moved if !haskey(spec, "encoding") @@ -163,7 +163,7 @@ function fix_shortcut_level_spec(spec_frag::VLFrag) inline_unnamed_data = Pair{Symbol,AbstractVector}[] if haskey(spec, "encoding") - if spec["encoding"] isa VLFrag + if spec["encoding"] isa VLFrag if !isempty(spec["encoding"].positional) error("Can't have positional arguments inside the encoding element.") else @@ -226,12 +226,12 @@ function convert_frag_tree_to_dict(spec::VLFrag) return "type" => p[2] else return p -end + end end return spec_as_dict2 end -function vlplot(args...;kwargs...) - return VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vlfrag(args...;kwargs...)))) +function vlplot(args...; kwargs...) + return VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vlfrag(args...; kwargs...)))) end diff --git a/src/dsl_vlplot_function/shorthandparser.jl b/src/dsl_vlplot_function/shorthandparser.jl index e3ad4ed4..96e6060a 100644 --- a/src/dsl_vlplot_function/shorthandparser.jl +++ b/src/dsl_vlplot_function/shorthandparser.jl @@ -69,18 +69,18 @@ function parse_shortcut(s::AbstractString) if length(tokens) > 2 && tokens[3] == ")" if length(tokens) == 3 decoded_func = decode_func(tokens[1]) - return [decoded_func,"type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] + return [decoded_func, "type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] elseif length(tokens) == 5 && tokens[4] == ":" - return [decode_func(tokens[1]),decode_typ(tokens[5])] + return [decode_func(tokens[1]), decode_typ(tokens[5])] else throw(ArgumentError("invalid shortcut string")) end elseif length(tokens) > 3 && tokens[4] == ")" if length(tokens) == 4 decoded_func = decode_func(tokens[1]) - return [decoded_func,"field" => tokens[3],"type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] + return [decoded_func, "field" => tokens[3], "type" => decoded_func[1] == "timeUnit" ? "temporal" : "quantitative"] elseif length(tokens) == 6 && tokens[5] == ":" - return [decode_func(tokens[1]),"field" => tokens[3],decode_typ(tokens[6])] + return [decode_func(tokens[1]), "field" => tokens[3], decode_typ(tokens[6])] else throw(ArgumentError("invalid shortcut string")) end @@ -88,7 +88,7 @@ function parse_shortcut(s::AbstractString) throw(ArgumentError("Invalid shortcut string")) end elseif length(tokens) == 3 && tokens[2] == ":" - return ["field" => tokens[1],decode_typ(tokens[3])] + return ["field" => tokens[1], decode_typ(tokens[3])] else throw(ArgumentError("Invalid shortcut string")) end diff --git a/src/dsl_vlplot_macro/dsl_vlplot_macro.jl b/src/dsl_vlplot_macro/dsl_vlplot_macro.jl index c49880e7..e28791de 100644 --- a/src/dsl_vlplot_macro/dsl_vlplot_macro.jl +++ b/src/dsl_vlplot_macro/dsl_vlplot_macro.jl @@ -1,7 +1,7 @@ macro vlplot(ex...) new_ex = Vega.convert_curly_style(ex, VLFrag) - return :( VegaLite.VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex))) ) + return :(VegaLite.VLSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex)))) end macro vlfrag(ex...) diff --git a/src/rendering/fileio.jl b/src/rendering/fileio.jl index 62251391..806d9fcf 100644 --- a/src/rendering/fileio.jl +++ b/src/rendering/fileio.jl @@ -26,4 +26,4 @@ function fileio_save(stream::FileIO.Stream{FileIO.format"vega"}, data::VLSpec; i parsed = JSON.parse(s) vgspec = Vega.VGSpec(parsed) Vega.savespec(stream.io, vgspec; include_data=include_data, kwargs...) -end \ No newline at end of file +end diff --git a/src/rendering/io.jl b/src/rendering/io.jl index fe30edec..b961bcde 100644 --- a/src/rendering/io.jl +++ b/src/rendering/io.jl @@ -20,8 +20,8 @@ function savefig(filename::AbstractString, v::VLSpec) mime = "image/png" elseif file_ext == ".eps" mime = "application/eps" - # elseif file_ext == ".ps" - # mime = "application/postscript" + # elseif file_ext == ".ps" + # mime = "application/postscript" else throw(ArgumentError("Unknown file type.")) end diff --git a/src/rendering/render.jl b/src/rendering/render.jl index d7fec5de..ebdafa31 100644 --- a/src/rendering/render.jl +++ b/src/rendering/render.jl @@ -7,14 +7,14 @@ using JSON asset(url...) = normpath(vegalite_app_path("minified", url...)) -const package_json = Ref{Dict{String, Any}}() +const package_json = Ref{Dict{String,Any}}() function version(package) - if !isassigned(package_json) - package_json[] = JSON.parsefile(vegalite_app_path("package.json")) - end - - return package_json[]["dependencies"][package] + if !isassigned(package_json) + package_json[] = JSON.parsefile(vegalite_app_path("package.json")) + end + + return package_json[]["dependencies"][package] end # Vega Scaffold: https://github.com/vega/vega/wiki/Runtime @@ -27,48 +27,51 @@ function writehtml_full(io::IO, spec::VLSpec; title="VegaLite plot") divid = "vg" * randstring(3) print(io, - """ - - -