Skip to content

Commit 0758d01

Browse files
authored
Merge pull request #99 from TuringLang/tor/doc-string-for-model
2 parents 0ec01ae + acb21a4 commit 0758d01

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/compiler.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ function build_output(model_info)
352352
$generator($(args...)) = $(DynamicPPL.Model)($evaluator, $args_nt, $model_gen_constructor)
353353
$(generator_kw_form...)
354354

355-
$model_gen = $model_gen_constructor
355+
$(Base).@__doc__ $model_gen = $model_gen_constructor
356356
end
357357
end
358358

test/compiler.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,19 @@ end
615615

616616
@test lp_w_threads lp_wo_threads
617617
end
618+
619+
@testset "docstring" begin
620+
"This is a test"
621+
@model function demo(x)
622+
m ~ Normal()
623+
x ~ Normal(m, 1)
624+
end
625+
626+
s = @doc(demo)
627+
@test string(s) == "This is a test\n"
628+
629+
# Verify that adding docstring didn't completely break execution of model
630+
m = demo(0.)
631+
@test m() isa Float64
632+
end
618633
end

0 commit comments

Comments
 (0)