Class PostsController
In: app/controllers/posts_controller.rb
Parent: ApplicationController

Methods

Constants

SOME_CONSTANT = 3   RDOC detects constants! By the way, always write your comment ABOVE an element and never next to it… otherwise it won‘t be part of the doc.

Attributes

something  [RW]  something is a class attribute. RW obviously means Read/Write. It‘s because i have created it with attr_accessor
something_else  [R]  something else is another class attribute that is read only.

Public Instance methods

This method is a very critical one in our system. Please be careful!

The text above is bigger because I used 2 heading characters "==" before typing the actual comment. (It‘s like the h1, h2, h3 tags in HTML but instead you use =, ==, === and so on)

[Source]

    # File app/controllers/posts_controller.rb, line 16
16:         def my_first_method                            
17:         end

Here is what my_second_method does :

  1. It takes 2 params
  2. We discard the 1st one
  3. We put "mister t" in the second one if nothing has been supplied.

As you can see, you can also create ordered lists with RDoc. Just type a digit and then a period before your comment. If you need a non-ordered list, type * or - before your comment. If you need an alpha list, type a letter followed by a period. Note also that RDoc automatically put hyperlinks around method and class names. That‘s a very easy and useful way to help people navigating in your documentation! Hey let‘s try it… I know you want to jump to the my_first_method declaration.

[Source]

    # File app/controllers/posts_controller.rb, line 29
29:         def my_second_method(my_first_param, my_second_param = "mister t")
30:         end

RDoc also detects external links, like www.rubyfleebie.com. If you prefer displaying a label instead of an URL address, use the label[url] format instead, like that : Ruby Fleebie!. If your label as more than 2 words (like in the example), put them inside curly braces, like that {Rock on!} [the url]

[Source]

    # File app/controllers/posts_controller.rb, line 35
35:         def my_third_method
36:         end

Finally, how about some HTML basic formatting? if it is just one word long, use * hello * for bold and _ hello _ for italic (just remove the spaces). Now if the thing to format is more than one word long, use the more traditionnal <em> and <b> tags (just a nitpicky question though : Why "b" instead of "strong"?).

[Source]

    # File app/controllers/posts_controller.rb, line 40
40:         def the_final_method!
41:         end

[Validate]