vue-router: finish scraper and filters

pull/881/head
Jasper van Merle 6 years ago
parent 63a8f840f3
commit 1c3a9761c6

@ -736,9 +736,9 @@ credits = [
'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
], [ ], [
'Vue Router', 'Vue Router',
'2013-2018 Evan You, Vue.js contributors', '2013-present Evan You',
'MIT', 'MIT',
'https://github.com/vuejs/vue-router/blob/dev/LICENSE' 'https://raw.githubusercontent.com/vuejs/vue-router/dev/LICENSE'
], [ ], [
'Vulkan', 'Vulkan',
'2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',

@ -11,4 +11,4 @@ module Docs
end end
end end
end end
end end

@ -3,16 +3,13 @@ module Docs
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
name = at_css('h1').content name = at_css('h1').content
name.remove! '# ' name.remove! '# '
name name
end end
def get_type def get_type
return 'Other Guides' if subpath.start_with?('guide/advanced') return 'Other Guides' if subpath.start_with?('guide/advanced')
return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation') return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation')
'API Reference' 'API Reference'
end end
@ -21,7 +18,7 @@ module Docs
end end
def additional_entries def additional_entries
return [] unless subpath.start_with?('api') return [] unless subpath.start_with?('api')
entries = [ entries = [
['<router-link>', 'router-link', 'API Reference'], ['<router-link>', 'router-link', 'API Reference'],
@ -31,7 +28,7 @@ module Docs
] ]
css('h3').each do |node| css('h3').each do |node|
entryName = node.content.strip entry_name = node.content.strip
# Get the previous h2 title # Get the previous h2 title
title = node title = node
@ -39,33 +36,36 @@ module Docs
title = title.content.strip title = title.content.strip
title.remove! '# ' title.remove! '# '
entryName.remove! '# ' entry_name.remove! '# '
if title == "Router Construction Options" case title
entryName = "RouterOptions.#{entryName}" when 'Router Construction Options'
elsif title == "<router-view> Props" entry_name = "RouterOptions.#{entry_name}"
entryName = "<router-view> `#{entryName}` prop" when '<router-view> Props'
elsif title == "<router-link> Props" entry_name = "<router-view> `#{entry_name}` prop"
entryName = "<router-link> `#{entryName}` prop" when '<router-link> Props'
elsif title == "Router Instance Methods" entry_name = "<router-link> `#{entry_name}` prop"
entryName = "#{entryName}()" when 'Router Instance Methods'
entry_name = "#{entry_name}()"
end end
unless title == "Component Injections" || node['id'] == 'applying-active-class-to-outer-element' || node['id'] == 'route-object-properties' entry_name = entry_name.split(' API ')[0] if entry_name.start_with?('v-slot')
entries << [entryName, node['id'], 'API Reference']
unless title == "Component Injections" || node['id'] == 'route-object-properties'
entries << [entry_name, node['id'], 'API Reference']
end end
end end
css('#route-object-properties + ul > li > p:first-child > strong').each do |node| css('#route-object-properties + ul > li > p:first-child > strong').each do |node|
entryName = node.content.strip entry_name = node.content.strip
id = "route-object-#{entryName.remove('$route.')}" id = "route-object-#{entry_name.remove('$route.')}"
node['id'] = id node['id'] = id
entries << [entryName, node['id'], 'API Reference'] entries << [entry_name, node['id'], 'API Reference']
end end
entries entries
end end
end end
end end
end end

@ -1,9 +1,10 @@
module Docs module Docs
class VueRouter < UrlScraper class VueRouter < UrlScraper
self.slug = 'vue_router'
self.name = 'Vue Router' self.name = 'Vue Router'
self.slug = 'vue_router'
self.type = 'simple' self.type = 'simple'
self.release = '3.1.2'
self.base_url = 'https://router.vuejs.org/'
self.links = { self.links = {
home: 'https://router.vuejs.org', home: 'https://router.vuejs.org',
code: 'https://github.com/vuejs/vue-router' code: 'https://github.com/vuejs/vue-router'
@ -11,17 +12,18 @@ module Docs
html_filters.push 'vue_router/entries', 'vue_router/clean_html' html_filters.push 'vue_router/entries', 'vue_router/clean_html'
self.release = '3.0.1'
self.base_url = 'https://router.vuejs.org/'
options[:skip_patterns] = [ options[:skip_patterns] = [
# Other languages # Other languages
/^(zh|ja|ru|kr|fr)\//, /^(zh|ja|ru|kr|fr)\//,
] ]
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2013&ndash;2018 Evan You, Vue.js contributors<br> &copy; 2013&ndash;present Evan You<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def get_latest_version(opts)
get_latest_github_release('vuejs', 'vue-router', opts)
end
end end
end end

@ -1 +1 @@
http://vuejs.org/ https://github.com/vuejs/vuejs.org/blob/master/assets/logo.ai

Loading…
Cancel
Save