-
Notifications
You must be signed in to change notification settings - Fork 481
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
Feature request: jldoctest examples without testing against expected results #452
Comments
Don't |
They work, but the code is not tested. Here is an example: module TestDocs
export test_it
"""
function test_it()
Here is an example that documenter does not run:
```@example
a = 1
b = 2
a + c
nothing # hide
```
"""
function test_it()
println("Hallo")
end
end When I generate the documentation with the make.jl-file, the code in the @example block does not get executed. You find the whole package at this link: https://github.com/jmgnve/TestDocs.jl Have I done something wrong? |
Ah, no, you're right, apparently they don't work. I assumed that they might. I don't see any other objection to enabling them other than that |
But back to doctests then -- in principle reducing the test down to "was there an exception or not" should be quite possible. However, with doctests we shouldn't inject the output of the run into the document (because of the objections above). Are doctests/example blocks without output actually useful? Is there are use case you could show? Also, we need syntax -- either we'd give it a new label (e.g. |
Are doctests/example blocks without output actually useful? Is there are use case you could show? For me, I think they would be quite useful. For example, I have models that produce a rather large set of outputs that are difficult to show and test in a compact way. But it would be nice to show examples on how to run the code, and be sure that they are always up-to-date. However, I am quite new to Julia and if it is difficult/tedious to implement such a feature, it would of course be helpful if more people give their opinion. For me it is more a good-to-have feature than something that is really needed. |
You can skip comparison pretty trivial now by adding
|
I'd love to see an option where code is run and one checks whether it crashes, but no output is compared. We have a lot of use cases where maintaining the output check is not practical (or important), but we do want to make sure things run. |
Sometimes I have some setup that I'd like to associate with a particular named doctest sequence, interleaving explanation and code. But some steps in the sequence have no need for a "correctness" test, they just need "did it not throw an error?" validation. Here is an example, where there is no reason to test the result of loading the image, but we'd like to use it for later
Unfortunately this gives an error:
I could mimic that with adequate setup code, but it just repeats the stuff that's in the demo.
but that feels pretty silly and might confuse users ("why do I have to call |
I have the same request. In GeoData.jl the examples are often downloading some data source, applying an operation, and plotting. The output is not worth testing, but I would like to make sure that the example code actually runs. Mostly now there are just empty |
Just also mentioning that this would be useful in Catalyst.jl as well. Every once in a while we get an issue where someone has tried to run something in the docs, but it no longer works and produces an error. It would not be feasible to compare the actual output, because either:
|
- Code chunks in `docs/` no longer fail silently: `@repl` → `@example`. - Code chunks in `docs/` expected to fail are now `jldoctest` blocs. - This introduces code setup duplication until some limitation is lifted? JuliaDocs/Documenter.jl#452 - Fix broken DOI url. - Docstring for helper macros are now plain comments for they are not in doc.
- Code chunks in `docs/` no longer fail silently: `@repl` → `@example`. - Code chunks in `docs/` expected to fail are now `jldoctest` blocs. - This introduces code setup duplication until some limitation is lifted? JuliaDocs/Documenter.jl#452 - Fix broken DOI url. - Docstring for helper macros are now plain comments for they are not in doc.
I think the actionable decision here is to implement an option (e.g. |
such a test would be very useful |
Just wondering if this is still a planned feature. It would be useful for my package. |
- Code chunks in `docs/` no longer fail silently: `@repl` → `@example`. - Code chunks in `docs/` expected to fail are now `jldoctest` blocs. - This introduces code setup duplication until some limitation is lifted? JuliaDocs/Documenter.jl#452 - Fix broken DOI url. - Docstring for helper macros are now plain comments for they are not in doc.
Would also like this. As a fun complication, in my case there is a function called in doctest which internally executes a function test_conformance_with_specification(obj)
@testset "Check conformance" begin
@test ...
end
end And then I have a sequence of
Note that I already use Anyway, note that since Documenter wraps the doctests also in a |
Just wondering if this is still a planned feature. It would be useful for my package. Just needs someone to take on the implementation. Would be happy to accept a PR implementing some version of this: #452 (comment)
Only if you run the It's orthogonal to this issue though. It would probably be good to have a separate issue to document and track this issue. |
You are right, will do. UPDATE done via #2605 |
Hi!
I want to add examples to my functions, but in many cases it is hard or not necessary to test the expected output. However, it may still be useful to test whether the functions/examples runs through or crashes. Is it possible to have a jldoctest with such a behavior? Perhaps by omitting the line(s) with expected outcomes as shown below:
The behavior I am looking for is the equivalent to adding this piece of "code" to the markdown documents:
However, I think it is more convenient to place the examples and testing whether they work or not directly in the files containing the Julia code, rather than in the markdown documents.
The text was updated successfully, but these errors were encountered: