Class: SupportTableData::Documentation::YardDoc

Inherits:
Object
  • Object
show all
Defined in:
lib/support_table_data/documentation/yard_doc.rb

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ YardDoc

Returns a new instance of YardDoc.

Parameters:

  • klass (Class)

    The model class to generate documentation for



7
8
9
# File 'lib/support_table_data/documentation/yard_doc.rb', line 7

def initialize(klass)
  @klass = klass
end

Instance Method Details

#attribute_helper_yard_doc(name, attribute_name) ⇒ String

Generate YARD documentation comment for the attribute method helper for the named instance.

Parameters:

  • name (String)

    The name of the instance method.

Returns:

  • (String)

    The YARD comment text



52
53
54
55
56
57
58
59
60
61
# File 'lib/support_table_data/documentation/yard_doc.rb', line 52

def attribute_helper_yard_doc(name, attribute_name)
  <<~YARD.chomp("\n")
    # Get the #{attribute_name} attribute from the data file
    # for the named instance +#{name}+.
    #
    # @!method self.#{name}_#{attribute_name}
    # @return [Object]
    # @!visibility public
  YARD
end

#instance_helper_yard_doc(name) ⇒ String

Generate YARD documentation comment for named instance singleton method.

Parameters:

  • name (String)

    The name of the instance method.

Returns:

  • (String)

    The YARD comment text



23
24
25
26
27
28
29
30
31
32
# File 'lib/support_table_data/documentation/yard_doc.rb', line 23

def instance_helper_yard_doc(name)
  <<~YARD.chomp("\n")
    # Find the named instance +#{name}+ from the database.
    #
    # @!method self.#{name}
    # @return [#{klass.name}]
    # @raise [ActiveRecord::RecordNotFound] if the record does not exist
    # @!visibility public
  YARD
end

#named_instance_yard_docsString?

Generate YARD documentation class definition for the model’s helper methods.

Returns:

  • (String, nil)

    The YARD documentation class definition, or nil if no named instances



14
15
16
17
# File 'lib/support_table_data/documentation/yard_doc.rb', line 14

def named_instance_yard_docs
  instance_names = klass.instance_names
  generate_yard_docs(instance_names)
end

#predicate_helper_yard_doc(name) ⇒ String

Generate YARD documentation comment for the predicate method for the named instance.

Parameters:

  • name (String)

    The name of the instance method.

Returns:

  • (String)

    The YARD comment text



38
39
40
41
42
43
44
45
46
# File 'lib/support_table_data/documentation/yard_doc.rb', line 38

def predicate_helper_yard_doc(name)
  <<~YARD.chomp("\n")
    # Check if this record is the named instance +#{name}+.
    #
    # @!method #{name}?
    # @return [Boolean]
    # @!visibility public
  YARD
end