defunkt / tomdoc

A TomDoc Ruby library.
http://tomdoc.org/
MIT License
114 stars 16 forks source link

Issue with a Rails controller #33

Open 10io opened 11 years ago

10io commented 11 years ago

Hi, I am trying to document a Rails controller. I'd like to extract this information as tokens using tomdoc.

Unfortunately, there is a small issue when the controller has before filters.

Here is a simple controller:

class ItemsController < ApplicationController
  # Public: This will do nothing.
  #
  # Returns nothing.
  def index
    puts 'foobar'
  end
end

and the output of tomdoc:

--------------------------------------------------------------------------------
ItemsController#index

Public: This will do nothing.

Returns nothing.

Looks good. Now, with this controller containing a before_filter:

class ItemsController < ApplicationController
  before_filter :filter, :only => [:index]
  # Public: This will do nothing.
  #
  # Returns nothing.
  def index
    puts 'foobar'
  end
end

tomdoc will output nothing. Am I doing something wrong?

trans commented 11 years ago

Looks like a potential bug. See what happens if you put a blank line after the before_filter.

Also, given your stated intent, you may be interested in rubyworks/tomparse.

10io commented 11 years ago

Same behavior with a blank line.

@trans: Yep, I am looking into rubyworks/tomparse too but my understanding is that it is used to parse code comments: I can't use it directly on ruby files. I need first to extract all the comments using yard(I saw yard-tomdoc), rdoc or whatever. Thanks for your suggestion.