Class: YardJunk::Janitor::Resolver

Inherits:
Object
  • Object
show all
Includes:
YARD::Templates::Helpers::HtmlHelper
Defined in:
lib/yard-junk/janitor/resolver.rb

Overview

TODO: Tests

Constant Summary collapse

MESSAGE_PATTERN =
'In file `%{file}\':%{line}: Cannot resolve link to %{name} from text: %{link}'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(docstring, yard_options) ⇒ Resolver

Returns a new instance of Resolver.



15
16
17
18
# File 'lib/yard-junk/janitor/resolver.rb', line 15

def initialize(docstring, yard_options)
  @docstring = docstring
  @options = yard_options
end

Class Method Details

.resolve_all(yard_options) ⇒ Object



11
12
13
# File 'lib/yard-junk/janitor/resolver.rb', line 11

def self.resolve_all(yard_options)
  YARD::Registry.all.map(&:base_docstring).each { |ds| new(ds, yard_options).resolve }
end

Instance Method Details

#resolveObject



20
21
22
23
24
25
26
27
28
# File 'lib/yard-junk/janitor/resolver.rb', line 20

def resolve
  markup_meth = "html_markup_#{options.markup}"
  return unless respond_to?(markup_meth)
  send(markup_meth, @docstring)
    .gsub(%r{<(code|tt|pre)[^>]*>(.*?)</\1>}im, '')
    .scan(/{[^}]+}/).flatten
    .map(&CGI.method(:unescapeHTML))
    .each(&method(:try_resolve))
end