From 66ba0df14b4939c8b0ec40a6815bc3964bae8733 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 8 Sep 2020 18:02:47 +0000 Subject: [PATCH] Format files using DocumentFormat --- docs/make.jl | 8 ++-- src/ElectronDisplay.jl | 40 ++++++++--------- test/runtests.jl | 97 +++++++++++++++++++++--------------------- 3 files changed, 72 insertions(+), 73 deletions(-) diff --git a/docs/make.jl b/docs/make.jl index 7561094..fb761bf 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,14 +1,14 @@ using Documenter, ElectronDisplay makedocs( - modules = [ElectronDisplay], - sitename = "ElectronDisplay.jl", + modules=[ElectronDisplay], + sitename="ElectronDisplay.jl", analytics="UA-132838790-1", - pages = [ + pages=[ "Introduction" => "index.md" ] ) deploydocs( - repo = "github.com/queryverse/ElectronDisplay.jl.git" + repo="github.com/queryverse/ElectronDisplay.jl.git" ) diff --git a/src/ElectronDisplay.jl b/src/ElectronDisplay.jl index dc78fc9..84d69d4 100644 --- a/src/ElectronDisplay.jl +++ b/src/ElectronDisplay.jl @@ -25,16 +25,16 @@ Update a copy of `config` based on `kwargs`. """ setconfig( config::ElectronDisplayConfig; - showable = config.showable, - single_window::Bool = config.single_window, - focus::Bool = config.focus, - max_json_bytes::Int = config.max_json_bytes, + showable=config.showable, + single_window::Bool=config.single_window, + focus::Bool=config.focus, + max_json_bytes::Int=config.max_json_bytes, ) = ElectronDisplayConfig( - showable = showable, - single_window = single_window, - focus = focus, - max_json_bytes = max_json_bytes, + showable=showable, + single_window=single_window, + focus=focus, + max_json_bytes=max_json_bytes, ) struct ElectronDisplayType <: Base.AbstractDisplay @@ -261,31 +261,31 @@ Base.displayable(d::ElectronDisplayType, ::MIME{Symbol("application/vnd.datareso function Base.display(d::ElectronDisplayType, x) showable = d.config.showable if showable("application/vnd.vegalite.v4+json", x) - display(d,MIME("application/vnd.vegalite.v4+json"), x) + display(d, MIME("application/vnd.vegalite.v4+json"), x) elseif showable("application/vnd.vegalite.v3+json", x) - display(d,MIME("application/vnd.vegalite.v3+json"), x) + display(d, MIME("application/vnd.vegalite.v3+json"), x) elseif showable("application/vnd.vegalite.v2+json", x) - display(d,MIME("application/vnd.vegalite.v2+json"), x) + display(d, MIME("application/vnd.vegalite.v2+json"), x) elseif showable("application/vnd.vega.v5+json", x) - display(d,MIME("application/vnd.vega.v5+json"), x) + display(d, MIME("application/vnd.vega.v5+json"), x) elseif showable("application/vnd.vega.v4+json", x) - display(d,MIME("application/vnd.vega.v4+json"), x) + display(d, MIME("application/vnd.vega.v4+json"), x) elseif showable("application/vnd.vega.v3+json", x) - display(d,MIME("application/vnd.vega.v3+json"), x) + display(d, MIME("application/vnd.vega.v3+json"), x) elseif showable("application/vnd.plotly.v1+json", x) - display(d,MIME("application/vnd.plotly.v1+json"), x) + display(d, MIME("application/vnd.plotly.v1+json"), x) elseif showable("application/vnd.dataresource+json", x) display(d, "application/vnd.dataresource+json", x) elseif showable("image/svg+xml", x) - display(d,"image/svg+xml", x) + display(d, "image/svg+xml", x) elseif showable("image/png", x) - display(d,"image/png", x) + display(d, "image/png", x) elseif showable("text/html", x) display(d, "text/html", x) elseif showable("text/markdown", x) display(d, "text/markdown", x) else - throw(MethodError(Base.display,(d,x))) + throw(MethodError(Base.display, (d, x))) end end @@ -323,10 +323,10 @@ Base.showable(::MIME"application/vnd.dataresource+json", dt::CachedDataResourceS function electrondisplay(x; config...) d = newdisplay(; showable=showable, config...) - if TableTraits.isiterabletable(x)!==false + if TableTraits.isiterabletable(x) !== false if showable("application/vnd.dataresource+json", x) display(d, x) - elseif TableTraits.isiterabletable(x)===true + elseif TableTraits.isiterabletable(x) === true display(d, DataresourceTableTraitsWrapper(x)) else try diff --git a/test/runtests.jl b/test/runtests.jl index e14460e..6cfebd8 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -17,69 +17,68 @@ include("construct_vega_specs.jl") @testset "ElectronDisplay" begin -p1 = plot(y=[1,2,3]) + p1 = plot(y=[1,2,3]) -f = display(p1) + f = display(p1) -@test f isa Electron.Window + @test f isa Electron.Window -ElectronDisplay.CONFIG.single_window = true + ElectronDisplay.CONFIG.single_window = true -f = display(p1) + f = display(p1) -@test f === ElectronDisplay._getglobalplotwindow() + @test f === ElectronDisplay._getglobalplotwindow() -p2 = plot(y=[1,2,3]) -f2 = display(p2) + p2 = plot(y=[1,2,3]) + f2 = display(p2) -@test f2 === f # Window is reused + @test f2 === f # Window is reused -eldt = ElectronDisplay.ElectronDisplayType() + eldt = ElectronDisplay.ElectronDisplayType() -@test electrondisplay(vl2) isa Electron.Window -@test electrondisplay(vl3) isa Electron.Window -@test electrondisplay(vg3) isa Electron.Window -@test electrondisplay(vg4) isa Electron.Window -@test electrondisplay(vg5) isa Electron.Window + @test electrondisplay(vl2) isa Electron.Window + @test electrondisplay(vl3) isa Electron.Window + @test electrondisplay(vg3) isa Electron.Window + @test electrondisplay(vg4) isa Electron.Window + @test electrondisplay(vg5) isa Electron.Window -@test_logs( + @test_logs( (:warn, r"The size of JSON representation.*exceeds.*max_json_bytes"), electrondisplay(vl3png; max_json_bytes=-1)::Electron.Window ) -mdo = DummyDisplayable{MIME"text/markdown"}("""foo""") -@test electrondisplay(mdo) isa Electron.Window - -pngo = DummyDisplayable{MIME"image/png"}("""fakedata""") -@test electrondisplay(pngo) isa Electron.Window - -dro = DummyDisplayable{MIME"application/vnd.dataresource+json"}("""{"schema":{"fields":[{"name": "Miles_per_Gallon","type": "number"}]},"data":[{"Miles_per_Gallon":18}]}""") -@test electrondisplay(dro) isa Electron.Window - -@test displayable(eldt, "text/html") == true -@test displayable(eldt, "text/markdown") == true -@test displayable(eldt, "image/png") == true -@test displayable(eldt, "image/svg+xml") == true -@test displayable(eldt, "application/vnd.vegalite.v2+json") == true -@test displayable(eldt, "application/vnd.vegalite.v3+json") == true -@test displayable(eldt, "application/vnd.vegalite.v4+json") == true -@test displayable(eldt, "application/vnd.vega.v3+json") == true -@test displayable(eldt, "application/vnd.vega.v4+json") == true -@test displayable(eldt, "application/vnd.vega.v5+json") == true -@test displayable(eldt, "application/vnd.plotly.v1+json") == true -@test displayable(eldt, "application/vnd.dataresource+json") == true - -@testset "smoke test: single_window=$single_window focus=$focus " for - single_window in [false, true], + mdo = DummyDisplayable{MIME"text/markdown"}("""foo""") + @test electrondisplay(mdo) isa Electron.Window + + pngo = DummyDisplayable{MIME"image/png"}("""fakedata""") + @test electrondisplay(pngo) isa Electron.Window + + dro = DummyDisplayable{MIME"application/vnd.dataresource+json"}("""{"schema":{"fields":[{"name": "Miles_per_Gallon","type": "number"}]},"data":[{"Miles_per_Gallon":18}]}""") + @test electrondisplay(dro) isa Electron.Window + + @test displayable(eldt, "text/html") == true + @test displayable(eldt, "text/markdown") == true + @test displayable(eldt, "image/png") == true + @test displayable(eldt, "image/svg+xml") == true + @test displayable(eldt, "application/vnd.vegalite.v2+json") == true + @test displayable(eldt, "application/vnd.vegalite.v3+json") == true + @test displayable(eldt, "application/vnd.vegalite.v4+json") == true + @test displayable(eldt, "application/vnd.vega.v3+json") == true + @test displayable(eldt, "application/vnd.vega.v4+json") == true + @test displayable(eldt, "application/vnd.vega.v5+json") == true + @test displayable(eldt, "application/vnd.plotly.v1+json") == true + @test displayable(eldt, "application/vnd.dataresource+json") == true + + @testset "smoke test: single_window=$single_window focus=$focus " for single_window in [false, true], focus in [false, true] - ElectronDisplay.CONFIG.single_window = single_window - ElectronDisplay.CONFIG.focus = focus - @test electrondisplay(dataset("cars")) isa Electron.Window - @test electrondisplay(@doc reduce) isa Electron.Window - - config = (single_window=single_window, focus=focus) - @test electrondisplay(dataset("cars"); config...) isa Electron.Window - @test electrondisplay(@doc reduce; config...) isa Electron.Window -end + ElectronDisplay.CONFIG.single_window = single_window + ElectronDisplay.CONFIG.focus = focus + @test electrondisplay(dataset("cars")) isa Electron.Window + @test electrondisplay(@doc reduce) isa Electron.Window + + config = (single_window = single_window, focus = focus) + @test electrondisplay(dataset("cars"); config...) isa Electron.Window + @test electrondisplay(@doc reduce; config...) isa Electron.Window + end end