Use nameof for function names instead of Symbol

It's the more correct option, and needed for cases such as Returns(4).

We also can't assume that the function summary has a space in it for
some function (again, like Returns(4)).
This commit is contained in:
TEC 2024-06-03 16:14:20 +08:00
parent a8512a6a6d
commit d42e2bc97e
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 3 additions and 2 deletions

View File

@ -1,8 +1,9 @@
function about(io::IO, fn::Function)
source = Main.InteractiveUtils.which(parentmodule(fn), Symbol(fn))
source = Main.InteractiveUtils.which(parentmodule(fn), nameof(fn))
methodmodules = getproperty.(methods(fn).ms, :module)
others = setdiff(methodmodules, [source])
fn_name, fn_extra = split(Base.summary(fn), ' ', limit=2)
fn_smry = split(Base.summary(fn), ' ', limit=2)
fn_name, fn_extra = if length(fn_smry) == 1 (fn_smry[1], "") else fn_smry end
print(io, S"{julia_funcall:$fn_name} $fn_extra\n Defined in {about_module:$source}")
if length(others) > 0
print(io, S"{shadow:({emphasis:$(sum(Ref(source) .=== methodmodules))})} extended in ")