diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index f4db13f828ed63..4d764ca5806c4f 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -161,11 +161,13 @@ end function docstr(binding::Binding, typesig = Union{}) @nospecialize typesig for m in modules - dict = meta(m) - if haskey(dict, binding) - docs = dict[binding].docs - if haskey(docs, typesig) - return docs[typesig] + if isdefined(m, META) && getfield(m, META) !== nothing + dict = meta(m) + if haskey(dict, binding) + docs = dict[binding].docs + if haskey(docs, typesig) + return docs[typesig] + end end end end diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 24bbfc2e6282d4..617e0b8f6bfd35 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -164,12 +164,14 @@ function doc(binding::Binding, sig::Type = Union{}) results, groups = DocStr[], MultiDoc[] # Lookup `binding` and `sig` for matches in all modules of the docsystem. for mod in modules - dict = meta(mod) - if haskey(dict, binding) - multidoc = dict[binding] - push!(groups, multidoc) - for msig in multidoc.order - sig <: msig && push!(results, multidoc.docs[msig]) + if isdefined(mod, Docs.META) && getfield(mod, Docs.META) !== nothing + dict = meta(mod) + if haskey(dict, binding) + multidoc = dict[binding] + push!(groups, multidoc) + for msig in multidoc.order + sig <: msig && push!(results, multidoc.docs[msig]) + end end end end @@ -565,14 +567,16 @@ Return documentation for a particular `field` of a type if it exists. """ function fielddoc(binding::Binding, field::Symbol) for mod in modules - dict = meta(mod) - if haskey(dict, binding) - multidoc = dict[binding] - if haskey(multidoc.docs, Union{}) - fields = multidoc.docs[Union{}].data[:fields] - if haskey(fields, field) - doc = fields[field] - return isa(doc, Markdown.MD) ? doc : Markdown.parse(doc) + if isdefined(mod, Docs.META) && getfield(mod, Docs.META) !== nothing + dict = meta(mod) + if haskey(dict, binding) + multidoc = dict[binding] + if haskey(multidoc.docs, Union{}) + fields = multidoc.docs[Union{}].data[:fields] + if haskey(fields, field) + doc = fields[field] + return isa(doc, Markdown.MD) ? doc : Markdown.parse(doc) + end end end end @@ -834,8 +838,10 @@ function apropos(io::IO, needle::Regex) for mod in modules # Module doc might be in README.md instead of the META dict docsearch(doc(mod), needle) && println(io, mod) - for (k, v) in meta(mod) - docsearch(v, needle) && println(io, k) + if isdefined(mod, Docs.META) && getfield(mod, Docs.META) !== nothing + for (k, v) in meta(mod) + docsearch(v, needle) && println(io, k) + end end end end