Skip to content

Commit cd4de55

Browse files
Fix REPL help mode to show help for using/import (#34757)
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]>
1 parent 48f942b commit cd4de55

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

stdlib/REPL/src/docview.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ function _helpmode(io::IO, line::AbstractString)
3737
# Docs for keywords must be treated separately since trying to parse a single
3838
# keyword such as `function` would throw a parse error due to the missing `end`.
3939
Symbol(line)
40+
elseif isexpr(x, (:using, :import))
41+
x.head
4042
else
4143
# Retrieving docs for macros requires us to make a distinction between the text
4244
# `@macroname` and `@macroname()`. These both parse the same, but are used by

stdlib/REPL/test/repl.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,11 @@ for (line, expr) in Pair[
10271027
"while " => :while, # keyword, trailing spaces should be stripped.
10281028
"0" => 0,
10291029
"\"...\"" => "...",
1030-
"r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "...")
1030+
"r\"...\"" => Expr(:macrocall, Symbol("@r_str"), LineNumberNode(1, :none), "..."),
1031+
"using Foo" => :using,
1032+
"import Foo" => :import,
10311033
]
1032-
#@test REPL._helpmode(line) == Expr(:macrocall, Expr(:., Expr(:., :Base, QuoteNode(:Docs)), QuoteNode(Symbol("@repl"))), LineNumberNode(119, doc_util_path), stdout, expr)
1034+
@test REPL._helpmode(line).args[4] == expr
10331035
buf = IOBuffer()
10341036
@test Base.eval(REPL._helpmode(buf, line)) isa Union{Markdown.MD,Nothing}
10351037
end

test/docs.jl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,6 @@ let x = Binding(Main, :⊕)
982982
@test Meta.parse(string(x)) == :()
983983
end
984984

985-
doc_util_path = Symbol(joinpath("docs", "utils.jl"))
986-
987985
@test sprint(repl_latex, "") == "\"\" can be typed by \\sqrt<tab>\n\n"
988986
@test sprint(repl_latex, "x̂₂") == "\"x̂₂\" can be typed by x\\hat<tab>\\_2<tab>\n\n"
989987

0 commit comments

Comments
 (0)