Skip to content

Commit

Permalink
Final fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Dec 9, 2018
1 parent 73ab219 commit ff3b35b
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 38 deletions.
18 changes: 8 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ julia:
- 1.0
- nightly

services:
- docker

notifications:
email: false

Expand All @@ -21,17 +18,18 @@ after_success:

jobs:
include:
- stage: "Documentation"
- stage: "Documentation/HTML"
julia: 1.0
os: linux
script:
# html
- julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- julia --project=docs/ docs/make.jl
# pdf
# - julia --project=docs/pdf/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
after_success: skip
- stage: "Documentation/PDF"
julia: 1.0
os: linux
services: docker
script:
- julia --project=docs/pdf/ -e 'using Pkg; Pkg.instantiate()'
- julia --project=docs/pdf/ docs/pdf/make.jl
after_success:
- julia --project=coverage/ -e 'using Pkg; Pkg.instantiate()'
- julia --project=coverage/ coverage/coverage.jl
after_success: skip
2 changes: 0 additions & 2 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ makedocs(
prettyurls = !("local" in ARGS),
canonical = "https://juliadocs.github.io/Documenter.jl/stable/",
),
# format = LaTeX(engine = "docker"),
# format = Markdown(),
clean = false,
assets = ["assets/favicon.ico"],
sitename = "Documenter.jl",
Expand Down
2 changes: 1 addition & 1 deletion docs/pdf/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.6.0"

[[Documenter]]
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "LibGit2", "Logging", "Markdown", "REPL", "Random", "Test", "Unicode"]
deps = ["Base64", "DocStringExtensions", "InteractiveUtils", "LibGit2", "Logging", "Markdown", "Pkg", "REPL", "Random", "Test", "Unicode"]
path = "../.."
uuid = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
version = "0.20.0+"
Expand Down
22 changes: 16 additions & 6 deletions docs/pdf/make.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using Documenter, DocumenterTools, DocumenterLaTeX
using Test

const ROOT = joinpath(@__DIR__, "..")

# Documenter package docs
doc = makedocs(
debug = true,
root = joinpath(@__DIR__, ".."),
root = ROOT,
build = "pdf/build",
modules = [Documenter, DocumenterTools],
clean = false,
format = LaTeX(engine = "docker"),
format = LaTeX(platform = "docker"),
sitename = "Documenter.jl",
authors = "Michael Hatherly, Morten Piibeleht, and contributors.",
pages = [
Expand Down Expand Up @@ -49,7 +51,15 @@ doc = makedocs(
]
);

@testset "LaTeX" begin
@test isa(doc, Documenter.Documents.Document)
@test isfile(joinpath(doc.user.root, doc.user.build, doc.user.sitename * ".pdf"))
end
# hack to only deploy the actual pdf-file
mkpath(joinpath(ROOT, "pdf", "build", "pdfdir"))
mv(joinpath(ROOT, "pdf", "build", "Documenter.jl.pdf"),
joinpath(ROOT, "pdf", "build", "pdfdir", "Documenter.jl.pdf"))


deploydocs(
repo = "github.com/JuliaDocs/Documenter.jl.git",
root = ROOT,
target = "pdf/build/pdfdir",
branch = "gh-pages-pdf",
)
2 changes: 1 addition & 1 deletion docs/src/man/other-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ installed tex which is the default. This is done with the `LaTeX` specifier:
```
using DocumenterLaTeX
makedocs(
format = LaTeX(engine = "docker"),
format = LaTeX(platform = "docker"),
...
)
```
Expand Down
4 changes: 2 additions & 2 deletions src/Documents.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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{Any} # What format to render the final document with?
format :: Vector{Plugin} # 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..
Expand Down Expand Up @@ -258,7 +258,7 @@ function Document(plugins = nothing;
Utilities.check_kwargs(others)

if !isa(format, AbstractVector)
format = [format]
format = Plugin[format]
end

if version == "git-commit"
Expand Down
25 changes: 10 additions & 15 deletions src/Writers/LaTeXWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@ module LaTeXWriter
import ...Documenter: Documenter

"""
LaTeXWriter.LaTeX(kwargs...)
LaTeXWriter.LaTeX(; kwargs...)
Sets the behavior of [`LaTeXWriter`](@ref).
# Keyword arguments
**`engine`** sets the latex engine; (natively installed) `"latexmk"`
(default) or `"docker"` using the
[`juliadocs/documenter-latex`](https://hub.docker.com/r/juliadocs/documenter-latex/)
docker image with required tex installation and fonts included.
**`platform`** sets the platform where the tex-file is compiled, either `"native"` (default) or `"docker"`.
See [Other Output Formats](@ref) for more information.
"""
struct LaTeX <: Documenter.Plugin
engine::String
function LaTeX(; engine = "latexmk")
engine ("latexmk", "docker") || throw(ArgumentError("unknown engine: $engine"))
return new(engine)
platform::String
function LaTeX(; platform = "native")
platform ("native", "docker") || throw(ArgumentError("unknown platform: $platform"))
return new(platform)
end
end

Expand Down Expand Up @@ -116,7 +114,7 @@ end
const DOCKER_IMAGE_TAG = "0.1"

function compile_tex(doc::Documents.Document, settings::LaTeX, texfile::String)
if settings.engine == "latexmk"
if settings.platform == "native"
Sys.which("latexmk") === nothing && (@error "LaTeXWriter: latexmk command not found."; return false)
@info "LaTeXWriter: using latexmk to compile tex."
try
Expand All @@ -128,7 +126,7 @@ function compile_tex(doc::Documents.Document, settings::LaTeX, texfile::String)
"Logs and partial output can be found in $(Utilities.locrepr(logs))." exception = err
return false
end
elseif settings.engine == "docker"
elseif settings.platform == "docker"
Sys.which("docker") === nothing && (@error "LaTeXWriter: docker command not found."; return false)
@info "LaTeXWriter: using docker to compile tex."
script = """
Expand All @@ -150,14 +148,11 @@ function compile_tex(doc::Documents.Document, settings::LaTeX, texfile::String)
finally
try; piperun(`docker stop latex-container`); catch; end
end
else
@error "LaTeXWriter: unrecognized engine: $(engine)"
return false
end
end

function piperun(cmd)
verbose = "--verbose" in ARGS
verbose = "--verbose" in ARGS || get(ENV, "DOCUMENTER_VERBOSE", "false") == "true"
run(pipeline(cmd, stdout = verbose ? stdout : "LaTeXWriter.stdout",
stderr = verbose ? stderr : "LaTeXWriter.stderr"))
end
Expand Down
12 changes: 12 additions & 0 deletions test/formats/latex.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# build pdf version of Documenter's docs on 64-bit Linux
if Sys.ARCH === :x86_64 && Sys.KERNEL === :Linux
cd(joinpath(@__DIR__, "..", "..")) do
cmd = `$(Base.julia_cmd()) --project=docs/pdf/`
@test success(`$(cmd) -e 'using Pkg; Pkg.instantiate()'`)
@test success(`$(cmd) docs/pdf/make.jl --verbose`)
# deploy only from Julia v1.0.X
if VERSION.major == 1 && VERSION.minor == 1
@test success(`$(cmd) docs/pdf/deploy.jl`)
end
end
end
1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ println("="^50)

# Documenter package docs with other formats.
include("formats/markdown.jl")
# include("formats/latex.jl")

# A simple build outside of a Git repository
include("nongit/tests.jl")
Expand Down

0 comments on commit ff3b35b

Please sign in to comment.