Skip to content

Commit

Permalink
Merge pull request #12 from aminya/docstring
Browse files Browse the repository at this point in the history
Add docstring support for a class
  • Loading branch information
rjplevin authored Jul 1, 2020
2 parents e6dcc51 + 3a027ac commit 7a0e805
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Classes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion test/test_classes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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
# end

0 comments on commit 7a0e805

Please sign in to comment.