Skip to content

Commit

Permalink
Print the value's type help for undocumented bindings
Browse files Browse the repository at this point in the history
exclude macros as this is just exposing their internals

closes #13002
  • Loading branch information
jakebolewski committed Sep 8, 2015
1 parent 1c221a1 commit 8f8276e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
12 changes: 11 additions & 1 deletion base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,17 @@ end

function doc(b::Binding)
d = invoke(doc, Tuple{Any}, b)
d == nothing ? doc(getfield(b.mod, b.var)) : d
if d == nothing
v = getfield(b.mod,b.var)
d = doc(v)
if d == nothing
# check to see if the binding var is not a macro
if !startswith(string(b.var),'@')
d = typesummary(typeof(v))
end
end
end
return d
end

# Function / Method support
Expand Down
14 changes: 14 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ import .Inner.@m
"Inner.@m"
:@m

type Foo
x
end

# value with no docs
const val = Foo(1.0)

end

import Base.Docs: meta
Expand Down Expand Up @@ -209,6 +216,13 @@ let fields = meta(DocsTest)[DocsTest.FieldDocs].fields
@test haskey(fields, :two) && fields[:two] == doc"two"
end

# test that when no docs exist, they fallback to
# the docs for the typeof(value)
let d1 = @doc(DocsTest.val)
d2 = @doc(DocsTest.Foo)
@test docstrings_equal(d1,d2)
end

# Issue #12700.
@test @doc(DocsTest.@m) == doc"Inner.@m"

Expand Down

0 comments on commit 8f8276e

Please sign in to comment.