There is a great tool rustdoc (currently used by cargo) to test examples of documentation comments in Rust. Does rdoc or yard give us something similar in Ruby?
Asked
Active
Viewed 442 times
3
-
1YARD's homepage has a blurb about running inline rspecs. I recall a gem for running code examples in comments as well but can't locate it at the moment. In any case, requests for tools/libraries/etc are considered OT for SO. I'll confirm they exist, however. – Dave Newton May 29 '15 at 14:44
-
@DaveNewton Sorry for OT. Will close request after your confirmation. Thank you! – Vitalii Elenhaupt May 29 '15 at 15:00
-
No problem. I'm not convinced questions like this *should* be OT, but libraries/etc. are relatively ephemeral so it sort of makes sense. – Dave Newton May 29 '15 at 15:06
-
1This practice is generally believed to have originated with the Python `doctest` library. I'm not sure if there aren't even older examples in Lisp or Smalltalk, but "doctest" is the term you're looking for. There have been multiple doctest libraries for Ruby, but I'm not sure if any of them is still maintained or even was mature to begin with. – Jörg W Mittag May 29 '15 at 15:41
-
1I removed the "(or something else)." With that, this question no longer asks for off-site resources, but instead about the capabilities of two specific gems. – Wayne Conrad May 29 '15 at 17:33
1 Answers
1
Well, there few examples of doctest tool in Ruby, and the most fresh one (for now) is yard-doctest:
Meet YARD::Doctest - simple and magical gem, which automatically parses your @example tags and turn them into tests!
Probably no so powerful as rustdoc, but it does what it needs to.

Vitalii Elenhaupt
- 7,146
- 3
- 27
- 43