Having examples in documentation is useful, and checking whether examples actually work, is useful as well. The doctest
package provides a way to achieve this, but it works by running a command on a source-tree, and hence can’t be easily integrated with a Cabal project as a test-suite, including a way to specify the dependencies doctests may have.
The cabal-doctest
project provides a way to achieve this, by generating a module at build-time which contains meta-information required to run doctest
as a test-suite, passing in all necessary GHC flags. However, it works by hooking into Cabal as a Custom
build-type in Setup.hs
.
This works fine, but has one major drawback: some Cabal features don’t work with Custom
builds, e.g., the use of internal libraries is only supported with per-component builds (I remember Backpack to suffer the same fate).
Is there a way to have a doctest
suite to run as a Cabal test-suite, without relying on Custom
builds and hence keeping it possible to use internal libraries?