# How to wrap code examples in comments

**URL:** <https://www.ruby-forum.com/t/how-to-wrap-code-examples-in-comments/120016>\
**Category:** Ruby\
**Created:** [November 13, 2007, 12:49am UTC](https://www.ruby-forum.com/t/how-to-wrap-code-examples-in-comments/120016 "2007-11-13T00:49:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f1d935/32.png) [@bado](https://www.ruby-forum.com/u/bado)\
**Post date:** [November 13, 2007, 12:49am UTC](https://www.ruby-forum.com/t/how-to-wrap-code-examples-in-comments/120016/1 "2007-11-13T00:49:05Z")

</div>

Hi guys,  
I tried to post this in removed\_email\_address@domain.invalid but nobody seems to be  
there.  
I’m new on documenting Ruby sources, I have some early opinions about  
RDoc but this time and want to ask you something.  
I tried to wrap code examples in comments using the following:

# 

# def setUp

# files \<\< File.new()

# end

# 

But it doesn’t work, it generates an ugly HTML like  
 def setUp

@appStates \<\< AppState1.new()

end

What am I missing here?

Thanks,  
Ubaldo

---

<div class="post-metadata">

**Author:** ![bado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f1d935/32.png) [@bado](https://www.ruby-forum.com/u/bado)\
**Post date:** [November 13, 2007, 2:13am UTC](https://www.ruby-forum.com/t/how-to-wrap-code-examples-in-comments/120016/2 "2007-11-13T02:13:13Z")

</div>

I found the answer by accident, just adding extra spaces at the begin  
of comment line, but now I have another question, I’m trying to place  
a labeled list in two lines like:

# objInputData:: Optional. The input data required by the logic defined

in

# derived classes. It’s commonly a hash map. Set

to nil by default.

Line two HTML is generated in typewriter mode. How could build a  
labeled list using multiple lines? Is there a nice site to find more  
information about RDoc? [RDoc Documentation](http://rdoc.sourceforge.net/doc/index.html)  
seems to be insufficient.

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![bado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/f1d935/32.png) [@bado](https://www.ruby-forum.com/u/bado)\
**Post date:** [November 13, 2007, 2:36am UTC](https://www.ruby-forum.com/t/how-to-wrap-code-examples-in-comments/120016/3 "2007-11-13T02:36:35Z")

</div>

I found the answer again, wow this list works great. Just adding or  
removing spaces from the second line until RDoc generated the proper  
HTML, this is a try-and-error process:

# objInputData:: Optional. The input data sent by the testcase caller

and available to be used by the logic defined in

# derived testcases. It’s commonly a hash map. Set to

nil by default.

I’m impressed, RDoc is absolutely intuitive and well programmed.
