Skip to content

Commit

Permalink
Fix world age for show methods in doctests
Browse files Browse the repository at this point in the history
Fixes #398.
  • Loading branch information
MichaelHatherly committed Jan 1, 2017
1 parent 8e69fbe commit 0ff1213
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DocChecks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ end

function result_to_string(buf, value)
dis = text_display(buf)
value === nothing || display(dis, value)
value === nothing || eval(Expr(:call, display, dis, QuoteNode(value)))
sanitise(buf)
end

Expand Down
20 changes: 20 additions & 0 deletions test/examples/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,25 @@ module AutoDocs
end
end

module Issue398

immutable TestType{T} end

function _show end
Base.show(io::IO, t::TestType) = _show(io, t)

macro define_show_and_make_object(x, y)
z = Expr(:quote, x)
esc(quote
$(Issue398)._show(io::IO, t::$(Issue398).TestType{$z}) = print(io, $y)
const $x = $(Issue398).TestType{$z}()
end)
end

export @define_show_and_make_object

end # module

# Build example docs
using Documenter

Expand All @@ -89,6 +108,7 @@ examples_markdown_doc = makedocs(
debug = true,
root = examples_root,
build = "builds/markdown",
doctest = false,
)

info("Building mock package docs: HTMLWriter")
Expand Down
13 changes: 13 additions & 0 deletions test/examples/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,16 @@ julia> fullname(Base.Pkg)
julia> current_module()
Main
```

# Issue398

```@meta
DocTestSetup = quote
using Issue398
end
```

```jldoctest
julia> @define_show_and_make_object q "abcd"
abcd
```

0 comments on commit 0ff1213

Please sign in to comment.