Documenter.jl: No way to skip checking output of script with doctest

Created on 10 Dec 2018  路  6Comments  路  Source: JuliaDocs/Documenter.jl

I can't find a way to not check the output of a script in a doctest. For the sake of example, I would like to be able to do something like:

```jldoctest; output = false
A = rand(5)
B = rand(5)
A + B

# output

[...]
``` #end of jldoctest

Looking at eval_script makes it seem like it's impossible to ignore the output, which if I understand is controlled by result.hide.

Question

Most helpful comment

It should be possible to use an at-example block for this, if you really do not care about the output:
```@example A = rand(5) B = rand(5) A + B nothing # hide ```

The nothing # hide part will make the block return nothing, which hides the output, and #hide hides that line in the input block. Documenter should still fail to build the docs if it fails to evaluate the at-example block.

All 6 comments

Maybe I am being dense, but If you don't want to check the output, why is it a jldoctest?

It's for an example of how to construct a filter object. The filter values don't really matter, but it would be nice to check that the steps to build the filter are valid (I.e. prevent the documentation from not matching the API). There doesn't seem to be a way to check just the first part of the filter array, or the type of the returned value either.

You could perhaps seed the random number generator so that the numbers are the same every time it is run, or alternatively use the filtering: https://juliadocs.github.io/Documenter.jl/stable/man/doctests/#Filtering-Doctests-1.

Ok filtering seems reasonable here. In general, when demonstrating an api, I think that showing the return value may not be informative if the value is large or complicated to display. Nonetheless it would be nice to check that the API still matches the example. You can achieve this with single statement examples by appending a semicolon to the doctest, but if the example is a 'script' with multiple statements then it's not currently possible (from what I can tell). The utility is the same in both cases, but for scripts it's not yet implemented.

It should be possible to use an at-example block for this, if you really do not care about the output:
```@example A = rand(5) B = rand(5) A + B nothing # hide ```

The nothing # hide part will make the block return nothing, which hides the output, and #hide hides that line in the input block. Documenter should still fail to build the docs if it fails to evaluate the at-example block.

Thanks @mortenpi that's exactly what I want.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thofma picture thofma  路  5Comments

lindnemi picture lindnemi  路  3Comments

dkarrasch picture dkarrasch  路  5Comments

carlobaldassi picture carlobaldassi  路  5Comments

halirutan picture halirutan  路  4Comments