mirror of https://github.com/mpastell/Weave.jl
Merge branch 'fbot/deps'
commit
f8ffe9218d
|
@ -1,9 +1,9 @@
|
||||||
using Compat
|
using Compat
|
||||||
|
|
||||||
@compat abstract type WeaveChunk end
|
abstract type WeaveChunk end
|
||||||
@compat abstract type Inline end
|
abstract type Inline end
|
||||||
|
|
||||||
type WeaveDoc
|
mutable struct WeaveDoc
|
||||||
source::AbstractString
|
source::AbstractString
|
||||||
basename::AbstractString
|
basename::AbstractString
|
||||||
path::AbstractString
|
path::AbstractString
|
||||||
|
@ -25,7 +25,7 @@ type WeaveDoc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
immutable ChunkOutput
|
struct ChunkOutput
|
||||||
code::AbstractString
|
code::AbstractString
|
||||||
stdout::AbstractString
|
stdout::AbstractString
|
||||||
displayed::AbstractString
|
displayed::AbstractString
|
||||||
|
@ -33,7 +33,7 @@ immutable ChunkOutput
|
||||||
figures::Array{AbstractString}
|
figures::Array{AbstractString}
|
||||||
end
|
end
|
||||||
|
|
||||||
type CodeChunk <: WeaveChunk
|
mutable struct CodeChunk <: WeaveChunk
|
||||||
content::AbstractString
|
content::AbstractString
|
||||||
number::Int
|
number::Int
|
||||||
result_no::Int
|
result_no::Int
|
||||||
|
@ -49,7 +49,7 @@ type CodeChunk <: WeaveChunk
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
type DocChunk <: WeaveChunk
|
mutable struct DocChunk <: WeaveChunk
|
||||||
content::Array{Inline}
|
content::Array{Inline}
|
||||||
number::Int
|
number::Int
|
||||||
start_line::Int
|
start_line::Int
|
||||||
|
@ -59,14 +59,14 @@ type DocChunk <: WeaveChunk
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
type InlineText <: Inline
|
mutable struct InlineText <: Inline
|
||||||
content::AbstractString
|
content::AbstractString
|
||||||
si::Int
|
si::Int
|
||||||
ei::Int
|
ei::Int
|
||||||
number::Int
|
number::Int
|
||||||
end
|
end
|
||||||
|
|
||||||
type InlineCode <: Inline
|
mutable struct InlineCode <: Inline
|
||||||
content::AbstractString
|
content::AbstractString
|
||||||
si::Int
|
si::Int
|
||||||
ei::Int
|
ei::Int
|
||||||
|
@ -79,11 +79,11 @@ type InlineCode <: Inline
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
type TermResult
|
mutable struct TermResult
|
||||||
end
|
end
|
||||||
|
|
||||||
type ScriptResult
|
mutable struct ScriptResult
|
||||||
end
|
end
|
||||||
|
|
||||||
type CollectResult
|
mutable struct CollectResult
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using Compat
|
using Compat
|
||||||
|
|
||||||
#Contains report global properties
|
#Contains report global properties
|
||||||
type Report <: Display
|
mutable struct Report <: Display
|
||||||
cwd::AbstractString
|
cwd::AbstractString
|
||||||
basename::AbstractString
|
basename::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
|
@ -33,7 +33,7 @@ function Base.display(report::Report, data)
|
||||||
for m in report.mimetypes
|
for m in report.mimetypes
|
||||||
if mimewritable(m, data)
|
if mimewritable(m, data)
|
||||||
try
|
try
|
||||||
@compat Compat.invokelatest(display, report, m, data)
|
Compat.invokelatest(display, report, m, data)
|
||||||
catch e
|
catch e
|
||||||
warn("Failed to display data in \"$m\" format")
|
warn("Failed to display data in \"$m\" format")
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -131,32 +131,10 @@ function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2HTML)
|
||||||
text = format_chunk(chunk, formatdict, nothing)
|
text = format_chunk(chunk, formatdict, nothing)
|
||||||
#invokelatest seems to be needed here
|
#invokelatest seems to be needed here
|
||||||
#to fix "invalid age range" on 0.6 #21653
|
#to fix "invalid age range" on 0.6 #21653
|
||||||
m = @compat Compat.invokelatest(Base.Markdown.parse, text)
|
m = Compat.invokelatest(Base.Markdown.parse, text)
|
||||||
return string(Documenter.Writers.HTMLWriter.mdconvert(m))
|
return string(Documenter.Writers.HTMLWriter.mdconvert(m))
|
||||||
end
|
end
|
||||||
|
|
||||||
if VERSION < v"0.6.0-dev.1965"
|
|
||||||
#Fixes to Base latex writer, included in JuliaLang/julia#19842 and JuliaLang/julia#19832.
|
|
||||||
function Base.Markdown.latex(io::IO, md::Base.Markdown.Paragraph)
|
|
||||||
println(io)
|
|
||||||
for md in md.content
|
|
||||||
Base.Markdown.latexinline(io, md)
|
|
||||||
end
|
|
||||||
println(io)
|
|
||||||
end
|
|
||||||
|
|
||||||
function wrapverb(f, io, cmd)
|
|
||||||
print(io, "\\", cmd, "|")
|
|
||||||
f()
|
|
||||||
print(io, "|")
|
|
||||||
end
|
|
||||||
|
|
||||||
function Base.Markdown.latexinline(io::IO, code::Base.Markdown.Code)
|
|
||||||
wrapverb(io, "verb") do
|
|
||||||
print(io, code.code)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2tex)
|
function format_chunk(chunk::DocChunk, formatdict, docformat::JMarkdown2tex)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
type Tex
|
mutable struct Tex
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -36,7 +36,7 @@ const texminted = Tex("Latex using minted for highlighting",
|
||||||
:mimetypes => ["application/pdf", "image/png", "text/latex", "text/plain"]
|
:mimetypes => ["application/pdf", "image/png", "text/latex", "text/plain"]
|
||||||
))
|
))
|
||||||
|
|
||||||
type Pandoc
|
mutable struct Pandoc
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -69,7 +69,7 @@ const pdoc2html = Pandoc("Markdown to HTML (requires Pandoc)",
|
||||||
"text/html", "text/markdown", "text/plain"],
|
"text/html", "text/markdown", "text/plain"],
|
||||||
:doctype=> "pandoc2html"))
|
:doctype=> "pandoc2html"))
|
||||||
|
|
||||||
type Markdown
|
mutable struct Markdown
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -90,7 +90,7 @@ Formatter for Hugo: https://gohugo.io/
|
||||||
|
|
||||||
When `uglyURLs` is `false`, prepend figure path by `..`.
|
When `uglyURLs` is `false`, prepend figure path by `..`.
|
||||||
"""
|
"""
|
||||||
immutable Hugo
|
struct Hugo
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
uglyURLs::Bool
|
uglyURLs::Bool
|
||||||
|
@ -108,7 +108,7 @@ const hugo = Hugo("Hugo markdown (using shortcodes)",
|
||||||
false)
|
false)
|
||||||
|
|
||||||
#Julia markdown
|
#Julia markdown
|
||||||
type JMarkdown2HTML
|
mutable struct JMarkdown2HTML
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -125,7 +125,7 @@ const md2html = JMarkdown2HTML("Julia markdown to html", Dict{Symbol,Any}(
|
||||||
:doctype=> "md2html"))
|
:doctype=> "md2html"))
|
||||||
|
|
||||||
#Julia markdown
|
#Julia markdown
|
||||||
type JMarkdown2tex
|
mutable struct JMarkdown2tex
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -142,7 +142,7 @@ const md2tex = JMarkdown2tex("Julia markdown to latex", Dict{Symbol,Any}(
|
||||||
:doctype=> "md2tex"))
|
:doctype=> "md2tex"))
|
||||||
|
|
||||||
|
|
||||||
type MultiMarkdown
|
mutable struct MultiMarkdown
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -201,7 +201,7 @@ const multimarkdown = MultiMarkdown("MultiMarkdown",
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
type Rest
|
mutable struct Rest
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
@ -219,7 +219,7 @@ const rst = Rest("reStructuredText and Sphinx",
|
||||||
:doctype => "rst"
|
:doctype => "rst"
|
||||||
))
|
))
|
||||||
|
|
||||||
type AsciiDoc
|
mutable struct AsciiDoc
|
||||||
description::AbstractString
|
description::AbstractString
|
||||||
formatdict::Dict{Symbol,Any}
|
formatdict::Dict{Symbol,Any}
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,13 +2,13 @@ import JSON, YAML
|
||||||
|
|
||||||
pushopt(options::Dict,expr::Expr) = Base.Meta.isexpr(expr,:(=)) && (options[expr.args[1]] = expr.args[2])
|
pushopt(options::Dict,expr::Expr) = Base.Meta.isexpr(expr,:(=)) && (options[expr.args[1]] = expr.args[2])
|
||||||
|
|
||||||
type MarkupInput
|
mutable struct MarkupInput
|
||||||
codestart::Regex
|
codestart::Regex
|
||||||
codeend::Regex
|
codeend::Regex
|
||||||
inline::Regex
|
inline::Regex
|
||||||
end
|
end
|
||||||
|
|
||||||
type ScriptInput
|
mutable struct ScriptInput
|
||||||
doc_line::Regex
|
doc_line::Regex
|
||||||
doc_start::Regex
|
doc_start::Regex
|
||||||
opt_line::Regex
|
opt_line::Regex
|
||||||
|
@ -16,7 +16,7 @@ type ScriptInput
|
||||||
inline::Regex
|
inline::Regex
|
||||||
end
|
end
|
||||||
|
|
||||||
type NotebookInput
|
mutable struct NotebookInput
|
||||||
inline
|
inline
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ function run_code(chunk::CodeChunk, report::Report, SandBox::Module)
|
||||||
|
|
||||||
#Save figures only in the end of chunk for PyPlot
|
#Save figures only in the end of chunk for PyPlot
|
||||||
if rcParams[:plotlib] == "PyPlot"
|
if rcParams[:plotlib] == "PyPlot"
|
||||||
@compat Compat.invokelatest(savefigs_pyplot, report)
|
Compat.invokelatest(savefigs_pyplot, report)
|
||||||
end
|
end
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -279,7 +279,7 @@ function eval_chunk(chunk::CodeChunk, report::Report, SandBox::Module)
|
||||||
|
|
||||||
#Run preexecute_hooks
|
#Run preexecute_hooks
|
||||||
for hook in preexecute_hooks
|
for hook in preexecute_hooks
|
||||||
chunk = @compat Compat.invokelatest(hook, chunk)
|
chunk = Compat.invokelatest(hook, chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
report.fignum = 1
|
report.fignum = 1
|
||||||
|
@ -294,7 +294,7 @@ function eval_chunk(chunk::CodeChunk, report::Report, SandBox::Module)
|
||||||
|
|
||||||
#Run post_execute chunks
|
#Run post_execute chunks
|
||||||
for hook in postexecute_hooks
|
for hook in postexecute_hooks
|
||||||
chunk = @compat Compat.invokelatest(hook, chunk)
|
chunk = Compat.invokelatest(hook, chunk)
|
||||||
end
|
end
|
||||||
|
|
||||||
if chunk.options[:term]
|
if chunk.options[:term]
|
||||||
|
@ -485,7 +485,7 @@ function detect_plotlib(chunk::CodeChunk)
|
||||||
if isdefined(:Plots)
|
if isdefined(:Plots)
|
||||||
init_plotting("Plots")
|
init_plotting("Plots")
|
||||||
#Need to set size before plots are created
|
#Need to set size before plots are created
|
||||||
@compat Compat.invokelatest(plots_set_size, chunk)
|
Compat.invokelatest(plots_set_size, chunk)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
import JSON
|
import JSON
|
||||||
|
|
||||||
type NotebookOutput
|
mutable struct NotebookOutput
|
||||||
end
|
end
|
||||||
|
|
||||||
type MarkdownOutput
|
mutable struct MarkdownOutput
|
||||||
end
|
end
|
||||||
|
|
||||||
type NowebOutput
|
mutable struct NowebOutput
|
||||||
end
|
end
|
||||||
|
|
||||||
type ScriptOutput
|
mutable struct ScriptOutput
|
||||||
end
|
end
|
||||||
|
|
||||||
const output_formats = Dict{String, Any}(
|
const output_formats = Dict{String, Any}(
|
||||||
|
|
Loading…
Reference in New Issue