Method: YARD::CodeObjects::MacroObject.apply_macro

Defined in:
lib/yard/code_objects/macro_object.rb

.apply_macro(macro, docstring, call_params = [], full_source = '', block_source = '') ⇒ String

Applies a macro to a docstring, interpolating the macro’s data on the docstring and appending any extra local docstring data that was in the original docstring object.

Parameters:

  • macro (MacroObject)

    the macro object

  • call_params (Array<String>) (defaults to: [])

    the method name and parameters to the method call. These arguments will fill $0-N

  • full_source (String) (defaults to: '')

    the full source line (excluding block) interpolated as $*

  • block_source (String) (defaults to: '')

    Currently unused. Will support interpolating the block data as a variable.

Returns:

  • (String)

    the expanded macro data



131
132
133
134
135
136
137
138
139
140
# File 'lib/yard/code_objects/macro_object.rb', line 131

def apply_macro(macro, docstring, call_params = [], full_source = '', block_source = '')
  docstring = Docstring.new(docstring) unless Docstring === docstring
  data = []
  data << macro.expand(call_params, full_source, block_source) if macro
  if !macro && new_macro?(docstring)
    data << expand(macro_data(docstring), call_params, full_source, block_source)
  end
  data << nonmacro_data(docstring)
  data.join("\n").strip
end