Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't skip modules during docsearch #13070

Merged
merged 1 commit into from
Sep 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,26 +238,29 @@ doc(f::Function) = doc(f, Tuple)

function doc(f::Function, sig::Type)
isgeneric(f) && isempty(methods(f,sig)) && return nothing
results, funcdocs = [], []
for mod in modules
if (haskey(meta(mod),f) && isa(meta(mod)[f],FuncDoc))
if (haskey(meta(mod), f) && isa(meta(mod)[f], FuncDoc))
fd = meta(mod)[f]
results = []
push!(funcdocs, fd)
for msig in fd.order
# try to find specific matching method signatures
if sig <: msig
push!(results, (msig,fd.meta[msig]))
push!(results, (msig, fd.meta[msig]))
end
end
# if all method signatures are Union{} ( ⊥ ), concat all docstrings
if isempty(results)
return catdoc([fd.meta[msig] for msig in reverse(fd.order)]...)
else
sort!(results, lt=(a,b)->type_morespecific(first(a),first(b)))
return catdoc([last(r) for r in results]...)
end
end
end
return nothing
# if all method signatures are Union{} ( ⊥ ), concat all docstrings
if isempty(results)
for fd in funcdocs
append!(results, [fd.meta[msig] for msig in reverse(fd.order)])
end
else
sort!(results, lt = (a, b) -> type_morespecific(first(a), first(b)))
results = [last(r) for r in results]
end
catdoc(results...)
end
doc(f::Function,args::Any...) = doc(f, Tuple{args...})

Expand Down
42 changes: 42 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,48 @@ f12593_2() = 1
@test contains(sprint(apropos, r"ind(exes|ices)"), "eachindex")
@test contains(sprint(apropos, "print"), "Profile.print")

# Issue #13068.

module I13068

module A

export foo

"""
foo from A
"""
foo(::Int) = 1

end

module B

import ..A: foo

export foo

"""
foo from B
"""
foo(::Float64) = 2

end

end

@test docstrings_equal(
@doc(I13068.A.foo),
doc"""
foo from A

foo from B
"""
)
@test docstrings_equal(Docs.doc(I13068.A.foo, Tuple{Int}), doc"foo from A")
@test docstrings_equal(Docs.doc(I13068.A.foo, Tuple{Float64}), doc"foo from B")
@test Docs.doc(I13068.A.foo, Tuple{Char}) === nothing

# Undocumented DataType Summaries.

module Undocumented
Expand Down