Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docstring support for a class #12

Merged
merged 2 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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