From 70c76d1fae4fb7b09d74544e5391a1168ec4c861 Mon Sep 17 00:00:00 2001 From: Frames White Date: Tue, 8 Oct 2024 18:37:57 +0800 Subject: [PATCH 1/2] Define line numbers for functions defined using required macro --- src/utils.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index a41161f..87861e0 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -16,11 +16,15 @@ macro required(sig) model_arg = model_arg_ex.args[1] model_arg isa Symbol || error("malformed signature definition") + # magic to use the call-site line numbers so methods includes them + def = Expr(:(=), call_ex, Expr(:block, __source__, + :($unimplemented(typeof($model_arg), $(Meta.quot(name)))) + )) return esc( quote - Base.@__doc__ $call_ex = $unimplemented(typeof($model_arg), $(Meta.quot(name))) + $def push!(REQUIRED_ACCESSORS, $name) - $name + Base.@__doc__ $name end, ) end From 6b8af6833ffb48ef765b8734d33e1fb1795bdcbb Mon Sep 17 00:00:00 2001 From: exaexa Date: Tue, 8 Oct 2024 10:42:34 +0000 Subject: [PATCH 2/2] automatic formatting triggered by @exaexa on PR #28 --- src/utils.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 87861e0..5163c3b 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -17,16 +17,16 @@ macro required(sig) model_arg isa Symbol || error("malformed signature definition") # magic to use the call-site line numbers so methods includes them - def = Expr(:(=), call_ex, Expr(:block, __source__, - :($unimplemented(typeof($model_arg), $(Meta.quot(name)))) - )) - return esc( - quote - $def - push!(REQUIRED_ACCESSORS, $name) - Base.@__doc__ $name - end, + def = Expr( + :(=), + call_ex, + Expr(:block, __source__, :($unimplemented(typeof($model_arg), $(Meta.quot(name))))), ) + return esc(quote + $def + push!(REQUIRED_ACCESSORS, $name) + Base.@__doc__ $name + end) end unimplemented(t::Type, x::Symbol) =