Weave.jl/src/config.jl

65 lines
1.7 KiB
Julia
Raw Normal View History

2020-05-08 16:39:17 +02:00
# Default options
const defaultParams = Dict{Symbol,Any}(
:storeresults => false,
:chunk_defaults => Dict{Symbol,Any}(
:echo => true,
:results => "markup",
:hold => false,
:fig => true,
:include => true,
:eval => true,
:tangle => true,
:cache => false,
:fig_cap => nothing,
# Size in inches
:fig_width => 6,
:fig_height => 4,
:fig_path => DEFAULT_FIG_PATH,
2020-05-08 16:39:17 +02:00
:dpi => 96,
:term => false,
:display => false,
:prompt => "\njulia> ",
:label => nothing,
:wrap => true,
:line_width => 75,
:engine => "julia",
# :option_AbstractString=> "",
# Defined in formats
:fig_ext => nothing,
:fig_pos => nothing,
:fig_env => nothing,
:out_width => nothing,
:out_height => nothing,
:skip => false,
),
)
# This one can be changed at runtime, initially a copy of defaults
2016-12-23 09:54:48 +01:00
const rcParams = deepcopy(defaultParams)
"""
2020-05-10 06:56:09 +02:00
set_chunk_defaults!(opts::Dict{Symbol, Any})
2016-12-23 09:54:48 +01:00
2020-03-06 02:14:21 +01:00
Set default options for code chunks, use [`get_chunk_defaults`](@ref) to see the current values.
2016-12-23 09:54:48 +01:00
2020-03-26 13:41:54 +01:00
E.g.: set default `dpi` to `200` and `fig_width` to `8`
2016-12-23 09:54:48 +01:00
2020-03-06 02:14:21 +01:00
```julia
2020-05-10 06:56:09 +02:00
julia> set_chunk_defaults!(Dict(:dpi => 200, :fig_width => 8))
2016-12-23 09:54:48 +01:00
```
"""
2020-05-10 06:56:09 +02:00
set_chunk_defaults!(opts::Dict{Symbol,Any}) = merge!(rcParams[:chunk_defaults], opts)
2016-12-23 09:54:48 +01:00
"""
2020-03-26 13:41:54 +01:00
get_chunk_defaults()
2016-12-23 09:54:48 +01:00
Get default options used for code chunks.
"""
2020-05-10 06:56:09 +02:00
get_chunk_defaults() = rcParams[:chunk_defaults]
2016-12-23 09:54:48 +01:00
"""
2020-05-10 06:56:09 +02:00
restore_chunk_defaults!()
2016-12-23 09:54:48 +01:00
2020-03-26 13:41:54 +01:00
Restore Weave.jl default chunk options.
2016-12-23 09:54:48 +01:00
"""
2020-05-10 06:56:09 +02:00
restore_chunk_defaults!() = rcParams[:chunk_defaults] = defaultParams[:chunk_defaults]