3 ms·
Actually every example in the documentation should be backed by a unit test, as in the example is transcluded from the unit test into the docs. Since you often
by PaulHoule 2y ago
Actually every example in the documentation should be backed by a unit test, as in the example is transcluded from the unit test into the docs. Since you often want to show examples that don’t compile in docs you also should be able to write tests for compile errors.
- red2awn 2y agoBetter yet, use doc test as featured in Python [1] or Rust [2]. This makes sure your documentation examples are always up-to-date and runnable. [1]: https://docs.python.org/3/library/doctest.html https://docs.python.org/3/library/doctest.html [2]: https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html https://doc.rust-lang.org/rustdoc/write-documentation/docume...