Shorter, more readable names

pull/840/head
Jasper van Merle 7 years ago
parent 843578b48e
commit 14cf0582c3

@ -2,14 +2,28 @@ module Docs
class Dart
class EntriesFilter < Docs::EntriesFilter
def get_name
title = get_title
kind = get_kind
breadcrumbs = at_css('.breadcrumbs').css('li:not(.self-crumb) > a')
breadcrumbs = breadcrumbs.length == 1 ? [] : breadcrumbs.slice(1..-1).map {|node| node.content}
first_part = ''
if breadcrumbs.length == 2 && !kind.include?('class')
first_part = breadcrumbs[1].content
elsif breadcrumbs.length == 3
first_part = breadcrumbs[2].content
end
first_part = breadcrumbs.join(':')
separator = first_part.empty? ? '' : ':'
last_part = get_title
separator = ''
unless first_part.empty?
if kind.include?('class')
separator = ':'
else
separator = '.'
end
end
first_part + separator + last_part
first_part + separator + title
end
def get_type
@ -27,6 +41,18 @@ module Docs
at_css('.main-content > h1').content[/(.*)( )/, 1].split(' top-level')[0]
end
end
def get_kind
title = at_css('h1.title')
if not title.nil?
# v1
title.at_css('.kind').content
else
# v2
at_css('.main-content > h1').content[/(.*)( )(.+)/, 3]
end
end
end
end
end

Loading…
Cancel
Save