Merge pull request #322 from JunoLab/avi/require

don't load Weave Plots submodules into user's module
pull/324/head
Shuhei Kadowaki 2020-05-10 14:06:09 +09:00 committed by GitHub
commit d809ddf703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 23 deletions

View File

@ -6,14 +6,8 @@ using Highlights, Mustache, Requires
const WEAVE_OPTION_NAME = "options" # TODO: rename to "weave_options"
function __init__()
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" Base.include(
Main,
joinpath(@__DIR__, "plots.jl"),
)
@require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" Base.include(
Main,
joinpath(@__DIR__, "gadfly.jl"),
)
@require Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" include("plots.jl")
@require Gadfly = "c91e804a-d5a3-530f-b6f0-dfbca275c004" include("gadfly.jl")
end
@static @isdefined(isnothing) || begin

View File

@ -1,11 +1,12 @@
module GadflyPlots
import Gadfly
import Weave
using ..Weave, ..Gadfly
try
import Cairo
using Cairo
catch
@warn("Cairo.jl is required to be installed to generate raster images")
@warn "Cairo.jl is required to be installed to generate raster images"
end
Gadfly.set_default_plot_format(:svg)
@ -52,4 +53,5 @@ function Base.display(report::Weave.Report, m::MIME"image/svg+xml", p::Gadfly.Pl
@warn("Can't save figure. Unsupported format, $format")
end
end
end

View File

@ -1,10 +1,9 @@
module WeavePlots
using Base64
import Plots
import Weave
using Base64, ..Plots, ..Weave
"""Pre-execute hooks to set the plot size for the chunk """
# Pre-execute hooks to set the plot size for the chunk
function plots_set_size(chunk)
w = chunk.options[:fig_width] * chunk.options[:dpi]
h = chunk.options[:fig_height] * chunk.options[:dpi]

View File

@ -1,6 +1,7 @@
#Test for Gadfly with different chunk options and figure formatsusing Weave
using Weave
using Test
# Test for Gadfly with different chunk options and figure formatsusing Weave
using Gadfly
function test_gadfly(doctype, fig_ext)
out = weave(joinpath(@__DIR__ , "documents/gadfly_formats_test.jnw"),
@ -13,7 +14,6 @@ function test_gadfly(doctype, fig_ext)
rm(out)
end
##
test_gadfly("github", ".png")
test_gadfly("github", ".pdf")
test_gadfly("github", ".svg")
@ -24,7 +24,6 @@ test_gadfly("tex", ".png")
test_gadfly("tex", ".ps")
test_gadfly("tex", ".tex")
import Gadfly
p = Gadfly.plot(x=1:10, y=1:10)
@test showable(MIME"application/pdf"(), p) == true
@test showable(MIME"application/png"(), p) == true

View File

@ -1,5 +1,5 @@
using Weave
using Test
using Plots
function pljtest(source, resfile, doctype)
weave("documents/$source", out_path = "documents/plotsjl/$resfile", doctype=doctype)