diff --git a/src/sum_type.jl b/src/sum_type.jl index c72e948..bf85823 100644 --- a/src/sum_type.jl +++ b/src/sum_type.jl @@ -228,6 +228,7 @@ function generate_sum_struct_expr(T, T_abstract, T_name, T_params, T_params_cons sum_struct_def = Expr(:struct, false, Expr(:(<:), T_full, T_abstract), Expr(:block, :(data :: ($Union){$(store_types...)}), )) + sum_struct_def = :(Base.@__doc__ $sum_struct_def) enumerate_constructors = collect(enumerate(constructors)) diff --git a/test/runtests.jl b/test/runtests.jl index f96174f..b219ef4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,6 +2,10 @@ using Test, SumTypes abstract type AbstractFoo end + +""" +This is a Foo. +""" @sum_type Foo <: AbstractFoo begin Bar(::Int) Baz(x) @@ -33,7 +37,8 @@ end @test Bar(1) isa Foo @test Bar(1) isa AbstractFoo @test_throws MethodError Foo(1) - + @test string(@doc Foo) == "This is a Foo.\n" + function either_test(x::Either) let x::Either{Int, Int} = x @cases x begin