From e710eeec7bad9e6acb49487b08b0ae46a1b385cb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 10 Mar 2021 18:18:05 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 8 ++--- src/Vega.jl | 6 ++-- .../dsl_vlplot_function.jl | 16 ++++----- src/dsl_vlplot_macro/dsl_vlplot_macro.jl | 10 +++--- src/rendering/io.jl | 4 +-- src/rendering/render.jl | 34 +++++++++---------- src/rendering/show.jl | 4 +-- src/spec_utils.jl | 10 +++--- src/vgspec.jl | 2 +- test/test_io.jl | 18 +++++----- test/test_macro.jl | 2 +- 11 files changed, 57 insertions(+), 57 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index cf82b28..510496b 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,7 +1,7 @@ using Documenter, Vega, UUIDs function Base.show(io::IO, m::MIME"text/html", v::Vega.VGSpec) - divid = string("vg", replace(string(uuid4()), "-"=>"")) + divid = string("vg", replace(string(uuid4()), "-" => "")) print(io, "
") print(io, " @@ -56,29 +56,29 @@ function writehtml_full(io::IO, spec::VGSpec; title="Vega plot") end function writehtml_full(spec::VGSpec; title="Vega plot") - tmppath = string(tempname(), ".vega.html") + tmppath = string(tempname(), ".vega.html") - open(tmppath, "w") do io - writehtml_full(io, spec, title=title) - end + open(tmppath, "w") do io + writehtml_full(io, spec, title=title) + end - tmppath + tmppath end """ opens a browser tab with the given html file """ function launch_browser(tmppath::String) - if Sys.isapple() - run(`open $tmppath`) - elseif Sys.iswindows() + if Sys.isapple() + run(`open $tmppath`) + elseif Sys.iswindows() run(`cmd /c start $tmppath`) elseif Sys.islinux() run(`xdg-open $tmppath`) - end + end end function Base.display(d::REPL.REPLDisplay, plt::VGSpec) - tmppath = writehtml_full(plt) - launch_browser(tmppath) # Open the browser + tmppath = writehtml_full(plt) + launch_browser(tmppath) # Open the browser end diff --git a/src/rendering/show.jl b/src/rendering/show.jl index a31c5f7..5e6a597 100644 --- a/src/rendering/show.jl +++ b/src/rendering/show.jl @@ -22,7 +22,7 @@ function convert_vg_to_x(v::VGSpec, script) reader = @async read(p, String) wait(p) res = fetch(reader) - if p.exitcode!=0 + if p.exitcode != 0 throw(ArgumentError("Invalid spec")) end return res @@ -38,7 +38,7 @@ function convert_vg_to_svg(v::VGSpec) reader = @async read(p, String) wait(p) res = fetch(reader) - if p.exitcode!=0 + if p.exitcode != 0 throw(ArgumentError("Invalid spec")) end return res diff --git a/src/spec_utils.jl b/src/spec_utils.jl index 3d629cc..5188fe2 100644 --- a/src/spec_utils.jl +++ b/src/spec_utils.jl @@ -6,7 +6,7 @@ abstract type AbstractVegaSpec end Base.copy(spec::T) where {T <: AbstractVegaSpec} = T(copy(getparams(spec))) -const ObjectLike = Union{AbstractVegaSpec, ObjectProxy} +const ObjectLike = Union{AbstractVegaSpec,ObjectProxy} getparams(spec) = getfield(spec, :params) @@ -52,21 +52,21 @@ struct DataValuesNode col_values, col_names = TableTraitsUtils.create_columns_from_iterabletable(it) - return new(OrderedDict{Symbol,AbstractVector}(i[1]=>i[2] for i in zip(col_names,col_values))) + return new(OrderedDict{Symbol,AbstractVector}(i[1] => i[2] for i in zip(col_names, col_values))) end end -Base.:(==)(a::DataValuesNode, b::DataValuesNode) = a.columns==b.columns +Base.:(==)(a::DataValuesNode, b::DataValuesNode) = a.columns == b.columns function our_show_json(io, it, col_names) print(io, "[") for (row_index, row) in enumerate(it) - row_index==1 || print(io, ",") + row_index == 1 || print(io, ",") print(io, "{") for (col_index, col_value) in enumerate(row) - col_index==1 || print(io, ",") + col_index == 1 || print(io, ",") JSON.print(io, col_names[col_index]) print(io, ":") JSON.print(io, col_value isa DataValue ? get(col_value, nothing) : col_value) diff --git a/src/vgspec.jl b/src/vgspec.jl index 3f50edd..e912874 100644 --- a/src/vgspec.jl +++ b/src/vgspec.jl @@ -9,7 +9,7 @@ end # data is an array in vega function vg_set_spec_data!(specdict, datait, name) updated = false - recs = [OrderedDict{String,Any}(string(c[1])=>isa(c[2], DataValues.DataValue) ? (isna(c[2]) ? nothing : get(c[2])) : c[2] for c in zip(keys(r), values(r))) for r in datait] + recs = [OrderedDict{String,Any}(string(c[1]) => isa(c[2], DataValues.DataValue) ? (isna(c[2]) ? nothing : get(c[2])) : c[2] for c in zip(keys(r), values(r))) for r in datait] for def in specdict["data"] if def["name"] == name def["values"] = recs diff --git a/test/test_io.jl b/test/test_io.jl index bdfb39a..b99c0ec 100644 --- a/test/test_io.jl +++ b/test/test_io.jl @@ -1,6 +1,6 @@ using Test using Vega -using Vega: getparams +using Vega:getparams using DataFrames using Dates using FileIO @@ -32,23 +32,23 @@ vgp = getvgplot() # end Base.Filesystem.mktempdir() do folder - save(joinpath(folder,"test4.svg"), vgp) - @test isfile(joinpath(folder,"test4.svg")) + save(joinpath(folder, "test4.svg"), vgp) + @test isfile(joinpath(folder, "test4.svg")) - save(joinpath(folder,"test4.pdf"), vgp) - @test isfile(joinpath(folder,"test4.pdf")) + save(joinpath(folder, "test4.pdf"), vgp) + @test isfile(joinpath(folder, "test4.pdf")) - save(joinpath(folder,"test4.png"), vgp) - @test isfile(joinpath(folder,"test4.png")) + save(joinpath(folder, "test4.png"), vgp) + @test isfile(joinpath(folder, "test4.png")) # save(joinpath(folder,"test4.eps"), vgp) # @test isfile(joinpath(folder,"test4.eps")) vgpl1 = getvgplot() - Vega.savespec(joinpath(folder,"test1.vega"), vgpl1, include_data=true) + Vega.savespec(joinpath(folder, "test1.vega"), vgpl1, include_data=true) - vgpl2 = Vega.loadvgspec(joinpath(folder,"test1.vega")) + vgpl2 = Vega.loadvgspec(joinpath(folder, "test1.vega")) @test vgpl1 == vgpl1 diff --git a/test/test_macro.jl b/test/test_macro.jl index 4610724..907edfe 100644 --- a/test/test_macro.jl +++ b/test/test_macro.jl @@ -1,5 +1,5 @@ using Vega -using Vega: getparams +using Vega:getparams using JSON using Test