Skip to content

Documenting Data classes #1375

Open
Open
@halostatue

Description

@halostatue

rdoc does not usefully document data classes defined the correct way:

# Documenting a class made with Data.define
MyDataClass = Data.define :a do
  # Capitalize the value of +a+.
  def cap
    a.capitalize
  end
end

This documents a constant on Object, Object::MyDataClass instead of documenting it as a class itself, and the method within the data class definition is not documented either. It does not matter whether the Prism parser is used.

When documented with reopening, there are two different issues

MyDataClass = Data.define :a # :nodoc:

# Documenting a class made with Data.define
class MyDataClass
  # Capitalize the value of +a+.
  def cap
    a.capitalize
  end
end

If defined without # :nodoc:, MyDataClass is still documented as a constant on Object; if defined with # :nodoc:, the documentation is removed, but the generated documentation pages for Object isn't removed.

I believe that Data.define and Struct.new should be treated as if they were written as class variants.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions