Class: YARD::Readme::TagFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/yard/readme/tag_factory.rb

Overview

Custom tag factory that overrides the default YARD tag factory to provide special handling for @readme tags. Specifically, it ensures that blank or empty @readme tags are properly processed.

Instance Method Summary collapse

Instance Method Details

#blank_readme_tag?(tag_name, text) ⇒ Boolean

Checks if a tag is a blank @readme tag (no content). This helper method is used to determine whether special handling is needed for a given tag.

Parameters:

  • tag_name (String)

    the name of the tag

  • text (String)

    the tag text

Returns:

  • (Boolean)

    true if the tag is a blank readme tag



37
38
39
# File 'lib/yard/readme/tag_factory.rb', line 37

def blank_readme_tag?(tag_name, text)
  tag_name == "readme" && text.nil? || text.empty?
end

#parse_tag_with_title_and_text(tag_name, text) ⇒ YARD::Tags::Tag

Overrides the default tag parsing behavior to handle blank @readme tags.

This method ensures that @readme tags without any text are properly handled, rather than being processed by the default YARD parser which expects title and text for tags defined with :with_title_and_text.

Parameters:

  • tag_name (String)

    the name of the tag

  • text (String)

    the tag text

Returns:

  • (YARD::Tags::Tag)

    the parsed tag

See Also:



22
23
24
25
26
# File 'lib/yard/readme/tag_factory.rb', line 22

def parse_tag_with_title_and_text(tag_name, text)
  return YARD::Tags::Tag.new(tag_name, text) if blank_readme_tag?(tag_name, text)

  super
end