Skip to content

Commit

Permalink
get loaddocs to give line numbers when it fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed May 19, 2017
1 parent 73b8dcb commit 78881f1
Showing 1 changed file with 11 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 @@ -749,11 +749,21 @@ include("utils.jl")
# Swap out the bootstrap macro with the real one.
Core.atdoc!(docm)

macro local_hygiene(expr)
# removes `esc` Exprs relative to the module argument to expand
# and resolves everything else relative to this (Doc) module
# this allows us to get good errors and backtraces
# from calling docm (by not using macros),
# while also getting macro-expansion correct (by using the macro-expander)
return expr
end
function loaddocs(docs)
unescape = GlobalRef(Docs, Symbol("@local_hygiene"))
for (mod, ex, str, file, line) in docs
data = Dict(:path => string(file), :linenumber => line)
doc = docstr(str, data)
eval(mod, :(@doc($doc, $ex, false)))
docstring = eval(mod, Expr(:body, Expr(:return, Expr(:call, QuoteNode(docm), QuoteNode(doc), QuoteNode(ex), false)))) # expand the real @doc macro now (using a hack because macroexpand takes current-module as an implicit argument)
eval(mod, Expr(:macrocall, unescape, nothing, docstring))
end
empty!(docs)
end
Expand Down

0 comments on commit 78881f1

Please sign in to comment.