diff --git a/docs/Project.toml b/docs/Project.toml index c12fbd9d91b..dd27a7aa120 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,2 +1,4 @@ [deps] +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +DocumenterLaTeX = "cd674d7a-5f81-5cf3-af33-235ef1834b99" DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8" diff --git a/docs/make.jl b/docs/make.jl index b008aa9b47d..d844f506b10 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -1,7 +1,8 @@ -using Documenter, DocumenterTools +using Documenter, DocumenterTools, DocumenterLaTeX makedocs( modules = [Documenter, DocumenterTools], + format = Documenter.Writers.LaTeXWriter.LaTeX(), clean = false, assets = ["assets/favicon.ico"], sitename = "Documenter.jl", diff --git a/src/Documents.jl b/src/Documents.jl index 8276e78bc86..dcab56d343a 100644 --- a/src/Documents.jl +++ b/src/Documents.jl @@ -184,7 +184,7 @@ struct User root :: String # An absolute path to the root directory of the document. source :: String # Parent directory is `.root`. Where files are read from. build :: String # Parent directory is also `.root`. Where files are written to. - format :: Vector{Symbol} # What format to render the final document with? + format :: Vector{Any} # What format to render the final document with? clean :: Bool # Empty the `build` directory before starting a new build? doctest :: Union{Bool,Symbol} # Run doctests? linkcheck::Bool # Check external links.. @@ -262,8 +262,9 @@ function Document(plugins; ) Utilities.check_kwargs(others) - fmt = Formats.fmt(format) - @assert !isempty(fmt) "No formats provided." + # fmt = Formats.fmt(format) + # @assert !isempty(fmt) "No formats provided." + fmt = [format] if version == "git-commit" version = "git:$(Utilities.get_commit_short(root))" diff --git a/src/Writers/LaTeXWriter.jl b/src/Writers/LaTeXWriter.jl index f93f0bdb431..8253dc2c52f 100644 --- a/src/Writers/LaTeXWriter.jl +++ b/src/Writers/LaTeXWriter.jl @@ -14,6 +14,13 @@ navigation menu. It goes into the `\\title` LaTeX command. """ module LaTeXWriter +struct LaTeX + info::Dict{String,Any} +end +function LaTeX() + return LaTeX(Dict{String,Any}("engine" => "latexmk")) +end + import ...Documenter: Anchors, Builder, @@ -53,7 +60,7 @@ const DOCUMENT_STRUCTURE = ( "subparagraph", ) -function render(doc::Documents.Document) +function render(doc::Documents.Document, fmt::LaTeX) mktempdir() do path cp(joinpath(doc.user.root, doc.user.build), joinpath(path, "build")) cd(joinpath(path, "build")) do @@ -86,7 +93,7 @@ function render(doc::Documents.Document) cp(STYLE, "documenter.sty") # compile .tex and copy over the .pdf file if compile_tex return true - status = compile_tex(texfile) + status = compile_tex(doc, fmt, texfile) status && cp(pdffile, joinpath(doc.user.root, doc.user.build, pdffile); force = true) end end @@ -94,8 +101,9 @@ end const DOCKER_IMAGE_TAG = "0.1" -function compile_tex(texfile) - engine = get(ENV, "DOCUMENTER_LATEX_ENGINE", "latexmk") # TODO: make this configurable from makedocs +function compile_tex(doc, fmt, texfile) + # engine = get(ENV, "DOCUMENTER_LATEX_ENGINE", "docker") # TODO: make this configurable from makedocs + engine = get(fmt.info, "engine", "docker") if engine == "latexmk" Sys.which("latexmk") === nothing && (@error "LaTeXWriter: latexmk command not found."; return false) @info "LaTeXWriter: using latexmk to compile tex." diff --git a/src/Writers/Writers.jl b/src/Writers/Writers.jl index 37b518c7f35..ad275a4d6a6 100644 --- a/src/Writers/Writers.jl +++ b/src/Writers/Writers.jl @@ -35,11 +35,11 @@ Selectors.order(::Type{LaTeXFormat}) = 2.0 Selectors.order(::Type{HTMLFormat}) = 3.0 Selectors.matcher(::Type{MarkdownFormat}, fmt, _) = fmt === :markdown -Selectors.matcher(::Type{LaTeXFormat}, fmt, _) = fmt === :latex +Selectors.matcher(::Type{LaTeXFormat}, fmt, _) = fmt === :latex || isa(fmt, LaTeXWriter.LaTeX) Selectors.matcher(::Type{HTMLFormat}, fmt, _) = fmt === :html Selectors.runner(::Type{MarkdownFormat}, _, doc) = MarkdownWriter.render(doc) -Selectors.runner(::Type{LaTeXFormat}, _, doc) = LaTeXWriter.render(doc) +Selectors.runner(::Type{LaTeXFormat}, fmt, doc) = LaTeXWriter.render(doc, fmt) Selectors.runner(::Type{HTMLFormat}, _, doc) = HTMLWriter.render(doc) """