Skip to content

Commit

Permalink
Fix REPL help mode to show help for using/import (#34757)
Browse files Browse the repository at this point in the history
Fix REPL help mode to show help for using/import for
:(using A)/:(import A) expressions, fixes #34713.


Co-authored-by: Shan Sikdar <[email protected]>
Co-authored-by: Fredrik Ekre <[email protected]>
  • Loading branch information
ssikdar1 and fredrikekre authored Feb 15, 2020
1 parent 48f942b commit cd4de55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function _helpmode(io::IO, line::AbstractString)
# Docs for keywords must be treated separately since trying to parse a single
# keyword such as `function` would throw a parse error due to the missing `end`.
Symbol(line)
elseif isexpr(x, (:using, :import))
x.head
else
# Retrieving docs for macros requires us to make a distinction between the text
# `@macroname` and `@macroname()`. These both parse the same, but are used by
Expand Down
6 changes: 4 additions & 2 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1027,9 +1027,11 @@ for (line, expr) in Pair[
"while " => :while, # keyword, trailing spaces should be stripped.
"0" => 0,
"\"...\"" => "...",
"r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "...")
"r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "..."),
"using Foo" => :using,
"import Foo" => :import,
]
#@test REPL._helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(119, doc_util_path), stdout, expr)
@test REPL._helpmode(line).args[4] == expr
buf = IOBuffer()
@test Base.eval(REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing}
end
Expand Down
2 changes: 0 additions & 2 deletions test/docs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,6 @@ let x = Binding(Main, :⊕)
@test Meta.parse(string(x)) == :()
end

doc_util_path = Symbol(joinpath("docs", "utils.jl"))

@test sprint(repl_latex, "") == "\"\" can be typed by \\sqrt<tab>\n\n"
@test sprint(repl_latex, "x̂₂") == "\"x̂₂\" can be typed by x\\hat<tab>\\_2<tab>\n\n"

Expand Down

0 comments on commit cd4de55

Please sign in to comment.