Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stdlib/REPL/src/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ function _repl(x, brief::Bool=true, mod::Module=Main, internal_accesses::Union{N
docs = esc(:(@doc $x))
docs = if isfield(x)
quote
if isa($(esc(x.args[1])), DataType)
if $(esc(x.args[1])) isa Type
fielddoc($(esc(x.args[1])), $(esc(x.args[2])))
else
$docs
Expand Down Expand Up @@ -684,6 +684,7 @@ function fielddoc(binding::Binding, field::Symbol)
end

# As with the additional `doc` methods, this converts an object to a `Binding` first.
fielddoc(obj::UnionAll, field::Symbol) = fielddoc(Base.unwrap_unionall(obj), field)
fielddoc(object, field::Symbol) = fielddoc(aliasof(object, typeof(object)), field)


Expand Down
18 changes: 18 additions & 0 deletions stdlib/REPL/test/docview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,24 @@ end
@test endswith(get_help_standard("Int.not_a_field"), "`$Int` has no fields.\n")
end

@testset "Parametric struct field help (#59524)" begin
"NonParametricStruct docstring"
struct NonParametricStruct
"field_x docstring"
field_x::Float64
end

"ParametricStruct docstring"
struct ParametricStruct{T<:Real}
"field_y docstring"
field_y::T
end

@test occursin("field_x docstring", get_help_standard("NonParametricStruct.field_x"))
@test occursin("field_y docstring", get_help_standard("ParametricStruct.field_y"))
@test endswith(get_help_standard("ParametricStruct.not_a_field"), "ParametricStruct` has field `field_y`.\n")
end

module InternalWarningsTests

module A
Expand Down