Skip to content

Commit

Permalink
fixup! Add support for default values to TYPEDSIGNATURES
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWrigley committed Sep 12, 2024
1 parent f1c9145 commit 1efecf6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,14 @@ function printmethod(buffer::IOBuffer, binding::Docs.Binding, func, method::Meth
formatted_kws = format_args(kws, NTuple{length(kws), Any}, print_types)
end

rt = Base.return_types(func, typesig)
can_print_rt = print_types && length(rt) >= 1 && rt[1] !== Nothing && rt[1] !== Union{}
rt = try
# We wrap this in a try-catch block because Base.return_types() is
# documented to fail on generated functions.
Base.return_types(func, typesig)
catch
nothing
end
can_print_rt = print_types && !isnothing(rt) && length(rt) >= 1 && rt[1] !== Nothing && rt[1] !== Union{}

return printmethod_format(buffer, string(binding.var), formatted_args, formatted_kws;
return_type = can_print_rt ? " -> $(rt[1])" : "")
Expand Down

0 comments on commit 1efecf6

Please sign in to comment.