Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new platform to compile only to latex #1339

Merged
merged 6 commits into from
Jun 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/src/man/other-formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,16 @@ services:
```

to your `.travis.yml` file.

### Compiling to latex only
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved

There's a possibility to save only the `.tex` file and skip the pdf compilation.
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved
For this purpose use the `platform="none"` keyword:

```
using DocumenterLaTeX
makedocs(
format = LaTeX(platform = "none"),
...
)
```
14 changes: 10 additions & 4 deletions src/Writers/LaTeXWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ The `makedocs` argument `authors` should also be specified, it will be used for

# Keyword arguments

**`platform`** sets the platform where the tex-file is compiled, either `"native"` (default) or `"docker"`.
**`platform`** sets the platform where the tex-file is compiled, either `"native"` (default), `"docker"`,
or "none" which doesn't compile the tex.
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved
See [Other Output Formats](@ref) for more information.
"""
struct LaTeX <: Documenter.Writer
platform::String
function LaTeX(; platform = "native")
platform ∈ ("native", "docker") || throw(ArgumentError("unknown platform: $platform"))
platform ∈ ("native", "docker", "none") || throw(ArgumentError("unknown platform: $platform"))
return new(platform)
end
end
Expand Down Expand Up @@ -94,7 +95,7 @@ function mktempdir(args...; kwargs...)
end

function render(doc::Documents.Document, settings::LaTeX=LaTeX())
@info "LaTeXWriter: rendering PDF."
@info "LaTeXWriter: rendering tex file."
cserteGT3 marked this conversation as resolved.
Show resolved Hide resolved
Base.mktempdir() do path
cp(joinpath(doc.user.root, doc.user.build), joinpath(path, "build"))
cd(joinpath(path, "build")) do
Expand Down Expand Up @@ -147,7 +148,9 @@ function render(doc::Documents.Document, settings::LaTeX=LaTeX())
end

# If the build was successful, copy of the PDF to the .build directory
if status
if status && (settings.platform == "none")
cp(texfile, joinpath(doc.user.root, doc.user.build, texfile); force = true)
elseif status
cp(pdffile, joinpath(doc.user.root, doc.user.build, pdffile); force = true)
else
error("Compiling the .tex file failed. See logs for more information.")
Expand Down Expand Up @@ -193,6 +196,9 @@ function compile_tex(doc::Documents.Document, settings::LaTeX, texfile::String)
finally
try; piperun(`docker stop latex-container`); catch; end
end
elseif settings.platform == "none"
@info "Skipping compiling tex file."
return true
end
end

Expand Down