lsegal / yard

YARD is a Ruby Documentation tool. The Y stands for "Yay!"
http://yardoc.org
MIT License
1.94k stars 397 forks source link

Ruby 3.2 Data.define #1502

Closed nvoynov closed 1 year ago

nvoynov commented 1 year ago

Hi,

I've designed some of my classes as Data classes of Ruby 3.2 with some improvements by opening the target class like

# Function Model
Func = Data.define(:name, :type, :desc, :input, :output) do 
  # @param name [String]
  # @param type [String]
  # ...
  def initialize(name:, type:, desc: '', input: [], output: [])
     # validation skipped ..
     super
  end

  # Param Builder 
  # @see Param#intiailize
  def self.param(name:, type:, desc: '')
     Param.new(name: name, type: type, desc: desc)
  end

  # Param Model inside Function 
  Param = Data.define(:name, :type, :desc) do 
    # @param name [String]
    # @param type [String]
    # ...
    def initialize(name:, type:, desc: '')
       # validation skipped ..
       super
    end
  end
end

Having designed my data model that way above I just run $ yard and get constants documented under root module see picture below

picture

The question is ... it's actually commented as constants. But is there a way to get these constants as classes Func and Param?

The second question is how to comment properties of Func(name, type, desc, input, output) and Param(name, type, desc) in Yard

nvoynov commented 1 year ago

sorry for the stupid question