Skip to content

Commit 0d0b99a

Browse files
authored
Format files using DocumentFormat
1 parent 9303adc commit 0d0b99a

File tree

15 files changed

+265
-258
lines changed

15 files changed

+265
-258
lines changed

docs/make.jl

Lines changed: 22 additions & 24 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ show if plots will have (true) or not (false) the action links displayed
6262
indicate if actions links should be dislpayed under the plot
6363
"""
6464
actionlinks() = ACTIONSLINKS
65-
actionlinks(b::Bool) = (global ACTIONSLINKS ; ACTIONSLINKS = b)
65+
actionlinks(b::Bool) = (global ACTIONSLINKS; ACTIONSLINKS = b)
6666

6767

6868
######################## includes #####################################

src/dsl_vlplot_function/dsl_vlplot_function.jl

Lines changed: 3 additions & 3 deletions
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -16,47 +16,50 @@ function writehtml_full(io::IO, spec::VGSpec; title="Vega plot")
1616
divid = "vg" * randstring(3)
1717

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

5050
our_json_print(io, spec)
5151
println(io)
5252

53-
println(io, """
54-
vegaEmbed('#$divid', spec, opt);
53+
println(
54+
io,
55+
"""
56+
vegaEmbed('#$divid', spec, opt);
5557
56-
</script>
58+
</script>
5759
58-
</html>
59-
""")
60+
</html>
61+
"""
62+
)
6063
end
6164

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

108117

@@ -113,9 +122,9 @@ function launch_browser(tmppath::String)
113122
if Sys.isapple()
114123
run(`open $tmppath`)
115124
elseif Sys.iswindows()
116-
run(`cmd /c start $tmppath`)
117-
elseif Sys.islinux()
118-
run(`xdg-open $tmppath`)
125+
run(`cmd /c start $tmppath`)
126+
elseif Sys.islinux()
127+
run(`xdg-open $tmppath`)
119128
end
120129
end
121130

0 commit comments

Comments
 (0)