<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

module Tests

using Lapidary
using Base.Test
using Compat


    # CrossReferences
    include("crossreferences.jl")


type T end

"Lapidary unit tests."
Base.length(::T) = 1

end

let doc = @doc(length)
    a = Lapidary.Utilities.filterdocs(doc, Set{Module}())
    b = Lapidary.Utilities.filterdocs(doc, Set{Module}([UnitTests]))
    c = Lapidary.Utilities.filterdocs(doc, Set{Module}([Base]))
    d = Lapidary.Utilities.filterdocs(doc, Set{Module}([Tests]))

    @test !isnull(a)
    @test get(a) === doc
    @test !isnull(b)
    @test contains(stringmime("text/plain", get(b)), "Lapidary unit tests.")
    @test !isnull(c)
    @test !contains(stringmime("text/plain", get(c)), "Lapidary unit tests.")
    @test isnull(d)
end

    include("deployconfig.jl")
    include("deploydocs.jl")

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

    # A simple build outside of a Git repository
    @info "Building nongit/tests.jl"
    @quietly include("nongit/tests.jl")

    # A simple build evaluating code outside build directory
    @info "Building workdir/tests.jl"
    @quietly include("workdir/tests.jl")

    # Passing a writer positionally (https://github.com/JuliaDocs/Documenter.jl/issues/1046)
# tests
# =====

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

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

    @test isfile(joinpath(build_dir, "index.md"))
    @test isfile(joinpath(build_dir, "assets", "mathjaxhelper.js"))
    @test isfile(joinpath(build_dir, "assets", "Lapidary.css"))
    @test isfile(joinpath(build_dir, "assets", "custom.css"))
    @test isfile(joinpath(build_dir, "lib", "functions.md"))
    @test isfile(joinpath(build_dir, "man", "tutorial.md"))
@test doc.user.source == "src"
@test doc.user.build  == "build"
@test doc.user.clean  == true
@test doc.user.format == Lapidary.Formats.Markdown

@test doc.internal.assets == normpath(joinpath(dirname(@__FILE__), "..", "assets"))

@test length(doc.internal.pages) == 3

let headers = doc.internal.headers
    @test Lapidary.Anchors.exists(headers, "Documentation")
    @test Lapidary.Anchors.exists(headers, "Documentation")
    @test Lapidary.Anchors.exists(headers, "Index-Page")
    @test Lapidary.Anchors.exists(headers, "Functions-Contents")
    @test Lapidary.Anchors.exists(headers, "Tutorial-Contents")
    @test Lapidary.Anchors.exists(headers, "Index")
    @test Lapidary.Anchors.exists(headers, "Tutorial")
    @test Lapidary.Anchors.exists(headers, "Function-Index")
    @test Lapidary.Anchors.exists(headers, "Functions")
    @test Lapidary.Anchors.isunique(headers, "Functions")
    @test Lapidary.Anchors.isunique(headers, "Functions", joinpath("build", "lib", "functions.md"))
    let name = "Foo", path = joinpath("build", "lib", "functions.md")
        @test Lapidary.Anchors.exists(headers, name, path)
        @test !Lapidary.Anchors.isunique(headers, name)
        @test !Lapidary.Anchors.isunique(headers, name, path)
        @test length(headers.map[name][path]) == 4
    end
end

@test length(doc.internal.objects) == 7

# Lapidary package docs:

const lapidary_root = Pkg.dir("Lapidary", "docs")

doc = makedocs(
    debug   = true,
    root    = lapidary_root,
    modules = Lapidary,
    clean   = false,
)

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

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

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

    @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 doc.user.root   == lapidary_root
@test doc.user.source == "src"
@test doc.user.build  == "build"
@test doc.user.clean  == false

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

end

include(Pkg.dir("Lapidary", "docs", "make.jl"))

<MSG> Rename package to Documenter.jl

Fixes #1.

<DFF> @@ -24,7 +24,7 @@ end
 
 module Tests
 
-using Lapidary
+using Documenter
 using Base.Test
 using Compat
 
@@ -35,23 +35,23 @@ module UnitTests
 
 type T end
 
-"Lapidary unit tests."
+"Documenter unit tests."
 Base.length(::T) = 1
 
 end
 
 let doc = @doc(length)
-    a = Lapidary.Utilities.filterdocs(doc, Set{Module}())
-    b = Lapidary.Utilities.filterdocs(doc, Set{Module}([UnitTests]))
-    c = Lapidary.Utilities.filterdocs(doc, Set{Module}([Base]))
-    d = Lapidary.Utilities.filterdocs(doc, Set{Module}([Tests]))
+    a = Documenter.Utilities.filterdocs(doc, Set{Module}())
+    b = Documenter.Utilities.filterdocs(doc, Set{Module}([UnitTests]))
+    c = Documenter.Utilities.filterdocs(doc, Set{Module}([Base]))
+    d = Documenter.Utilities.filterdocs(doc, Set{Module}([Tests]))
 
     @test !isnull(a)
     @test get(a) === doc
     @test !isnull(b)
-    @test contains(stringmime("text/plain", get(b)), "Lapidary unit tests.")
+    @test contains(stringmime("text/plain", get(b)), "Documenter unit tests.")
     @test !isnull(c)
-    @test !contains(stringmime("text/plain", get(c)), "Lapidary unit tests.")
+    @test !contains(stringmime("text/plain", get(c)), "Documenter unit tests.")
     @test isnull(d)
 end
 
@@ -73,7 +73,7 @@ doc = makedocs(
 # tests
 # =====
 
-@test isa(doc, Lapidary.Documents.Document)
+@test isa(doc, Documenter.Documents.Document)
 
 let build_dir  = joinpath(example_root, "build"),
     source_dir = joinpath(example_root, "src")
@@ -85,7 +85,7 @@ let build_dir  = joinpath(example_root, "build"),
 
     @test isfile(joinpath(build_dir, "index.md"))
     @test isfile(joinpath(build_dir, "assets", "mathjaxhelper.js"))
-    @test isfile(joinpath(build_dir, "assets", "Lapidary.css"))
+    @test isfile(joinpath(build_dir, "assets", "Documenter.css"))
     @test isfile(joinpath(build_dir, "assets", "custom.css"))
     @test isfile(joinpath(build_dir, "lib", "functions.md"))
     @test isfile(joinpath(build_dir, "man", "tutorial.md"))
@@ -101,49 +101,49 @@ end
 @test doc.user.source == "src"
 @test doc.user.build  == "build"
 @test doc.user.clean  == true
-@test doc.user.format == Lapidary.Formats.Markdown
+@test doc.user.format == Documenter.Formats.Markdown
 
 @test doc.internal.assets == normpath(joinpath(dirname(@__FILE__), "..", "assets"))
 
 @test length(doc.internal.pages) == 3
 
 let headers = doc.internal.headers
-    @test Lapidary.Anchors.exists(headers, "Documentation")
-    @test Lapidary.Anchors.exists(headers, "Documentation")
-    @test Lapidary.Anchors.exists(headers, "Index-Page")
-    @test Lapidary.Anchors.exists(headers, "Functions-Contents")
-    @test Lapidary.Anchors.exists(headers, "Tutorial-Contents")
-    @test Lapidary.Anchors.exists(headers, "Index")
-    @test Lapidary.Anchors.exists(headers, "Tutorial")
-    @test Lapidary.Anchors.exists(headers, "Function-Index")
-    @test Lapidary.Anchors.exists(headers, "Functions")
-    @test Lapidary.Anchors.isunique(headers, "Functions")
-    @test Lapidary.Anchors.isunique(headers, "Functions", joinpath("build", "lib", "functions.md"))
+    @test Documenter.Anchors.exists(headers, "Documentation")
+    @test Documenter.Anchors.exists(headers, "Documentation")
+    @test Documenter.Anchors.exists(headers, "Index-Page")
+    @test Documenter.Anchors.exists(headers, "Functions-Contents")
+    @test Documenter.Anchors.exists(headers, "Tutorial-Contents")
+    @test Documenter.Anchors.exists(headers, "Index")
+    @test Documenter.Anchors.exists(headers, "Tutorial")
+    @test Documenter.Anchors.exists(headers, "Function-Index")
+    @test Documenter.Anchors.exists(headers, "Functions")
+    @test Documenter.Anchors.isunique(headers, "Functions")
+    @test Documenter.Anchors.isunique(headers, "Functions", joinpath("build", "lib", "functions.md"))
     let name = "Foo", path = joinpath("build", "lib", "functions.md")
-        @test Lapidary.Anchors.exists(headers, name, path)
-        @test !Lapidary.Anchors.isunique(headers, name)
-        @test !Lapidary.Anchors.isunique(headers, name, path)
+        @test Documenter.Anchors.exists(headers, name, path)
+        @test !Documenter.Anchors.isunique(headers, name)
+        @test !Documenter.Anchors.isunique(headers, name, path)
         @test length(headers.map[name][path]) == 4
     end
 end
 
 @test length(doc.internal.objects) == 7
 
-# Lapidary package docs:
+# Documenter package docs:
 
-const lapidary_root = Pkg.dir("Lapidary", "docs")
+const Documenter_root = Pkg.dir("Documenter", "docs")
 
 doc = makedocs(
     debug   = true,
-    root    = lapidary_root,
-    modules = Lapidary,
+    root    = Documenter_root,
+    modules = Documenter,
     clean   = false,
 )
 
-@test isa(doc, Lapidary.Documents.Document)
+@test isa(doc, Documenter.Documents.Document)
 
-let build_dir  = joinpath(lapidary_root, "build"),
-    source_dir = joinpath(lapidary_root, "src")
+let build_dir  = joinpath(Documenter_root, "build"),
+    source_dir = joinpath(Documenter_root, "src")
 
     @test isdir(build_dir)
     @test isdir(joinpath(build_dir, "assets"))
@@ -152,16 +152,16 @@ let build_dir  = joinpath(lapidary_root, "build"),
 
     @test isfile(joinpath(build_dir, "index.md"))
     @test isfile(joinpath(build_dir, "assets", "mathjaxhelper.js"))
-    @test isfile(joinpath(build_dir, "assets", "Lapidary.css"))
+    @test isfile(joinpath(build_dir, "assets", "Documenter.css"))
 end
 
-@test doc.user.root   == lapidary_root
+@test doc.user.root   == Documenter_root
 @test doc.user.source == "src"
 @test doc.user.build  == "build"
 @test doc.user.clean  == false
 
-rm(joinpath(lapidary_root, "build"); recursive = true)
+rm(joinpath(Documenter_root, "build"); recursive = true)
 
 end
 
-include(Pkg.dir("Lapidary", "docs", "make.jl"))
+include(Pkg.dir("Documenter", "docs", "make.jl"))

Rename package to Documenter.jl