Ver código fonte

vue-router: finish scraper and filters

Jasper van Merle 6 anos atrás
pai
commit
1c3a9761c6

+ 2 - 2
assets/javascripts/templates/pages/about_tmpl.coffee

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

+ 1 - 1
lib/docs/filters/vue_router/clean_html.rb

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

+ 20 - 20
lib/docs/filters/vue_router/entries.rb

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

+ 8 - 6
lib/docs/scrapers/vue_router.rb

@@ -1,9 +1,10 @@
 module Docs
   class VueRouter < UrlScraper
-    self.slug = 'vue_router'
     self.name = 'Vue Router'
+    self.slug = 'vue_router'
     self.type = 'simple'
-
+    self.release = '3.1.2'
+    self.base_url = 'https://router.vuejs.org/'
     self.links = {
       home: 'https://router.vuejs.org',
       code: 'https://github.com/vuejs/vue-router'
@@ -11,17 +12,18 @@ module Docs
 
     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] = [
       # Other languages
       /^(zh|ja|ru|kr|fr)\//,
     ]
 
     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.
     HTML
+
+    def get_latest_version(opts)
+      get_latest_github_release('vuejs', 'vue-router', opts)
+    end
   end
 end

+ 1 - 1
public/icons/docs/vue_router/SOURCE

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