Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the ":nodoc:" syntax needed?

Tags:

It seems a lot of libraries/plugins use this syntax:

  def self.included(base) # :nodoc:
    base.extend ClassMethods
  end

Why is the :nodoc: part necessary?

like image 276
Bryan Locke Avatar asked Nov 10 '09 17:11

Bryan Locke


2 Answers

It is not necessary. If applied to a class, it just suppresses documentation (rdoc) for all the methods in the Class extension. Described in Programming Ruby as:

:nodoc: - Don't include this element in the documentation. For classes and modules, the methods, aliases, constants, and attributes directly within the affected class or module will also be omitted from the documentation. By default, though, modules and classes within that class or module will be documented.

like image 164
Chirantan Avatar answered Sep 23 '22 17:09

Chirantan


I don't think it's necessary. Actually, in my opinion, it's one of the most useless features of RDoc.

So many times I've seen it while reading a libarie's code and I had to ask myself "Why?". I don't see any reason to use this feature. If you don't want people to use your method, just make it private. It's a big hassle when reading documentation and seeing a method call to a method that's left out of the documentation.

like image 45
Patrik Avatar answered Sep 23 '22 17:09

Patrik