Weave.jl/src/config.jl

85 lines
2.7 KiB
Julia
Raw Normal View History

#Default options
const defaultParams =
@compat Dict{Symbol,Any}(:plotlib => "Gadfly",
2014-12-05 17:58:15 +01:00
:storeresults => false,
:doc_number => 0,
2014-12-05 17:58:15 +01:00
:chunk_defaults =>
2014-12-05 11:59:05 +01:00
Dict{Symbol,Any}(
2014-12-05 17:58:15 +01:00
:echo=> true,
:results=> "markup",
2016-04-19 15:38:03 +02:00
:hold => false,
2014-12-05 17:58:15 +01:00
:fig=> true,
:include=> true,
:eval => true,
:tangle => true,
:cache => false,
2014-12-05 22:13:44 +01:00
:fig_cap=> nothing,
2014-12-05 17:58:15 +01:00
#Size in inches
:fig_width => 6,
:fig_height => 4,
:fig_path=> "figures",
:dpi => 96,
:term=> false,
:name=> nothing,
:wrap=> true,
:line_width => 75,
2014-12-05 17:58:15 +01:00
:engine=> "julia",
2016-04-11 17:40:18 +02:00
#:option_AbstractString=> "",
2014-12-05 17:58:15 +01:00
#Defined in formats
:fig_ext => nothing,
:fig_pos=> nothing,
:fig_env=> nothing,
:out_width=> nothing,
:out_height=> nothing,
)
)
#This one can be changed at runtime, initially a copy of defaults
const rcParams = deepcopy(defaultParams)
#Parameters set per document
const docParams =Dict{Symbol,Any}(
:fig_path=> nothing,
:fig_ext => nothing,
)
"""
`set_chunk_defaults(opts::Dict{Symbol, Any})`
Set default options for code chunks, use get_chunk_defaults
to see the current values.
2014-12-05 17:58:15 +01:00
e.g. set default dpi to 200 and fig_width to 8
```
julia> set_chunk_defaults(Dict{Symbol, Any}(:dpi => 200, fig_width => 8))
```
"""
function set_chunk_defaults(opts::Dict{Symbol, Any})
merge!(rcParams[:chunk_defaults], opts)
end
"""
`get_chunk_defaults()`
Get default options used for code chunks.
"""
function get_chunk_defaults()
return(rcParams[:chunk_defaults])
end
"""
`restore_chunk_defaults()`
Restore Weave.jl default chunk options
"""
function restore_chunk_defaults()
rcParams[:chunk_defaults] = defaultParams[:chunk_defaults]
merge!(rcParams[:chunk_defaults], docParams)
return nothing
end