2019-03-10 16:51:19 +01:00
|
|
|
import Mustache
|
2015-01-04 14:18:17 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
abstract type WeaveChunk end
|
|
|
|
abstract type Inline end
|
2016-12-26 19:06:03 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct WeaveDoc
|
2016-04-11 17:40:18 +02:00
|
|
|
source::AbstractString
|
|
|
|
basename::AbstractString
|
|
|
|
path::AbstractString
|
2016-12-26 19:06:03 +01:00
|
|
|
chunks::Array{WeaveChunk}
|
2016-04-11 17:40:18 +02:00
|
|
|
cwd::AbstractString
|
2015-01-06 23:01:25 +01:00
|
|
|
format
|
2016-04-11 17:40:18 +02:00
|
|
|
doctype::AbstractString
|
2016-11-02 22:45:32 +01:00
|
|
|
header_script::String
|
2016-12-14 23:07:56 +01:00
|
|
|
header::Dict
|
2019-03-10 16:51:19 +01:00
|
|
|
template::Union{AbstractString, Mustache.MustacheTokens}
|
2016-12-15 14:49:21 +01:00
|
|
|
css::AbstractString
|
|
|
|
highlight_theme
|
2016-12-23 07:34:54 +01:00
|
|
|
fig_path::AbstractString
|
2019-03-05 18:36:27 +01:00
|
|
|
chunk_defaults::Dict{Symbol,Any}
|
2016-12-14 20:50:29 +01:00
|
|
|
function WeaveDoc(source, chunks, header)
|
2015-01-06 23:01:25 +01:00
|
|
|
path, fname = splitdir(abspath(source))
|
|
|
|
basename = splitext(fname)[1]
|
2016-12-15 14:49:21 +01:00
|
|
|
new(source, basename, path, chunks, "", nothing, "", "", header,
|
2019-03-05 18:36:27 +01:00
|
|
|
"", "", Highlights.Themes.DefaultTheme, "", deepcopy(rcParams[:chunk_defaults]))
|
2015-01-07 15:37:02 +01:00
|
|
|
end
|
2015-01-06 23:01:25 +01:00
|
|
|
end
|
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
struct ChunkOutput
|
2016-04-11 17:40:18 +02:00
|
|
|
code::AbstractString
|
|
|
|
stdout::AbstractString
|
|
|
|
displayed::AbstractString
|
2016-04-27 15:05:11 +02:00
|
|
|
rich_output::AbstractString
|
2016-04-11 17:40:18 +02:00
|
|
|
figures::Array{AbstractString}
|
2015-01-11 22:38:58 +01:00
|
|
|
end
|
2015-01-06 23:01:25 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct CodeChunk <: WeaveChunk
|
2016-04-11 17:40:18 +02:00
|
|
|
content::AbstractString
|
2015-01-04 14:18:17 +01:00
|
|
|
number::Int
|
2015-01-11 00:20:28 +01:00
|
|
|
result_no::Int
|
2015-01-04 14:18:17 +01:00
|
|
|
start_line::Int
|
2016-04-23 17:15:59 +02:00
|
|
|
optionstring::AbstractString
|
2015-01-04 14:18:17 +01:00
|
|
|
options::Dict{Symbol, Any}
|
2016-04-11 17:40:18 +02:00
|
|
|
output::AbstractString
|
2016-04-27 16:14:42 +02:00
|
|
|
rich_output::AbstractString
|
2016-04-11 17:40:18 +02:00
|
|
|
figures::Array{AbstractString}
|
2015-01-11 22:38:58 +01:00
|
|
|
result::Array{ChunkOutput}
|
2016-04-23 17:15:59 +02:00
|
|
|
function CodeChunk(content, number, start_line, optionstring, options)
|
2017-03-13 14:05:07 +01:00
|
|
|
new(rstrip(content) * "\n", number, 0, start_line, optionstring, options, "","", AbstractString[], ChunkOutput[])
|
2015-01-04 14:18:17 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct DocChunk <: WeaveChunk
|
2016-12-26 19:06:03 +01:00
|
|
|
content::Array{Inline}
|
2015-01-04 14:18:17 +01:00
|
|
|
number::Int
|
|
|
|
start_line::Int
|
2016-12-26 19:06:03 +01:00
|
|
|
function DocChunk(text::AbstractString, number::Int, start_line::Int, inline_regex = nothing)
|
|
|
|
chunks = parse_inline(text, inline_regex)
|
|
|
|
new(chunks, number, start_line)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct InlineText <: Inline
|
2016-12-26 19:06:03 +01:00
|
|
|
content::AbstractString
|
2016-12-27 20:43:13 +01:00
|
|
|
si::Int
|
|
|
|
ei::Int
|
|
|
|
number::Int
|
2015-01-04 14:18:17 +01:00
|
|
|
end
|
2015-01-11 22:38:58 +01:00
|
|
|
|
2017-12-31 13:02:28 +01:00
|
|
|
mutable struct InlineCode <: Inline
|
2016-12-26 19:06:03 +01:00
|
|
|
content::AbstractString
|
2016-12-27 20:43:13 +01:00
|
|
|
si::Int
|
|
|
|
ei::Int
|
|
|
|
number::Int
|
2019-03-06 21:27:47 +01:00
|
|
|
ctype::Symbol
|
2016-12-26 20:21:55 +01:00
|
|
|
output::AbstractString
|
|
|
|
rich_output::AbstractString
|
|
|
|
figures::Array{AbstractString}
|
2019-03-06 21:27:47 +01:00
|
|
|
function InlineCode(content, si, ei, number, ctype)
|
|
|
|
new(content, si, ei, number, ctype, "", "", AbstractString[])
|
2016-12-26 20:21:55 +01:00
|
|
|
end
|
2016-12-26 19:06:03 +01:00
|
|
|
end
|
|
|
|
|
2020-03-18 02:50:01 +01:00
|
|
|
struct TermResult end
|
|
|
|
struct ScriptResult end
|
|
|
|
struct CollectResult end
|