Rdoc help needed

Hello,

I'm preparing a class on ruby, and I decided to write the exercices as ruby files with function stubs and rdoc comments. Additionally I'm defining unit tests, such that the student can test his program to complie with the unit tests.

What I would like to have would be a simpler rdoc output. Mainly parsing the file from top to bottom, and outputting marked up comments and ruby source as it is encountered in the file. Is this already possible, or do I have to write something myself.

Alternatively, if someone knows a better approach I'm also open to it.

Regards,

Brian

Does --inline-source do what you want?

Cheers

Dave

···

On Sep 17, 2004, at 5:19, Brian Schröder wrote:

What I would like to have would be a simpler rdoc output. Mainly parsing the file from top to bottom, and outputting marked up comments and ruby source as it is encountered in the file. Is this already possible, or do I have to write something myself.

can you define 'simpler'? - without knowing what that means i'm inclined to
say it already does this but you seem to think it does not by your comment so
you must have some definition of 'simple' i don't understand.

kind regards.

-a

···

On Fri, 17 Sep 2004, Brian [ISO-8859-1] Schröder wrote:

Hello,

I'm preparing a class on ruby, and I decided to write the exercices as ruby files with function stubs and rdoc comments. Additionally I'm defining unit tests, such that the student can test his program to complie with the unit tests.

What I would like to have would be a simpler rdoc output. Mainly parsing the file from top to bottom, and outputting marked up comments and ruby source as it is encountered in the file. Is this already possible, or do I have to write something myself.

Alternatively, if someone knows a better approach I'm also open to it.

Regards,

Brian

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen

===============================================================================

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 :wink:

Regards,

Brian

Have you tried --inline-source --one-file

Cheers

Dave

···

On Sep 17, 2004, at 10:59, Brian Schröder wrote:

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.

Thank you Dave,

I should have thought that it was already included (and now that I have
formulated my whishes exactly, I see how stupid it was that I did not
encounter the correct switch.)

Regards,

Brian

PS: I think this is really one of the friendliest newsgroups I know.
Everywhere else I'd have gotten a RTFM. I read it, but I was too slow to
recognize. But next time I think I have to read it more thoroughly to
spare me the shame.

···

Am Sat, 18 Sep 2004 01:49:57 +0900 schrieb Dave Thomas:

On Sep 17, 2004, at 10:59, Brian Schröder wrote:

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.

Have you tried --inline-source --one-file

Cheers

Dave

Oh, two fast. I think I'll go to bed and have some sleep. I didn't see
that rdoc is mixing up the method order. I just wanted everything to
appear in the same sequence as it is in the file. Simply markup the file.
No further intelligent things.

Regards,

Brian

···

Am Sat, 18 Sep 2004 01:49:57 +0900 schrieb Dave Thomas:

On Sep 17, 2004, at 10:59, Brian Schröder wrote:

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.

Have you tried --inline-source --one-file

Cheers

Dave

That's not something it currently does (but it's an interesting idea. Let me think about it)

Cheers

Dave

···

On Sep 17, 2004, at 14:24, Brian Schröder wrote:

Oh, two fast. I think I'll go to bed and have some sleep. I didn't see
that rdoc is mixing up the method order. I just wanted everything to
appear in the same sequence as it is in the file. Simply markup the file.
No further intelligent things.

PS: I think this is really one of the friendliest newsgroups I know.
Everywhere else I'd have gotten a RTFM. I read it, but I was too slow to

···

On Sat, Sep 18, 2004 at 04:04:46AM +0900, Brian Schröder wrote:
                                    ====
The advantages of the lack of docs: there is no manual for Ruby ;-))))

recognize. But next time I think I have to read it more thoroughly to
spare me the shame.

--
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com