diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index c808aa4057..a6b31843d1 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -1555,7 +1555,7 @@ function component_post_processing(expr, isconnector) args = sig.args[2:end] quote - function $fname($(args...)) + $Base.@__doc__ function $fname($(args...)) # we need to create a closure to escape explicit return in `body`. res = (() -> $body)() if $isdefined(res, :gui_metadata) && $getfield(res, :gui_metadata) === nothing diff --git a/test/components.jl b/test/components.jl index d4bedb8eb7..d9233558c3 100644 --- a/test/components.jl +++ b/test/components.jl @@ -298,3 +298,25 @@ rc_eqs = [connect(capacitor.n, resistor.p) sys = structural_simplify(rc_model) prob = ODEProblem(sys, u0, (0, 10.0)) sol = solve(prob, Tsit5()) + +@testset "docstrings (#1155)" begin + """ + Hey there, Pin1! + """ + @connector function Pin1(; name) + @variables t + sts = @variables v(t)=1.0 i(t)=1.0 + ODESystem(Equation[], t, sts, []; name = name) + end + @test string(Base.doc(Pin1)) == "Hey there, Pin1!\n" + + """ + Hey there, Pin2! + """ + @component function Pin2(; name) + @variables t + sts = @variables v(t)=1.0 i(t)=1.0 + ODESystem(Equation[], t, sts, []; name = name) + end + @test string(Base.doc(Pin2)) == "Hey there, Pin2!\n" +end