Skip to content

Commit

Permalink
Fix Utilities.submodules for module aliases (#852)
Browse files Browse the repository at this point in the history
Fix #851, module aliases confuse Utilities.submodules.

(cherry picked from commit fdddf00)
  • Loading branch information
tkoolen authored and mortenpi committed Oct 14, 2018
1 parent af989ce commit f75cf92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utilities/Utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function submodules(root::Module, seen = Set{Module}())
for name in Compat.names(root, all=true)
if Base.isidentifier(name) && isdefined(root, name) && !isdeprecated(root, name)
object = getfield(root, name)
if isa(object, Module) && !(object in seen)
if isa(object, Module) && !(object in seen) && parentmodule(object::Module) == root
submodules(object, seen)
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ export OuterModule
end
end

module ExternalModule end
module ModuleWithAliases
using ..ExternalModule
Y = ExternalModule
module A
module B
const X = Main
end
end
end

@testset "Utilities" begin
let doc = @doc(length)
a = Documenter.Utilities.filterdocs(doc, Set{Module}())
Expand Down Expand Up @@ -69,6 +80,7 @@ end
@test OuterModule in Documenter.Utilities.submodules(OuterModule)
@test OuterModule.InnerModule in Documenter.Utilities.submodules(OuterModule)
@test length(Documenter.Utilities.submodules(OuterModule)) == 2
@test Documenter.Utilities.submodules(ModuleWithAliases) == Set([ModuleWithAliases, ModuleWithAliases.A, ModuleWithAliases.A.B])

@test Documenter.Utilities.isabsurl("file.md") === false
@test Documenter.Utilities.isabsurl("../file.md") === false
Expand Down

0 comments on commit f75cf92

Please sign in to comment.