Open
Description
I found that writing a doctest using the HTML backend can fail. It was printing to the terminal, rather than whichever IO that Documenter.jl was redirecting to. I think that the issue is caused by this line. Note that the docstring for display
says that "In general, you cannot assume that display
output goes to stdout
".
In this MWE, the output of pretty_table
should get written to the pipe
. Instead, it is printed on the terminal.
julia> using PrettyTables
julia> (_read, _write) = pipe = Pipe()
Pipe(RawFD(4294967295) init => RawFD(4294967295) init, 0 bytes waiting)
# note the semicolon, the table is getting printed on the terminal instead of written to `stdout`
julia> redirect_stdout(() -> pretty_table(stdout, [1,2,3,4]; backend = Val(:html)), pipe);
<table>
<thead>
<tr class = "header headerLastRow">
<th style = "text-align: right;">Col. 1</th>
</tr>
</thead>
<tbody>
<tr>
<td style = "text-align: right;">1</td>
</tr>
<tr>
<td style = "text-align: right;">2</td>
</tr>
<tr>
<td style = "text-align: right;">3</td>
</tr>
<tr>
<td style = "text-align: right;">4</td>
</tr>
</tbody>
</table>
julia> close(_write)
julia> read(_read, String)
""
For comparison, here is the redirection working correctly:
julia> using PrettyTables
julia> (_read, _write) = pipe = Pipe()
Pipe(RawFD(4294967295) init => RawFD(4294967295) init, 0 bytes waiting)
julia> redirect_stdout(() -> pretty_table(stdout, [1,2,3,4]), pipe);
julia> close(_write)
julia> read(_read, String)
"┌────────┐\n│ Col. 1 │\n├────────┤\n│ 1 │\n│ 2 │\n│ 3 │\n│ 4 │\n└────────┘\n"
Metadata
Metadata
Assignees
Labels
No labels