<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")

    # 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)
    @test_throws ArgumentError makedocs(sitename="", HTML())

    # Running doctest() on our own manual
    @info "doctest() Documenter's manual"
    @quietly include("manual.jl")
end
@test Documenter.Utilities.issubmodule(UnitTests, UnitTests.SubModule) === false


# Integration tests for module api.

# Mock package docs:

<MSG> Merge pull request #96 from JuliaDocs/mh/docsystem-interface

Cross-version compatible docsystem interface
<DFF> @@ -120,6 +120,89 @@ end
 @test Documenter.Utilities.issubmodule(UnitTests, UnitTests.SubModule) === false
 
 
+# DocSystem unit tests.
+
+import Documenter: DocSystem
+
+## Bindings.
+
+@test_throws ArgumentError DocSystem.binding(9000)
+let b = Docs.Binding(current_module(), :DocSystem)
+    @test DocSystem.binding(b) == b
+end
+let b = DocSystem.binding(Documenter.Documents.Document)
+    @test b.mod === Documenter.Documents
+    @test b.var === :Document
+end
+let b = DocSystem.binding(Documenter)
+    @test b.mod === Main
+    @test b.var === :Documenter
+end
+let b = DocSystem.binding(:Main)
+    # @test b.mod === Main
+    @test b.var === :Main
+end
+let b = DocSystem.binding(DocSystem.binding)
+    @test b.mod === DocSystem
+    @test b.var === :binding
+end
+let b = DocSystem.binding(getfield(Core.Intrinsics, :ccall))
+    @test b.mod === Core.Intrinsics
+    @test b.var === :ccall
+end
+let b = DocSystem.binding(Documenter, :Documenter)
+    @test b.mod === Main
+    @test b.var === :Documenter
+end
+
+## `MultiDoc` object.
+
+@test isdefined(DocSystem, :MultiDoc)
+@test fieldnames(DocSystem.MultiDoc) == [:order, :docs]
+
+## `DocStr` object.
+
+@test isdefined(DocSystem, :DocStr)
+@test fieldnames(DocSystem.DocStr) == [:text, :object, :data]
+
+## `getdocs`.
+
+const alias_of_getdocs = DocSystem.getdocs
+
+let b   = DocSystem.binding(DocSystem, :getdocs),
+    d_0 = DocSystem.getdocs(b, Tuple{}),
+    d_1 = DocSystem.getdocs(b),
+    d_2 = DocSystem.getdocs(b, Union{Tuple{ANY}, Tuple{ANY, Type}}; compare = (==)),
+    d_3 = DocSystem.getdocs(b; modules = Module[]),
+    d_4 = DocSystem.getdocs(DocSystem.binding(current_module(), :alias_of_getdocs)),
+    d_5 = DocSystem.getdocs(DocSystem.binding(current_module(), :alias_of_getdocs); aliases = false)
+
+    @test length(d_0) == 0
+    @test length(d_1) == 2
+    @test length(d_2) == 1
+    @test length(d_3) == 0
+    @test length(d_4) == 2
+    @test length(d_5) == 0
+
+    @test d_1[1].data[:binding] == b
+    @test d_1[2].data[:binding] == b
+    @test d_1[1].data[:typesig] == Union{Tuple{Docs.Binding}, Tuple{Docs.Binding, Type}}
+    @test d_1[2].data[:typesig] == Union{Tuple{ANY}, Tuple{ANY, Type}}
+    @test d_1[1].data[:module]  == DocSystem
+    @test d_1[2].data[:module]  == DocSystem
+    @test d_1[1].data[:source]  != quote end
+    @test d_1[2].data[:source]  != quote end
+
+    @test d_2[1].data[:binding] == b
+    @test d_2[1].data[:typesig] == Union{Tuple{ANY}, Tuple{ANY, Type}}
+    @test d_2[1].data[:module]  == DocSystem
+    @test d_2[1].data[:source]  != quote end
+
+    @test d_1 == d_4
+    @test d_1 != d_5
+end
+
+
 # Integration tests for module api.
 
 # Mock package docs:

Merge pull request #96 from JuliaDocs/mh/docsystem-interface