<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

# Integration tests for module api.

# setup
# =====

const example_root = joinpath(dirname(@__FILE__), "examples")

const env =
    makedocs(
        debug = true,
        root  = example_root,
    )

# tests
# =====
    # Passing a writer positionally (https://github.com/JuliaDocs/Documenter.jl/issues/1046)
    @test_throws ArgumentError makedocs(sitename="", HTML())

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

@test length(env.docsmap) == 7

end

<MSG> Include submodules when using 'modules' keyword.

<DFF> @@ -55,16 +55,17 @@ end
 
 # Integration tests for module api.
 
+# Mock package docs:
+
 # setup
 # =====
 
 const example_root = joinpath(dirname(@__FILE__), "examples")
 
-const env =
-    makedocs(
-        debug = true,
-        root  = example_root,
-    )
+env = makedocs(
+    debug = true,
+    root  = example_root,
+)
 
 # tests
 # =====
@@ -109,4 +110,37 @@ end
 
 @test length(env.docsmap) == 7
 
+# Lapidary package docs:
+
+const lapidary_root = Pkg.dir("Lapidary", "docs")
+
+env = makedocs(
+    debug   = true,
+    root    = lapidary_root,
+    modules = Lapidary,
+    clean   = false,
+)
+
+@test isa(env, Lapidary.Env)
+
+let build_dir  = joinpath(lapidary_root, "build"),
+    source_dir = joinpath(lapidary_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", "Lapidary.css"))
+end
+
+@test env.root   == lapidary_root
+@test env.source == "src"
+@test env.build  == "build"
+@test env.clean  == false
+
+rm(joinpath(lapidary_root, "build"); recursive = true)
+
 end

Include submodules when using 'modules' keyword.