Skip to content

Commit

Permalink
Merge pull request #99 from TuringLang/tor/doc-string-for-model
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored May 3, 2020
2 parents 0ec01ae + acb21a4 commit 0758d01
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ function build_output(model_info)
$generator($(args...)) = $(DynamicPPL.Model)($evaluator, $args_nt, $model_gen_constructor)
$(generator_kw_form...)

$model_gen = $model_gen_constructor
$(Base).@__doc__ $model_gen = $model_gen_constructor
end
end

Expand Down
15 changes: 15 additions & 0 deletions test/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,19 @@ end

@test lp_w_threads lp_wo_threads
end

@testset "docstring" begin
"This is a test"
@model function demo(x)
m ~ Normal()
x ~ Normal(m, 1)
end

s = @doc(demo)
@test string(s) == "This is a test\n"

# Verify that adding docstring didn't completely break execution of model
m = demo(0.)
@test m() isa Float64
end
end

0 comments on commit 0758d01

Please sign in to comment.