Class: SupportTableData::Documentation::YardDoc
- Inherits:
-
Object
- Object
- SupportTableData::Documentation::YardDoc
- Defined in:
- lib/support_table_data/documentation/yard_doc.rb
Constant Summary collapse
- MACRO_FINDER =
"support_table_data_finder"- MACRO_PREDICATE =
"support_table_data_predicate"- MACRO_ATTRIBUTE =
"support_table_data_attribute"
Instance Method Summary collapse
-
#attribute_helper_yard_doc(name, attribute_name) ⇒ String
Generate YARD documentation comment for the attribute method helper for the named instance.
-
#initialize(klass) ⇒ YardDoc
constructor
A new instance of YardDoc.
-
#instance_helper_yard_doc(name) ⇒ String
Generate YARD documentation comment for named instance singleton method.
-
#named_instance_yard_docs ⇒ String?
Generate YARD documentation for the model’s helper methods.
-
#predicate_helper_yard_doc(name) ⇒ String
Generate YARD documentation comment for the predicate method for the named instance.
Constructor Details
#initialize(klass) ⇒ YardDoc
Returns a new instance of YardDoc.
11 12 13 |
# File 'lib/support_table_data/documentation/yard_doc.rb', line 11 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.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/support_table_data/documentation/yard_doc.rb', line 74 def attribute_helper_yard_doc(name, attribute_name) return_type = attribute_yard_return_type(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 [#{return_type}] # @!visibility public YARD end |
#instance_helper_yard_doc(name) ⇒ String
Generate YARD documentation comment for named instance singleton method.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/support_table_data/documentation/yard_doc.rb', line 44 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_docs ⇒ String?
Generate YARD documentation for the model’s helper methods. The format is controlled by the model’s ‘support_table_yard_docs` setting:
-
‘:full` - verbose comment block per method (default)
-
‘:compact` - shared @!macro definitions plus a short @!method/@!macro
pair per generated method -
‘:none` - generate no docs at all
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/support_table_data/documentation/yard_doc.rb', line 26 def named_instance_yard_docs return nil if klass.support_table_yard_docs == :none instance_names = klass.instance_names return nil if instance_names.empty? case klass.support_table_yard_docs when :compact generate_compact_yard_docs(instance_names) else generate_verbose_yard_docs(instance_names) end end |
#predicate_helper_yard_doc(name) ⇒ String
Generate YARD documentation comment for the predicate method for the named instance.
59 60 61 62 63 64 65 66 67 |
# File 'lib/support_table_data/documentation/yard_doc.rb', line 59 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 |