Weave.jl/src/chunks.jl

90 lines
2.1 KiB
Julia
Raw Normal View History

2017-03-10 09:25:09 +01:00
using Compat
2017-03-10 09:25:09 +01:00
@compat abstract type WeaveChunk end
@compat abstract type Inline end
2016-12-26 19:06:03 +01:00
type 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
format
2016-04-11 17:40:18 +02:00
doctype::AbstractString
header_script::String
header::Dict
template::AbstractString
css::AbstractString
highlight_theme
2016-12-23 07:34:54 +01:00
fig_path::AbstractString
2016-12-14 20:50:29 +01:00
function WeaveDoc(source, chunks, header)
path, fname = splitdir(abspath(source))
basename = splitext(fname)[1]
new(source, basename, path, chunks, "", nothing, "", "", header,
2016-12-23 07:34:54 +01:00
"", "", Highlights.Themes.DefaultTheme, "")
end
end
immutable ChunkOutput
2016-04-11 17:40:18 +02:00
code::AbstractString
stdout::AbstractString
displayed::AbstractString
rich_output::AbstractString
2016-04-11 17:40:18 +02:00
figures::Array{AbstractString}
end
2016-12-26 19:06:03 +01:00
type CodeChunk <: WeaveChunk
2016-04-11 17:40:18 +02:00
content::AbstractString
number::Int
result_no::Int
start_line::Int
optionstring::AbstractString
options::Dict{Symbol, Any}
2016-04-11 17:40:18 +02:00
output::AbstractString
rich_output::AbstractString
2016-04-11 17:40:18 +02:00
figures::Array{AbstractString}
result::Array{ChunkOutput}
function CodeChunk(content, number, start_line, optionstring, options)
new(rstrip(content) * "\n", number, 0, start_line, optionstring, options, "","", AbstractString[], ChunkOutput[])
end
end
2016-12-26 19:06:03 +01:00
type DocChunk <: WeaveChunk
content::Array{Inline}
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
type InlineText <: Inline
content::AbstractString
2016-12-27 20:43:13 +01:00
si::Int
ei::Int
number::Int
end
2016-12-26 19:06:03 +01:00
type InlineCode <: Inline
content::AbstractString
2016-12-27 20:43:13 +01:00
si::Int
ei::Int
number::Int
2016-12-26 20:21:55 +01:00
output::AbstractString
rich_output::AbstractString
figures::Array{AbstractString}
2016-12-27 20:43:13 +01:00
function InlineCode(content, si, ei, number)
new(content, si, ei, number, "", "", AbstractString[])
2016-12-26 20:21:55 +01:00
end
2016-12-26 19:06:03 +01:00
end
type TermResult
end
type ScriptResult
end
type CollectResult
end