3 ms·
The docs have test cases embedded in the markdown. This is a pretty cool use of markdown. I have started doing something similar with markdown in my project. I
by Ohkay 2y ago
The docs have test cases embedded in the markdown. This is a pretty cool use of markdown. I have started doing something similar with markdown in my project. I wonder if other programming languages have done this too.
- oulipo 2y agoWell, it's what's called "literate programming"
- returningfory2 2y agoRust has this, and it just makes so much sense. Especially when you write a library in which the basic demo is also the basic unit test you want to make. Instead of writing a specific unit test that's hidden in source code, you just embed it in the docs and then you (a) don't have code duplication and (b) have verification your documentation's code samples are actually correct.
- LoganDark 2y ago> and (b) have verification your documentation's code samples are actually correct. I find a lot of libraries don't go through the effort to actually use doctests, and just stick `no_run` everywhere, which defeats a lot of the purpose.
- jmholla 2y agoPython has doctests: https://docs.python.org/3/library/doctest.html https://docs.python.org/3/library/doctest.html
- Calamitous 2y agoElixir has this as well, IIRC.