Docception - Run doctests for markdown files

testing
doctest
#1

Hi!

I spent some hours the last few days to put together a simple helper to check that code examples in README.md files can actually be tested against the project. The result is Docception, which exposes a mix task to check any markdown file using Elixir’s own doctest:

$ mix docception README.md # run the doctests in README.md

The approach of Docception is simply: It reads a file, generates an abstract Erlang Form for the Docs chunk, and puts that into the very-private-do-not-trust-I-will-be-there-later ExUnit.DocTest.__doctests__/1 function. See the repository for some more information and an example project using the mix task within an alias for mix test.

I hope somebody finds that useful, or at least interesting.

9 Likes

#2

Ooo I’ve always wanted that to be done, always wished I could doctest an md file instead of an elixir file. :slight_smile:

1 Like

#3

Nice! This is great, because I love literate programming :smile:

2 Likes