Class: SettingsHandlerBase

Inherits:
YARD::Handlers::Ruby::Base
  • Object
show all
Defined in:
lib/yard-settings/handler.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#first_line_of_description(object) ⇒ Object



33
34
35
36
37
# File 'lib/yard-settings/handler.rb', line 33

def first_line_of_description(object)
  return '' if object.docstring.blank?

  object.docstring.lines.first
end

#processObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/yard-settings/handler.rb', line 9

def process
  name = statement.parameters.first.jump(:tstring_content, :ident).source
  object = YARD::CodeObjects::MethodObject.new(namespace, name)
  register(object)

  # Modify the code object for the new instance method
  object.dynamic = true
  # Add custom metadata to the object
  object['custom_field'] = '(Found using method_missing)'

  # Module-level configuration notes
  hutch_config = YARD::CodeObjects::ModuleObject.new(:root, "Hutch::Config")
  collection_name = statement.first.first
  default_value = statement.parameters[1].jump(:tstring_content, :ident).source

  (hutch_config['setting_rows'] ||= []) << {
    name: name,
    default_value: default_value,
    type: collection_name.sub('_setting', '').capitalize,
    description: object.docstring,
    first_line_of_description: first_line_of_description(object)
  }
end