From b0bf3946b4a24bb39ed0a00215ee87df8c6811f9 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Thu, 19 Sep 2024 07:37:10 -0400 Subject: [PATCH] fix #52986, regression in `@doc` of macro without REPL loaded (#55795) fix #52986 (cherry picked from commit 4045e7baa496b2f14dfe562dbe3700d0c91006ff) --- base/docs/Docs.jl | 4 ++++ test/docs.jl | 1 + 2 files changed, 5 insertions(+) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index 6be96cd8b1799..21d781035081c 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -519,6 +519,10 @@ function _doc(binding::Binding, sig::Type = Union{}) for msig in multidoc.order sig <: msig && return multidoc.docs[msig] end + # if no matching signatures, return first + if !isempty(multidoc.docs) + return first(values(multidoc.docs)) + end end end return nothing diff --git a/test/docs.jl b/test/docs.jl index 8e6023b6b385d..b1281f9ad0612 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -4,6 +4,7 @@ import Base.Docs: meta, @var, DocStr, parsedoc # check that @doc can work before REPL is loaded @test !startswith(read(`$(Base.julia_cmd()) -E '@doc sin'`, String), "nothing") +@test !startswith(read(`$(Base.julia_cmd()) -E '@doc @time'`, String), "nothing") using Markdown using REPL