<NME> tests_latex.jl
<BEF> using Test

# DOCUMENTER_TEST_EXAMPLES can be used to control which builds are performed in
# make.jl, and we need to set it to the relevant LaTeX builds.
ENV["DOCUMENTER_TEST_EXAMPLES"] = "latex_simple"

# When the file is run separately we need to include make.jl which actually builds
# the docs and defines a few modules that are referred to in the docs. The make.jl
# When the file is run separately we need to include make.jl which actually builds
# the docs and defines a few modules that are referred to in the docs. The make.jl
# has to be expected in the context of the Main module.
if (@__MODULE__) === Main && !@isdefined examples_root
    include("make.jl")
elseif (@__MODULE__) !== Main && isdefined(Main, :examples_root)
    using Documenter
    const examples_root = Main.examples_root
elseif (@__MODULE__) !== Main && !isdefined(Main, :examples_root)
    error("examples/make.jl has not been loaded into Main.")
end

# This gets appended to the filename if we're building a tag (i.e. TRAVIS_TAG is set)
tagsuffix = if occursin(Base.VERSION_REGEX, get(ENV, "TRAVIS_TAG", ""))
    v = VersionNumber(ENV["TRAVIS_TAG"])
            @test joinpath(build_dir, "DocumenterLaTeXSimple.pdf") |> isfile
        end
    end
end
    end

    @testset "PDF/LaTeX" begin
        doc = Main.examples_latex_doc
        @test isa(doc, Documenter.Documents.Document)
        let build_dir = joinpath(examples_root, "builds", "latex")
            @test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
        end
    end

    @testset "PDF/LaTeX: Custom Cover Page" begin
        doc = Main.examples_latex_cover_page
        @test isa(doc, Documenter.Documents.Document)
        let build_dir = joinpath(examples_root, "builds", "latex_cover_page")
            @test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
        end
    end

    @testset "PDF/LaTeX: Custom TOC Style" begin
        doc = Main.examples_latex_toc_style
        @test isa(doc, Documenter.Documents.Document)
        let build_dir = joinpath(examples_root, "builds", "latex_toc_style")
            @test joinpath(build_dir, "DocumenterLaTeX$(tagsuffix).pdf") |> isfile
        end
    end

    @testset "PDF/LaTeX: tectonic" begin
        doc = Main.examples_latex_simple_tectonic_doc
        @test isa(doc, Documenter.Documents.Document)
        let build_dir = joinpath(examples_root, "builds", "latex_simple_tectonic")
            @test joinpath(build_dir, "DocumenterLaTeXSimpleTectonic-1.2.3.pdf") |> isfile
        end
    end

    @testset "PDF/LaTeX: showcase" begin
        doc = Main.examples_latex_showcase_doc
        @test isa(doc, Documenter.Documents.Document)
        let build_dir = joinpath(examples_root, "builds", "latex_showcase")
            @test joinpath(build_dir, "DocumenterLaTeXShowcase-1.2.3.pdf") |> isfile
        end
    end
end

<MSG> Fix problems with at-index/contents in LaTeXWriter

The \begin{itemize} / \end{itemize} were not correctly paired in the
LaTeX generated for at-contents blocks when the items went for than two
levels deep. Also, empty at-index and at-contents emitted an empty
\begin/\end pair, which errors, as you need at least one \item.

When storing the LaTeX build files with DOCUMENTER_LATEX_DEBUG, you can
now set it to a directory name, so that it would not generate a new
directory every time.

Also, except for one file, test/examples is not built with LaTeXWriter
on CI too in the new build stage, fixing #950.

<DFF> @@ -2,7 +2,7 @@ using Test
 
 # DOCUMENTER_TEST_EXAMPLES can be used to control which builds are performed in
 # make.jl, and we need to set it to the relevant LaTeX builds.
-ENV["DOCUMENTER_TEST_EXAMPLES"] = "latex_simple"
+ENV["DOCUMENTER_TEST_EXAMPLES"] = "latex latex_simple"
 
 # When the file is run separately we need to include make.jl which actually builds
 # the docs and defines a few modules that are referred to in the docs. The make.jl
@@ -24,4 +24,12 @@ end
             @test joinpath(build_dir, "DocumenterLaTeXSimple.pdf") |> isfile
         end
     end
+
+    @testset "PDF/LaTeX" begin
+        doc = Main.examples_latex_doc
+        @test isa(doc, Documenter.Documents.Document)
+        let build_dir = joinpath(examples_root, "builds", "latex")
+            @test joinpath(build_dir, "DocumenterLaTeX.pdf") |> isfile
+        end
+    end
 end

Fix problems with at-index/contents in LaTeXWriter