Docception - Run doctests for markdown files



I spent some hours the last few days to put together a simple helper to check that code examples in 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 # run the doctests in

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.



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


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