Hacker News new | past | comments | ask | show | jobs | submit login

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.




I believe it's also how it works in go documentation. Examples are executed at compile time.


It's also present in Elixir!


It's present in python too


Didn'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-keep...


but as usual, it's optional.


such 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


Not without external tooling, as far as I'm aware.

With rust this is built into the default tools installed by rustup.


?

> https://docs.python.org/2/library/doctest.html

Write doctests in your docstrings, run python -m doctest


Sweet. Thank you.


Go does this as well.


Wow, that's very nice!




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: