5 ms·
Not only that, any code examples in rustdoc are treated like tests and get executed during compilation! That ensures that your examples are not obsolete (or at
by hprotagonist 9y ago
Not only that, any code examples in rustdoc are treated like tests and get executed during compilation! That ensures that your examples are not obsolete (or at least that they compile).
That is a genuinely great idea.
- mlvljr 9y agoPython has had this for a decade or more, too :)
- _ZeD_ 9y agoIt's present in python too
- hprotagonist 9y agobut as usual, it's optional.
- agumonkey 9y agosuch is life, especially in dynlangs, things got added, it's already cool that it's known and works finely as it is. maybe one day domains, limits and code/proofs will be a single entity in source
- seangransee 9y agoDidn't realize this was possible with Sphinx (Python) until I saw your comment and did some digging. Here's the relevant documentation if anyone else is curious: http://docs.sphinxdocs.com/en/latest/step-3.html#step-3-keeping-documentation-up-to-date http://docs.sphinxdocs.com/en/latest/step-3.html#step-3-keep...
- staticassertion 9y agoNot without external tooling, as far as I'm aware. With rust this is built into the default tools installed by rustup.
- Macha 9y ago? > https://docs.python.org/2/library/doctest.html https://docs.python.org/2/library/doctest.html Write doctests in your docstrings, run python -m doctest
- staticassertion 9y agoSweet. Thank you.
- weberc2 9y agoGo does this as well.
- iampims 9y agoI believe it's also how it works in go documentation. Examples are executed at compile time.
- maxxxxx 9y agoWow, that's very nice!
- yangmaster 9y agoIt's also present in Elixir!