rubyyard

YARD - how to document @!method YARD on class level rather than instance level?


By default, such methods are created on the instance level from what I see. How to document class/static level methods instead?

I checked https://www.rubydoc.info/gems/yard/file/docs/Tags.md#method but it wasn't very clear.


Solution

  • This can be adjusted via @!scope which can be either class or instance:

    class Foo
      # @!scope class
      #
      # @!method bar
      #   @return [Bar] enum scope
      # @!method baz
      #   @return [Baz] enum scope
    end
    

    See Documenting Custom DSL Methods