Skip to content

Commit

Permalink
Merge pull request #17242 from MichaelHatherly/mh/docstr-metadata-cha…
Browse files Browse the repository at this point in the history
…nges

Don't store source expressions in docstrings
  • Loading branch information
vtjnash committed Jul 2, 2016
2 parents e1a9006 + 5585919 commit ef56ff8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 2 additions & 3 deletions base/docs/Docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ function doc!(b::Binding, str::DocStr, sig::ANY = Union{})
push!(m.order, sig)
end
m.docs[sig] = str
str.data[:binding] = b
str.data[:typesig] = sig
return b
end

Expand Down Expand Up @@ -436,16 +438,13 @@ Build a `Dict` expression containing metadata captured from the expression `expr
Fields that may be included in the returned `Dict`:
- `:source`: Source code for the given `expr`.
- `:path`: String representing the file where `expr` is defined.
- `:linenumber`: Linenumber where `expr` is defined.
- `:module`: Module where the docstring is defined.
- `:fields`: `Dict` of all field docs found in `expr`. Only for concrete types.
"""
function metadata(expr)
args = []
# Source code for the object being documented.
push!(args, :($(Pair)(:source, $(quot(expr)))))
# Filename and linenumber of the docstring.
push!(args, :($(Pair)(:path, $(Base).@__FILE__)))
push!(args, :($(Pair)(:linenumber, $(unsafe_load(cglobal(:jl_lineno, Cint))))))
Expand Down
4 changes: 4 additions & 0 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ let f = @var(DocsTest.f)
md = meta(DocsTest)[f]
@test docstrings_equal(md.docs[Tuple{Any}], doc"f-1")
@test docstrings_equal(md.docs[Tuple{Any,Any}], doc"f-2")
@test md.docs[Tuple{Any}].data[:binding] === f
@test md.docs[Tuple{Any}].data[:typesig] === Tuple{Any}
@test md.docs[Tuple{Any,Any}].data[:binding] === f
@test md.docs[Tuple{Any,Any}].data[:typesig] === Tuple{Any,Any}
end

let s = @var(DocsTest.s)
Expand Down

0 comments on commit ef56ff8

Please sign in to comment.