I would like to include some worked examples in a package (distinct from unit tests).
Where should they go? A subdirectory in docs (will that interfere with Documenter.jl?) or in tests?
Is there a framework for running them within CI? For now, I just want to run each example on Travis in a fresh Julia process, and check that it completes without an error. Later on it would be nice to check the results.
Is there a way I can splice a file into documentation generated with Documenter.jl as Julia source code, ie between ```s?
For my projects I decided to just use Jupyter notebooks. It is easier for the user to play with them right away, specially if you provide a dummy function to start Jupyter in the examples folder:
I keep updating them as the project evolves. The major downside of writing separate Jupyter notebooks is that they aren’t synced with the docs. If you update them in the repository, they will be always ahead of the latest tagged version.
In Query I have an examples folder, and run them as part of my tests. I’m not super happy with that because it really slows down the build, but at least I know when something breaks.
I have somewhat of a hack at Augmentor.jl to convert plain examples/*.jl scripts into nice looking documentation pages as well as jupyter notebooks. Its more of a curiosity than a clean solution but it does its job quite nicely
With a bit of rejiggering, you can test doctests as part of Pkg.test. You just have to move the code for building your documentation inside your testing file (set strict = TRUE and also some messing around with file paths). I do this for all of my packages, and try to have as many tests in the form as doctests as possible.
Thanks! Can you link an example of testing standalone examples? I looked at some of your packages and saw how you build the docs in runtests.jl, but found no example testing.
While I got many helpful answers for questions 2 and 3, no one said anything about 1, so I guess there is no standard location for examples. I will just use examples/.
Maybe there should be a standard? I remember a time when we didn’t have a real standard for the src and test folders, now there is. Maybe a similar standardization for the examples would be good?