sfcgeorge / yard-contracts

YARD Plugin for Automatic Param Docs from Contracts.
MIT License
26 stars 3 forks source link

Class methods showing up as instance methods #15

Open nixpulvis opened 9 years ago

nixpulvis commented 9 years ago

Doing the following doesn't work as expected.

class Foo
  include Contracts

  class << self
    Contract String => Num
    def foo(a)
      1
    end
  end
end

Shows the method as an instance method.

sfcgeorge commented 9 years ago

The current check for whether it's a class or instance method is very simplistic based on there being a self. so this other syntax doesn't work. YARD / Ripper don't (that I could find) provide a way to automatically see if a method is class or instance, hence the need for this hack.

I don't really know what to do to fix it. I don't particularly want to add even bigger hacks for all the edge cases. If you can find an elegant way to do it though I'm open to a pull request.