Class: YardJunk::Janitor::Resolver
- Inherits:
-
Object
- Object
- YardJunk::Janitor::Resolver
- Includes:
- YARD::Templates::Helpers::HtmlHelper, YARD::Templates::Helpers::MarkupHelper
- Defined in:
- lib/yard-junk/janitor/resolver.rb
Constant Summary collapse
- OBJECT_MESSAGE_PATTERN =
This one is copied from real YARD output
"In file `%{file}':%{line}: " \ 'Cannot resolve link to %{name} from text: %{link}'
- FILE_MESSAGE_PATTERN =
…while this one is totally invented, YARD doesn’t check file existance at all
"In file `%{file}':%{line}: File '%{name}' does not exist: %{link}"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(object, yard_options) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve ⇒ Object
Constructor Details
#initialize(object, yard_options) ⇒ Resolver
Returns a new instance of Resolver.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/yard-junk/janitor/resolver.rb', line 21 def initialize(object, ) @options = case object when YARD::CodeObjects::ExtraFileObject init_file(object) when YARD::Docstring init_docstring(object) else fail "Unknown object to resolve #{object.class}" end end |
Class Method Details
.resolve_all(yard_options) ⇒ Object
16 17 18 19 |
# File 'lib/yard-junk/janitor/resolver.rb', line 16 def self.resolve_all() YARD::Registry.all.map(&:base_docstring).each { |ds| new(ds, ).resolve } .files.each { |file| new(file, ).resolve } end |
Instance Method Details
#resolve ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/yard-junk/janitor/resolver.rb', line 33 def resolve markup_meth = "html_markup_#{markup}" return unless respond_to?(markup_meth) send(markup_meth, @string) .gsub(%r{<(code|tt|pre)[^>]*>(.*?)</\1>}im, '') .scan(/{[^}]+}/).flatten .map(&CGI.method(:unescapeHTML)) .each(&method(:try_resolve)) end |