Documenter.jl: Show the error message on purpose?

Created on 21 Sep 2020  路  5Comments  路  Source: JuliaDocs/Documenter.jl

I wanted to show some error message in the docs on purpose, but I realized that (by default) Documenter.jl is not going to show it, but give a warning in the docs build step. Is there an easy hack how to display the error warning? Ideally, I wouldn't want to distract the reader with display details, so I'd like to show only the call that would trigger the error.

Enhancement help wanted

Most helpful comment

I had this issue as well. Here was the work-around I came up with:
`Julia @example
try #hide
rand(2,2)'ones(3)
catch err; showerror(stderr, err); end #hide

````
Just calling `@error e` isn't sufficient because the string representation of the error is often different to `showerror`.

Presumably, the fix for this issue is to add a 
````Julia
```@example; allow_error=true
rand(2,2)'ones(3)

````
which rewrites the block to the above.

All 5 comments

Do you have an example? Is this in a doctest or @example block?

It's an @example block, generated with Literate.jl. An example could be

```@example custom
rand(2,2)'ones(3)

I think the short answer here is that for an at-example block, no. But it should work as you expect if you convert it to a doctest.

We expect the the at-blocks to run successfully. Or, rather, if they fail, it's probably an error the user wants to know about. Potentially though we could have an option for at-example blocks that explicitly allows the blocks to error (and prints the error as the output, I guess?).

As a quick fix, you could rewrite your code with try ... catch and handle the exception yourself? I.e.

md ```@example try rand(2,2)'ones(3) catch e @error e end ```

I had this issue as well. Here was the work-around I came up with:
`Julia @example
try #hide
rand(2,2)'ones(3)
catch err; showerror(stderr, err); end #hide

````
Just calling `@error e` isn't sufficient because the string representation of the error is often different to `showerror`.

Presumably, the fix for this issue is to add a 
````Julia
```@example; allow_error=true
rand(2,2)'ones(3)

````
which rewrites the block to the above.

Yep, a keyword argument for the at-blocks. I think #1447 is adjacent to this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nalimilan picture nalimilan  路  4Comments

thofma picture thofma  路  5Comments

timholy picture timholy  路  6Comments

lindnemi picture lindnemi  路  3Comments

juliohm picture juliohm  路  6Comments