<NME> runtests.jl
<BEF> using Test
import Documenter
include("TestUtilities.jl"); using Main.TestUtilities

@testset "Documenter" begin
    # Build the example docs
    @info "Building example/make.jl"
    include("examples/make.jl")

    # Test missing docs
    @info "Building missingdocs/make.jl"
    include("missingdocs/make.jl")

    # Error reporting.
    @info "Building errors/make.jl"
    @quietly include("errors/make.jl")

    # Unit tests for module internals.
    include("except.jl")
    include("utilities.jl")
    include("remotes.jl")

    # DocChecks tests
    include("docchecks.jl")

    # NavNode tests.
    include("navnode.jl")

    # DocSystem unit tests.
    include("docsystem.jl")

    # CrossReferences
    include("crossreferences.jl")

    # DocTest unit tests.
    @info "Running tests in doctests/"
    include("doctests/docmeta.jl")
    include("doctests/doctestapi.jl")
    include("doctests/doctests.jl")
    include("doctests/fix/tests.jl")

    # DOM Tests.
    include("dom.jl")

    # MDFlatten tests.
    include("mdflatten.jl")

    # Main build pipeline (Builder and Expanders modules)
    include("pipeline.jl")

    # HTMLWriter
    include("htmlwriter.jl")

    # LaTeXWriter
    include("latexwriter.jl")

    # Deployment configurations
    include("deployconfig.jl")
    include("deploydocs.jl")

    # Mock package docs.
    include("examples/tests.jl")

include(joinpath(dirname(@__FILE__), "examples", "tests.jl"))

# Documenter package docs:

const Documenter_root = normpath(joinpath(dirname(@__FILE__), "..", "docs"))

info("Building Documenter package docs.")
doc = makedocs(
    debug   = true,
    root    = Documenter_root,
    modules = Documenter,
    clean   = false,
)

@test isa(doc, Documenter.Documents.Document)

let build_dir  = joinpath(Documenter_root, "build"),
    source_dir = joinpath(Documenter_root, "src")

    @test isdir(build_dir)
    @test isdir(joinpath(build_dir, "assets"))
    @test isdir(joinpath(build_dir, "lib"))
    @test isdir(joinpath(build_dir, "man"))

    @test isfile(joinpath(build_dir, "index.md"))
    @test isfile(joinpath(build_dir, "assets", "mathjaxhelper.js"))
    @test isfile(joinpath(build_dir, "assets", "Documenter.css"))
end

@test doc.user.root   == Documenter_root
@test doc.user.source == "src"
@test doc.user.build  == "build"
@test doc.user.clean  == false

rm(joinpath(Documenter_root, "build"); recursive = true)

mktempdir() do root
    let path = joinpath(root, "docs")
        Documenter.generate("DocumenterTestPackage", dir = path)
        @test isdir(path)
        @test isfile(joinpath(path, "mkdocs.yml"))
        @test isfile(joinpath(path, ".gitignore"))
        @test isfile(joinpath(path, "make.jl"))
        @test isdir(joinpath(path, "src"))
        @test isfile(joinpath(path, "src", "index.md"))
    end
end

@test_throws ErrorException Documenter.generate("Documenter")
@test_throws ErrorException Documenter.generate(randstring())

# Test PDF generation.

makedocs(
    root = Documenter_root,
    modules = [Documenter],
    clean = false,
    format = Documenter.Formats.LaTeX,
    sitename = "Documenter.jl",
    authors = "Michael Hatherly, Morten Piibeleht, and contributors.",
    pages = Any[ # Compat: `Any` for 0.4 compat
        "Home" => "index.md",
        "Manual" => Any[
            "Guide" => "man/guide.md",
            "man/examples.md",
            "man/syntax.md",
            "man/doctests.md",
            "man/hosting.md",
            "man/latex.md",
            "man/internals.md",
            "man/contributing.md",
        ],
        "Library" => Any[
            "Public" => "lib/public.md",
            "Internals" => Any[
                "Internals" => "lib/internals.md",
                "lib/internals/anchors.md",
                "lib/internals/builder.md",
                "lib/internals/cross-references.md",
                "lib/internals/docchecks.md",
                "lib/internals/docsystem.md",
                "lib/internals/documents.md",
                "lib/internals/dom.md",
                "lib/internals/expanders.md",
                "lib/internals/formats.md",
                "lib/internals/generator.md",
                "lib/internals/mdflatten.md",
                "lib/internals/selectors.md",
                "lib/internals/utilities.md",
                "lib/internals/walkers.md",
                "lib/internals/writers.md",
            ]
        ]
    ]
)

end

    @test_throws ArgumentError makedocs(sitename="", HTML())

    # Running doctest() on our own manual
    @info "doctest() Documenter's manual"
    @quietly include("manual.jl")
end

<MSG> Move output tests to separate files, use testsets

<DFF> @@ -63,99 +63,10 @@ println("="^50)
 
 include(joinpath(dirname(@__FILE__), "examples", "tests.jl"))
 
-# Documenter package docs:
+# Documenter package docs with other formats
 
-const Documenter_root = normpath(joinpath(dirname(@__FILE__), "..", "docs"))
-
-info("Building Documenter package docs.")
-doc = makedocs(
-    debug   = true,
-    root    = Documenter_root,
-    modules = Documenter,
-    clean   = false,
-)
-
-@test isa(doc, Documenter.Documents.Document)
-
-let build_dir  = joinpath(Documenter_root, "build"),
-    source_dir = joinpath(Documenter_root, "src")
-
-    @test isdir(build_dir)
-    @test isdir(joinpath(build_dir, "assets"))
-    @test isdir(joinpath(build_dir, "lib"))
-    @test isdir(joinpath(build_dir, "man"))
-
-    @test isfile(joinpath(build_dir, "index.md"))
-    @test isfile(joinpath(build_dir, "assets", "mathjaxhelper.js"))
-    @test isfile(joinpath(build_dir, "assets", "Documenter.css"))
-end
-
-@test doc.user.root   == Documenter_root
-@test doc.user.source == "src"
-@test doc.user.build  == "build"
-@test doc.user.clean  == false
-
-rm(joinpath(Documenter_root, "build"); recursive = true)
-
-mktempdir() do root
-    let path = joinpath(root, "docs")
-        Documenter.generate("DocumenterTestPackage", dir = path)
-        @test isdir(path)
-        @test isfile(joinpath(path, "mkdocs.yml"))
-        @test isfile(joinpath(path, ".gitignore"))
-        @test isfile(joinpath(path, "make.jl"))
-        @test isdir(joinpath(path, "src"))
-        @test isfile(joinpath(path, "src", "index.md"))
-    end
-end
-
-@test_throws ErrorException Documenter.generate("Documenter")
-@test_throws ErrorException Documenter.generate(randstring())
-
-# Test PDF generation.
-
-makedocs(
-    root = Documenter_root,
-    modules = [Documenter],
-    clean = false,
-    format = Documenter.Formats.LaTeX,
-    sitename = "Documenter.jl",
-    authors = "Michael Hatherly, Morten Piibeleht, and contributors.",
-    pages = Any[ # Compat: `Any` for 0.4 compat
-        "Home" => "index.md",
-        "Manual" => Any[
-            "Guide" => "man/guide.md",
-            "man/examples.md",
-            "man/syntax.md",
-            "man/doctests.md",
-            "man/hosting.md",
-            "man/latex.md",
-            "man/internals.md",
-            "man/contributing.md",
-        ],
-        "Library" => Any[
-            "Public" => "lib/public.md",
-            "Internals" => Any[
-                "Internals" => "lib/internals.md",
-                "lib/internals/anchors.md",
-                "lib/internals/builder.md",
-                "lib/internals/cross-references.md",
-                "lib/internals/docchecks.md",
-                "lib/internals/docsystem.md",
-                "lib/internals/documents.md",
-                "lib/internals/dom.md",
-                "lib/internals/expanders.md",
-                "lib/internals/formats.md",
-                "lib/internals/generator.md",
-                "lib/internals/mdflatten.md",
-                "lib/internals/selectors.md",
-                "lib/internals/utilities.md",
-                "lib/internals/walkers.md",
-                "lib/internals/writers.md",
-            ]
-        ]
-    ]
-)
+include("formats/markdown.jl")
+include("formats/latex.jl")
 
 end
 

Move output tests to separate files, use testsets