From db7c8feaabd58bb151a643be6ad4c8f9985dc4b3 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 1 Jul 2020 04:20:30 -0500 Subject: [PATCH 1/2] Add docstring support --- src/Classes.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Classes.jl b/src/Classes.jl index 47ee2b5..da73858 100644 --- a/src/Classes.jl +++ b/src/Classes.jl @@ -279,7 +279,7 @@ function _defclass(clsname, supercls, mutable, wheres, exprs) result = quote abstract type $abs_class <: $abs_super end - $struct_def + Base.@__doc__($struct_def) $(outer...) Classes.superclass(::Type{$clsname}) = $supercls $clsname # return the struct type From 3a027ac715c474914126bd94a84debdfd9a3774b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 1 Jul 2020 04:51:40 -0500 Subject: [PATCH 2/2] Add docstring test --- test/test_classes.jl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/test_classes.jl b/test/test_classes.jl index 2d5a116..e752467 100644 --- a/test/test_classes.jl +++ b/test/test_classes.jl @@ -6,6 +6,11 @@ using Classes @test isclass(AbstractClass) == false # not concrete @test isclass(Int) == false # not <: AbstractClass +""" + Foo + +A test class +""" @class Foo begin foo::Int @@ -20,6 +25,10 @@ end @test classof(AbstractFoo) == Foo @test classof(Foo) == Foo +@test string(@doc(Foo)) == """Foo + +A test class +""" @test superclass(Foo) == Class @test_throws Exception superclass(AbstractFoo) @@ -157,4 +166,4 @@ obj = AbstractLog{Float64}([1. 2.; 3. 4.]) # function (ParameterizedSub{T3, T4}(one::T1, two::T2, x::Float64, y::Float64; )::Any) where {T3 <: TupleHolder, T4 <: TupleHolder} # #= /Users/rjp/.julia/packages/MacroTools/4AjBS/src/utils.jl:302 =# # new{T3, T4}(one, two, x, y) -# end \ No newline at end of file +# end