Skip to content

Commit

Permalink
Document cabal doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Jul 14, 2024
1 parent 365b7d8 commit 3a3e16b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ It is similar in spirit to the [popular Python module with the same name](https:
* [A basic example](#a-basic-example)
* [Running doctest for a Cabal package](#running-doctest-for-a-cabal-package)
* [Passing doctest options to cabal repl](#passing-doctest-options-to-cabal-repl)
* [Cabal integration](#cabal-integration)
* [Writing examples and properties](#writing-examples-and-properties)
* [Example groups](#example-groups)
* [A note on performance](#a-note-on-performance)
Expand All @@ -36,7 +37,7 @@ It is similar in spirit to the [popular Python module with the same name](https:
[Hackage](https://hackage.haskell.org/package/doctest).
Install it with:

cabal update && cabal install doctest
cabal update && cabal install --ignore-project doctest

Make sure that Cabal's `bindir` is on your `PATH`.

Expand Down Expand Up @@ -120,7 +121,7 @@ library

With a `.cabal` file in place, it is possible to run `doctest` via `cabal repl`:

```
```bash
$ cabal repl --with-compiler=doctest
...
Examples: 2 Tried: 2 Errors: 0 Failures: 0
Expand Down Expand Up @@ -159,7 +160,7 @@ You can pass `doctest` options like `--fast`, `--preserve-it` and `--verbose` to

Example:

```
```bash
$ cabal repl --with-compiler=doctest --repl-options=--verbose
### Started execution at src/Fib.hs:7.
### example:
Expand All @@ -175,6 +176,22 @@ fib 5
Examples: 2 Tried: 2 Errors: 0 Failures: 0
```

## Cabal integration

***NOTE:*** This feature is experimental.

***NOTE:*** This feature requires `cabal-install` version 3.12 or later.


```bash
$ cabal install --ignore-project doctest --flag cabal-doctest
```

```bash
$ cabal doctest
Examples: 2 Tried: 2 Errors: 0 Failures: 0
```

# Writing examples and properties

## Example groups
Expand Down
22 changes: 19 additions & 3 deletions doc/README.template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ It is similar in spirit to the [popular Python module with the same name](https:
[Hackage](https://hackage.haskell.org/package/doctest).
Install it with:

cabal update && cabal install doctest
cabal update && cabal install --ignore-project doctest

Make sure that Cabal's `bindir` is on your `PATH`.

Expand Down Expand Up @@ -75,7 +75,7 @@ A simple `.cabal` file for `Fib` looks like this:

With a `.cabal` file in place, it is possible to run `doctest` via `cabal repl`:

```
```bash
$ cabal repl --with-compiler=doctest
...
Examples: 2 Tried: 2 Errors: 0 Failures: 0
Expand Down Expand Up @@ -114,7 +114,7 @@ You can pass `doctest` options like `--fast`, `--preserve-it` and `--verbose` to

Example:

```
```bash
$ cabal repl --with-compiler=doctest --repl-options=--verbose
### Started execution at src/Fib.hs:7.
### example:
Expand All @@ -130,6 +130,22 @@ fib 5
Examples: 2 Tried: 2 Errors: 0 Failures: 0
```

## Cabal integration

***NOTE:*** This feature is experimental.

***NOTE:*** This feature requires `cabal-install` version 3.12 or later.


```bash
$ cabal install --ignore-project doctest --flag cabal-doctest
```

```bash
$ cabal doctest
Examples: 2 Tried: 2 Errors: 0 Failures: 0
```

# Writing examples and properties

## Example groups
Expand Down

0 comments on commit 3a3e16b

Please sign in to comment.