rdoc help needed

B

Brian Schröder

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
 
D

Dave Thomas

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.

Does --inline-source do what you want?

Cheers

Dave
 
A

Ara.T.Howard

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

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
--
===============================================================================
| 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
===============================================================================
 
B

Brian Schröder

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
 
D

Dave Thomas

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
 
B

Brian Schröder

Am Sat, 18 Sep 2004 01:49:57 +0900 schrieb Dave Thomas:
Have you tried --inline-source --one-file


Cheers

Dave

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.
 
B

Brian Schröder

Am Sat, 18 Sep 2004 01:49:57 +0900 schrieb Dave Thomas:
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
 
D

Dave Thomas

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.

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


Cheers

Dave
 
M

Mauricio Fernández

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
====
The advantages of the lack of docs: there is no manual for Ruby ;-))))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top