Class: MarkdownRubyDocumentation::TemplateParser::CommentMacros::MethodLink

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown_ruby_documentation/template_parser.rb

Constant Summary collapse

RUBY_METHOD_REGEX =
/(\b(?<!['"])[a-z_][a-z_0-9?!]*(?!['"]))/.freeze

Instance Method Summary collapse

Constructor Details

#initialize(match:, call_on_title: :titleize, method_to_class: {}, link_to_markdown:, ruby_class:) ⇒ MethodLink

Returns a new instance of MethodLink.



303
304
305
306
307
308
309
310
311
312
313
# File 'lib/markdown_ruby_documentation/template_parser.rb', line 303

def initialize(match:,
               call_on_title: :titleize,
               method_to_class: {},
               link_to_markdown:,
               ruby_class:)
  @match            = match
  @ruby_class       = ruby_class
  @call_on_title    = call_on_title
  @method_to_class  = method_to_class
  @link_to_markdown = link_to_markdown
end

Instance Method Details



315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/markdown_ruby_documentation/template_parser.rb', line 315

def link
  if constant_override
    constant_override_method_path
  else
    link = link_to_markdown.call(method_name, title: title, _ruby_class: method_owner)
    if link == :non_project_location
      match
    else
      link
    end
  end
rescue UnimplementedMethod => e
  "[#{title}](##{match.downcase.dasherize.delete(" ").delete('?').delete("!")})"
end