From: "Brian Schröder" Date: 2004-09-18T00:59:50+09:00 Subject: Re: rdoc help needed Hello Rubyists, Thanks for the answers, and I'm sorry that I have expressed myself unclear. I'll give a short example: --8<---(shortened) 01_iterators.solutions.rb---8<-- #!/usr/bin/ruby ######################################################################### # This file contains exercises for the ruby course "sommercampus 2004" # Please fill in the solutions, and test them using the # 01_iterators.test.rb unit tests. # # Example: # $ ./01_iterators.rb ######################################################################## ######################################################################### = Iterators # == Exercise 1: n_times # Write an iterator function n_times(n) that calls the given block n times # # Call a block n times def n_times(n) #+++solution+++ n.times do yield() end #---solution--- end # == Exercise 2: Inject # === irb # Write a one-liner in irb using Range#inject to calculate 20!. # # Hint: A range is written like this: # (1..3) # == 1,2,3 # (1...3) # == 1,2 # === Function # Change the program to accept a variable and fill in this function stub. # # Make shure that (0! == 0), and (-1! == 0) # # Calculate n! def fac(n) #+++solution+++ return 0 if n < 1 (1..n).inject(1) { | result, i | result * i } #---solution--- end --8<---EOF---8<-- Now I'd like to get a single html, (or if it would be possible latex) file, containing the comments in this file as text and the code in this file as marked up code. (Note, the parts marked +++solution+++ can be removed before processing to make an exercise and a solution version. So I'll give the students this file to put there code in and set up the html files for easier reading. They'll learn to write rdoc-code and ruby at the same time ;) Regards, Brian