Skip to content

Commit 051d319

Browse files
authored
Format files using DocumentFormat
1 parent d004e4e commit 051d319

File tree

13 files changed

+178
-171
lines changed

13 files changed

+178
-171
lines changed

docs/make.jl

+22-24
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,28 @@ function Base.show(io::IO, m::MIME"text/html", v::Vega.VGSpec)
99
end
1010

1111
makedocs(
12-
modules=[Vega],
13-
sitename="Vega.jl",
14-
pages=[
15-
"Home" => "index.md",
16-
"Getting Started" => Any[
17-
"Installation" => "gettingstarted/installation.md"
18-
],
19-
"User Guide" => Any[
20-
"Using Vega" => "userguide/vega.md"
21-
],
22-
"Examples" => Any[
23-
24-
"Line & Area Charts" => "examples/examples_vega_line_area_charts.md",
25-
"Circular Charts" => "examples/examples_vega_circular_charts.md",
26-
"Scatter Plots" => "examples/examples_vega_scatter_plots.md",
27-
"Tree Diagrams" => "examples/examples_vega_tree_diagrams.md",
28-
"Network Diagrams" => "examples/examples_vega_network_diagrams.md",
29-
"Single Data Source" => "examples/examples_vega_single_data_source.md",
30-
"Multiple Data Source" => "examples/examples_vega_multi_data_source.md"
31-
],
32-
"Reference Manual" => [
33-
"Global settings" => "referencemanual/global.md",
34-
"Outputs" => "referencemanual/output.md"]
35-
]
12+
modules=[Vega],
13+
sitename="Vega.jl",
14+
pages=[
15+
"Home" => "index.md",
16+
"Getting Started" => Any[
17+
"Installation"=>"gettingstarted/installation.md"
18+
],
19+
"User Guide" => Any[
20+
"Using Vega"=>"userguide/vega.md"
21+
],
22+
"Examples" => Any["Line & Area Charts"=>"examples/examples_vega_line_area_charts.md",
23+
"Circular Charts"=>"examples/examples_vega_circular_charts.md",
24+
"Scatter Plots"=>"examples/examples_vega_scatter_plots.md",
25+
"Tree Diagrams"=>"examples/examples_vega_tree_diagrams.md",
26+
"Network Diagrams"=>"examples/examples_vega_network_diagrams.md",
27+
"Single Data Source"=>"examples/examples_vega_single_data_source.md",
28+
"Multiple Data Source"=>"examples/examples_vega_multi_data_source.md"
29+
],
30+
"Reference Manual" => [
31+
"Global settings" => "referencemanual/global.md",
32+
"Outputs" => "referencemanual/output.md"]
33+
]
3634
)
3735

3836
deploydocs(

src/Vega.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ show if plots will have (true) or not (false) the action links displayed
6868
indicate if actions links should be dislpayed under the plot
6969
"""
7070
actionlinks() = ACTIONSLINKS
71-
actionlinks(b::Bool) = (global ACTIONSLINKS ; ACTIONSLINKS = b)
71+
actionlinks(b::Bool) = (global ACTIONSLINKS; ACTIONSLINKS = b)
7272

7373

7474
######################## includes #####################################

src/dsl_vlplot_function/dsl_vlplot_function.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function convert_nt_to_dict(item::AbstractVegaFragment, fragtype)
1919
return fragtype(item.positional, OrderedDict{String,Any}(string(k) => convert_nt_to_dict(v, fragtype) for (k, v) in pairs(item.named)))
2020
end
2121

22-
function walk_dict(f, d::T, parent) where {T <: AbstractDict}
22+
function walk_dict(f, d::T, parent) where {T<:AbstractDict}
2323
res = T()
2424
for p in d
2525
if p[2] isa Dict
@@ -108,6 +108,6 @@ function convert_frag_tree_to_dict(spec::VGFrag)
108108
return OrderedDict{String,Any}(k => replace_remaining_frag(v) for (k, v) in spec.named)
109109
end
110110

111-
function vgplot(args...;kwargs...)
112-
return VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vgfrag(args...;kwargs...))))
111+
function vgplot(args...; kwargs...)
112+
return VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec(vgfrag(args...; kwargs...))))
113113
end

src/dsl_vlplot_macro/dsl_vlplot_macro.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ function convert_curly_style_array(exprs, fragtype)
33

44
for ex in exprs
55
if ex isa Expr && ex.head == :braces
6-
push!(res.args, :( $(convert_curly_style(ex.args, fragtype)) ))
6+
push!(res.args, :($(convert_curly_style(ex.args, fragtype))))
77
else
88
push!(res.args, esc(ex))
99
end
@@ -21,11 +21,11 @@ function convert_curly_style(exprs, fragtype)
2121
for ex in exprs
2222
if ex isa Expr && ex.head == :(=)
2323
if ex.args[2] isa Expr && ex.args[2].head == :braces
24-
push!(named_args, :( $(string(ex.args[1])) => $(convert_curly_style(ex.args[2].args, fragtype)) ))
24+
push!(named_args, :($(string(ex.args[1])) => $(convert_curly_style(ex.args[2].args, fragtype))))
2525
elseif ex.args[2] isa Expr && ex.args[2].head == :vect
26-
push!(named_args, :( $(string(ex.args[1])) => $(convert_curly_style_array(ex.args[2].args, fragtype)) ))
26+
push!(named_args, :($(string(ex.args[1])) => $(convert_curly_style_array(ex.args[2].args, fragtype))))
2727
else
28-
push!(named_args, :( $(string(ex.args[1])) => $(esc(ex.args[2])) ))
28+
push!(named_args, :($(string(ex.args[1])) => $(esc(ex.args[2]))))
2929
end
3030
elseif ex isa Expr && ex.head == :braces
3131
push!(pos_args, convert_curly_style(ex.args, fragtype))
@@ -40,7 +40,7 @@ end
4040
macro vgplot(ex...)
4141
new_ex = convert_curly_style(ex, VGFrag)
4242

43-
return :( Vega.VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex))) )
43+
return :(Vega.VGSpec(convert_frag_tree_to_dict(fix_shortcut_level_spec($new_ex))))
4444
end
4545

4646
macro vgfrag(ex...)

src/rendering/io.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ end
4040

4141
savespec(filename::AbstractString, v::AbstractVegaSpec; kwargs...) =
4242
open(filename, "w") do io
43-
savespec(io, v; kwargs...)
44-
end
43+
savespec(io, v; kwargs...)
44+
end

src/rendering/render.jl

+81-72
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ using JSON
77

88
asset(url...) = normpath(vegalite_app_path("minified", url...))
99

10-
const package_json = Ref{Dict{String, Any}}()
10+
const package_json = Ref{Dict{String,Any}}()
1111

1212
function version(package)
13-
if !isassigned(package_json)
14-
package_json[] = JSON.parsefile(vegalite_app_path("package.json"))
15-
end
13+
if !isassigned(package_json)
14+
package_json[] = JSON.parsefile(vegalite_app_path("package.json"))
15+
end
1616

17-
return package_json[]["dependencies"][package]
17+
return package_json[]["dependencies"][package]
1818
end
1919

2020
# Vega Scaffold: https://github.com/vega/vega/wiki/Runtime
@@ -23,47 +23,50 @@ function writehtml_full(io::IO, spec::VGSpec; title="Vega plot")
2323
divid = "vg" * randstring(3)
2424

2525
println(io,
26-
"""
27-
<html>
28-
<head>
29-
<title>$title</title>
30-
<meta charset="UTF-8">
31-
<script>$(read(asset("vega.min.js"), String))</script>
32-
<script>$(read(asset("vega-embed.min.js"), String))</script>
33-
</head>
34-
<body>
35-
<div id="$divid" style="width:100%;height:100%;"></div>
36-
</body>
37-
38-
<style media="screen">
39-
.vega-actions a {
40-
margin-right: 10px;
41-
font-family: sans-serif;
42-
font-size: x-small;
43-
font-style: italic;
44-
}
45-
</style>
46-
47-
<script type="text/javascript">
48-
49-
var opt = {
50-
mode: "vega",
51-
renderer: "$RENDERER",
52-
actions: $ACTIONSLINKS
53-
}
54-
55-
var spec = """)
26+
"""
27+
<html>
28+
<head>
29+
<title>$title</title>
30+
<meta charset="UTF-8">
31+
<script>$(read(asset("vega.min.js"), String))</script>
32+
<script>$(read(asset("vega-embed.min.js"), String))</script>
33+
</head>
34+
<body>
35+
<div id="$divid" style="width:100%;height:100%;"></div>
36+
</body>
37+
38+
<style media="screen">
39+
.vega-actions a {
40+
margin-right: 10px;
41+
font-family: sans-serif;
42+
font-size: x-small;
43+
font-style: italic;
44+
}
45+
</style>
46+
47+
<script type="text/javascript">
48+
49+
var opt = {
50+
mode: "vega",
51+
renderer: "$RENDERER",
52+
actions: $ACTIONSLINKS
53+
}
54+
55+
var spec = """)
5656

5757
our_json_print(io, spec)
5858
println(io)
5959

60-
println(io, """
61-
vegaEmbed('#$divid', spec, opt);
60+
println(
61+
io,
62+
"""
63+
vegaEmbed('#$divid', spec, opt);
6264
63-
</script>
65+
</script>
6466
65-
</html>
66-
""")
67+
</html>
68+
"""
69+
)
6770
end
6871

6972
function writehtml_full(spec::VGSpec; title="Vega plot")
@@ -81,35 +84,41 @@ Creates a HTML script + div block for showing the plot (typically for Pluto).
8184
VegaLite js files are loaded from the web using script tags.
8285
"""
8386
function writehtml_partial_script(io::IO, spec::VGSpec; title="VegaLite plot")
84-
divid = "vg" * randstring(3)
85-
print(io, """
86-
<style media="screen">
87-
.vega-actions a {
88-
margin-right: 10px;
89-
font-family: sans-serif;
90-
font-size: x-small;
91-
font-style: italic;
92-
}
93-
</style>
94-
95-
<script src="https://cdn.jsdelivr.net/npm/vega@$(version("vega"))/build/vega.min.js"></script>
96-
<script src="https://cdn.jsdelivr.net/npm/vega-embed@$(version("vega-embed"))/build/vega-embed.min.js"></script>
97-
98-
<div id="$divid"></div>
99-
100-
<script>
101-
var spec = """)
102-
our_json_print(io, spec)
103-
print(io,"""
104-
;
105-
var opt = {
106-
mode: "vega-lite",
107-
renderer: "$(Vega.RENDERER)",
108-
actions: $(Vega.ACTIONSLINKS)
109-
};
110-
vegaEmbed("#$divid", spec, opt);
111-
</script>
112-
""")
87+
divid = "vg" * randstring(3)
88+
print(
89+
io,
90+
"""
91+
<style media="screen">
92+
.vega-actions a {
93+
margin-right: 10px;
94+
font-family: sans-serif;
95+
font-size: x-small;
96+
font-style: italic;
97+
}
98+
</style>
99+
100+
<script src="https://cdn.jsdelivr.net/npm/vega@$(version("vega"))/build/vega.min.js"></script>
101+
<script src="https://cdn.jsdelivr.net/npm/vega-embed@$(version("vega-embed"))/build/vega-embed.min.js"></script>
102+
103+
<div id="$divid"></div>
104+
105+
<script>
106+
var spec = """
107+
)
108+
our_json_print(io, spec)
109+
print(
110+
io,
111+
"""
112+
;
113+
var opt = {
114+
mode: "vega-lite",
115+
renderer: "$(Vega.RENDERER)",
116+
actions: $(Vega.ACTIONSLINKS)
117+
};
118+
vegaEmbed("#$divid", spec, opt);
119+
</script>
120+
"""
121+
)
113122
end
114123

115124

@@ -120,9 +129,9 @@ function launch_browser(tmppath::String)
120129
if Sys.isapple()
121130
run(`open $tmppath`)
122131
elseif Sys.iswindows()
123-
run(`cmd /c start $tmppath`)
124-
elseif Sys.islinux()
125-
run(`xdg-open $tmppath`)
132+
run(`cmd /c start $tmppath`)
133+
elseif Sys.islinux()
134+
run(`xdg-open $tmppath`)
126135
end
127136
end
128137

src/rendering/show.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ function convert_vg_to_x(v::VGSpec, fileformat; cmd_args="")
2828
reader = @async read(p, String)
2929

3030
wait(writer)
31-
wait(p)
31+
wait(p)
3232
res = fetch(reader)
33-
33+
3434
if p.exitcode != 0
3535
throw(ArgumentError("Invalid spec"))
3636
end

0 commit comments

Comments
 (0)