Join GitHub today
generate tests from code example docstrings (to fight bitrot) #2925
So I'm going through my contributions and adding code examples for most of the API stuff out there that isn't immediately obvious.
I only have one example of an existing code sample that is live in the libstd docs right now, and that's for
Since more literate code examples in the docs is probably a good thing, this is where I'm putting my energies for documentation of my work (as opposed to blog posts, emails to the list, etc). I'm trying to make the examples complete, illustrative and durable (the latter of which I have no control over).
Cutting to the chase:
I'd be happy with something like what (I'm told) we have in the tutorial markdown: have the build automation (rustdoc, in this case?) do a run-pass on all code blocks (by some known convention) that appear in docstrings, for the greater good.
The easiest way is probably to use rustdoc to convert the documentation to markdown, then run the python script over it to generate tests.
Here's my preference:
Later, once we've created a unified