Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdout not being captured #986

Closed
JackDunnNZ opened this issue Mar 22, 2019 · 2 comments
Closed

stdout not being captured #986

JackDunnNZ opened this issue Mar 22, 2019 · 2 comments
Assignees
Milestone

Comments

@JackDunnNZ
Copy link
Contributor

JackDunnNZ commented Mar 22, 2019

On the current master, the following doesn't show any output being captured

```@example
println("hello world")
```

Works as expected on 0.21.5

@fredrikekre fredrikekre self-assigned this Mar 22, 2019
@mortenpi mortenpi added this to the 0.22.0 milestone Mar 23, 2019
@mortenpi
Copy link
Member

Seems to be due to #938. We're just discarding the buffer variable now:

result, buffer = nothing, IOBuffer()
if !continued # run the code
# check if there is any code wating
if haskey(page.globals.meta, :ContinuedCode) && haskey(page.globals.meta[:ContinuedCode], sym)
code = page.globals.meta[:ContinuedCode][sym] * '\n' * x.code
delete!(page.globals.meta[:ContinuedCode], sym)
else
code = x.code
end
for (ex, str) in Utilities.parseblock(code, doc, page; keywords = false)
(value, success, backtrace, text) = Utilities.withoutput() do
cd(dirname(page.build)) do
Core.eval(mod, ex)
end
end
Core.eval(mod, Expr(:global, Expr(:(=), :ans, QuoteNode(value))))
result = value
print(buffer, text)
if !success
push!(doc.internal.errors, :example_block)
@warn("""
failed to run `@example` block in $(Utilities.locrepr(page.source, lines))
```$(x.language)
$(x.code)
```
""", value)
page.mapping[x] = x
return
end
end
else # store the continued code
CC = get!(page.globals.meta, :ContinuedCode, Dict())
CC[sym] = get(CC, sym, "") * '\n' * x.code
end
# Splice the input and output into the document.
content = []
input = droplines(x.code)
# Generate different in different formats and let each writer select
output = Base.invokelatest(Utilities.display_dict, result)

Looking into a fix.

@JackDunnNZ
Copy link
Contributor Author

Thanks @mortenpi !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants