Skip to content

Commit 1739ac3

Browse files
authored
Make it possible to document sum types (#63)
1 parent 1f5b1cf commit 1739ac3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/sum_type.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ function generate_sum_struct_expr(T, T_abstract, T_name, T_params, T_params_cons
228228

229229
sum_struct_def = Expr(:struct, false, Expr(:(<:), T_full, T_abstract),
230230
Expr(:block, :(data :: ($Union){$(store_types...)}), ))
231+
sum_struct_def = :(Base.@__doc__ $sum_struct_def)
231232

232233
enumerate_constructors = collect(enumerate(constructors))
233234

test/runtests.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ using Test, SumTypes
22

33

44
abstract type AbstractFoo end
5+
6+
"""
7+
This is a Foo.
8+
"""
59
@sum_type Foo <: AbstractFoo begin
610
Bar(::Int)
711
Baz(x)
@@ -33,7 +37,8 @@ end
3337
@test Bar(1) isa Foo
3438
@test Bar(1) isa AbstractFoo
3539
@test_throws MethodError Foo(1)
36-
40+
@test string(@doc Foo) == "This is a Foo.\n"
41+
3742
function either_test(x::Either)
3843
let x::Either{Int, Int} = x
3944
@cases x begin

0 commit comments

Comments
 (0)