yard icon indicating copy to clipboard operation
yard copied to clipboard

Nasty problem upgrading to 0.9.28

Open mcorino opened this issue 3 years ago • 0 comments

I am documenting a native C-Ruby extension with files much like this:

# -----------------
# - Just comment
# -----------------


module Top

  # Test class
  #
  class Test < Object

    # @!method test(*args)
    # @overload test(i, b)
    #   @param i [Integer] an integer
    #   @param b [Boolean] a boolean
    # @overload test(s='')
    #   @param s [String] a string
    #
    #   Method with overloads

    # @!method ::new
    #   default constructor

  end

end

This worked just fine with Ruby 2.5 and yard 0.9.12 but since I upgraded to Ruby 3.1.2 and yard 0.9.28 I have a nasty problem with the generated documentation in that ALL methods of classes like class Test above are generated as members of the module Top instead of class Test.

Weirdly I found that when the class declaration contains any non-commented statement like:

module Top

  # Test class
  #
  class Test

    # ...

    self
  end

end

the documentation gets generated correctly. This is however a workaround I would be not happy about to have to apply.

Steps to reproduce

This is the minimal reproduction for the issue. I've done my best to remove all extraneous code and unique environment state on my machine before providing these steps:

  1. Save the example above to some file
  2. Run the following command: yardoc <file>
  3. Open browser to the generated index.html file
  4. Click on the 'Top' module link.
  5. Click on the 'Test' class link

Actual Output

Methods listed under top module.

Expected Output

Methods listed under class where thery are documented.

Environment details:

  • OS: OpenSuSE Leap 15.4
  • Ruby version (ruby -v): ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-linux]
  • YARD version (yard -v): yard 0.9.28

I have read the Contributing Guide.

mcorino avatar Nov 08 '22 15:11 mcorino