From: Joel VanderWerf Date: 2004-08-28T06:05:42+09:00 Subject: Re: Literate testing? Massimiliano Mirra - bard wrote: > I was documenting a class and found myself often copying unit tests > and pasting them as examples. I think I also read something about > tests embedded in doc strings in Python. So in the interest of DRY I > figured something like this could be desirable: > > class Calculator > extend Literate > > example > # Addition > add(2, 8) == 10 > end > > def add(a, b) > return a + b > end > end > > I then came up with a stupid but working proof of concept: > > class Calculator > extend Literate > > example(__FILE__, __LINE__) do |calc| > # Addition > calc.add(2, 8) == 10 > end Are you planning to extract the example from the source code and generate documentation files? This could be done using the file and line information and some parsing or just good guesses about indentation.