From 19e0a354e1e8828686ed80f602457694dabe68b7 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Sat, 25 Aug 2018 17:45:59 +0200 Subject: [PATCH] fix doccing call overload without named argument (#28875) (cherry picked from commit 7e1f739d3c628e387cc5827a35ca086fc17006c6) --- base/docs/Docs.jl | 2 +- test/docs.jl | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/base/docs/Docs.jl b/base/docs/Docs.jl index c9de490bcb67f..d409eea9a6ca8 100644 --- a/base/docs/Docs.jl +++ b/base/docs/Docs.jl @@ -281,7 +281,7 @@ function astname(x::Expr, ismacro::Bool) ismacro ? macroname(x) : x # Call overloading, e.g. `(a::A)(b) = b` or `function (a::A)(b) b end` should document `A(b)` elseif (isexpr(x, :function) || isexpr(x, :(=))) && isexpr(x.args[1], :call) && isexpr(x.args[1].args[1], :(::)) - return astname(x.args[1].args[1].args[2], ismacro) + return astname(x.args[1].args[1].args[end], ismacro) else n = isexpr(x, (:module, :struct)) ? 2 : 1 astname(x.args[n], ismacro) diff --git a/test/docs.jl b/test/docs.jl index 3a925d65a4334..c6cbb3847ae28 100644 --- a/test/docs.jl +++ b/test/docs.jl @@ -1121,6 +1121,13 @@ struct A_20087 end @test docstrings_equal(@doc(A_20087()), doc"a") +struct B_20087 end + +"""b""" +(::B_20087)() = a + +@test docstrings_equal(@doc(B_20087()), doc"b") + # issue #27832 _last_atdoc = Core.atdoc