Skip to content

Commit

Permalink
fix rubocop issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim committed Oct 24, 2015
1 parent 987ad2b commit 591f71d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/jazzy/sourcekitten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,19 +312,21 @@ def self.filter_excluded_files(json)
end

def self.names_and_urls(docs)
names_and_urls = docs.flat_map do |doc|
docs.flat_map do |doc|
# FIXME: autolink more than just top-level items.
[{:name => doc.name, :url => doc.url}] # + names_and_urls(doc.children)
[{ name: doc.name, url: doc.url }] # + names_and_urls(doc.children)
end
end

def self.autolink_text(text, data, url)
text.gsub(/\b(#{data.map { |d| Regexp.escape(d[:name]) }.join('|')})\b/) do
auto_url = data.find { |d| d[:name] == $1 }[:url]
unless auto_url == url # docs shouldn't autolink to themselves
"<a href=\"#{ELIDED_AUTOLINK_TOKEN}#{auto_url}\">#{$1}</a>"
regex = /\b(#{data.map { |d| Regexp.escape(d[:name]) }.join('|')})\b/
text.gsub(regex) do
name = Regexp.last_match(1)
auto_url = data.find { |d| d[:name] == name }[:url]
if auto_url == url # docs shouldn't autolink to themselves
Regexp.last_match(0)
else
$1
"<a href=\"#{ELIDED_AUTOLINK_TOKEN}#{auto_url}\">#{name}</a>"
end
end
end
Expand All @@ -351,7 +353,7 @@ def self.parse(sourcekitten_output, min_acl, skip_undocumented)
# than min_acl
docs = docs.reject { |doc| doc.type.enum_element? }
docs = make_doc_urls(docs, [])
docs = autolink(docs, names_and_urls(docs.flat_map { |d| d.children }))
docs = autolink(docs, names_and_urls(docs.flat_map(&:children)))
[docs, doc_coverage, @undocumented_tokens]
end
end
Expand Down

0 comments on commit 591f71d

Please sign in to comment.