Module | YARD::Handlers::Ruby::StructHandlerMethods
In: | lib/yard/handlers/ruby/struct_handler_methods.rb

Helper methods to parse @attr_* tags on a class.

@since 0.5.6

### Methods

add_reader_tags add_writer_tags create_attributes create_class create_member_method? create_reader create_writer member_tag_for_member members_from_tags return_type_from_tag

### Included Modules

YARD::CodeObjects

### Public Instance methods

add_reader_tags(klass, new_method, member)

Creates the auto-generated docstring for the getter method of a struct‘s member. This is used so the generated documentation will look just like that of an attribute defined using attr_accessor.

@param [ClassObject] klass the class whose members we‘re working with @param [String] member the name of the member we‘re generating documentation for @return [String] a docstring to be attached to the getter method for this member

add_writer_tags(klass, new_method, member)

Creates the auto-generated docstring for the setter method of a struct‘s member. This is used so the generated documentation will look just like that of an attribute defined using attr_accessor.

@param [ClassObject] klass the class whose members we‘re working with @param [String] member the name of the member we‘re generating documentation for @return [String] a docstring to be attached to the setter method for this member

create_attributes(klass, members)

Creates the given member methods and attaches them to the given ClassObject.

@param [ClassObject] klass the class to generate attributes for @param [Array<String>] members a list of member names

create_class(classname, superclass)

Creates and registers a class object with the given name and superclass name. Returns it for further use.

@param [String] classname the name of the class @param [String] superclass the name of the superclass @return [ClassObject] the class object for further processing/method attaching

create_member_method?(klass, member, type = :read)

Determines whether to create an attribute method based on the class‘s tags.

@param [ClassObject] klass the class whose tags we‘re searching @param [String] member the name of the struct member we need @param [Symbol] type (:read) reader method, or writer method? @return [Boolean] should the attribute be created?

create_reader(klass, member)

Creates the getter (reader) method and attaches it to the class as an attribute. Also sets up the docstring to prettify the documentation output.

@param [ClassObject] klass the class to attach the method to @param [String] member the name of the member we‘re generating a method for

create_writer(klass, member)

Creates the setter (writer) method and attaches it to the class as an attribute. Also sets up the docstring to prettify the documentation output.

@param [ClassObject] klass the class to attach the method to @param [String] member the name of the member we‘re generating a method for

member_tag_for_member(klass, member, type = :read)

Extracts the user‘s defined @member tag for a given class and its member. Returns nil if the user did not define a @member tag for this struct entry.

@param [ClassObject] klass the class whose tags we‘re searching @param [String] member the name of the struct member we need @param [Symbol] type reader method, or writer method? @return [Tags::Tag, nil] the tag matching the request, or nil if not found

members_from_tags(klass)

Retrieves all members defined in @attr* tags

@param [ClassObject] klass the class with the attributes @return [Array<String>] the list of members defined as attributes on the class

return_type_from_tag(member_tag)

Gets the return type for the member in a nicely formatted string. Used to be injected into auto-generated docstrings.

@param [ClassObject] klass the class whose tags we‘re searching @param [String] member the name of the struct member whose return type we need @return [String] the user-declared type of the struct member, or [Object] if

      the user did not define a type for this member.

[Validate]