Prechádzať zdrojové kódy

Update Vuex documentation (3.6.2 and 4.0.0-rc.2)

Simon Legner 4 rokov pred
rodič
commit
bf248f0dff

+ 2 - 2
lib/docs/core/doc.rb

@@ -246,9 +246,9 @@ module Docs
       JSON.parse fetch(url, opts)
     end
 
-    def get_npm_version(package, opts)
+    def get_npm_version(package, opts, tag='latest')
       json = fetch_json("https://registry.npmjs.com/#{package}", opts)
-      json['dist-tags']['latest']
+      json['dist-tags'][tag]
     end
 
     def get_latest_github_release(owner, repo, opts)

+ 8 - 1
lib/docs/filters/vuex/clean_html.rb

@@ -2,7 +2,7 @@ module Docs
   class Vuex
     class CleanHtmlFilter < Filter
       def call
-        @doc = at_css('.content')
+        @doc = at_css('main')
 
         # Remove video from root page
         css('a[href="#"]').remove if root_page?
@@ -10,6 +10,13 @@ module Docs
         # Remove unneeded elements
         css('.header-anchor').remove
 
+        # Remove data-v-* attributes
+        css('*').each do |node|
+          node.attributes.each_key do |attribute|
+            node.remove_attribute(attribute) if attribute.start_with? 'data-v-'
+          end
+        end
+
         doc
       end
     end

+ 11 - 3
lib/docs/scrapers/vuex.rb

@@ -1,8 +1,6 @@
 module Docs
   class Vuex < UrlScraper
     self.type = 'simple'
-    self.release = '3.1.1'
-    self.base_url = 'https://vuex.vuejs.org/'
     self.links = {
       home: 'https://vuex.vuejs.org',
       code: 'https://github.com/vuejs/vuex'
@@ -20,8 +18,18 @@ module Docs
       Licensed under the MIT License.
     HTML
 
+    version '4' do
+      self.release = '4.0.0-rc.2'
+      self.base_url = 'https://next.vuex.vuejs.org/'
+    end
+
+    version '3' do
+      self.release = '3.6.2'
+      self.base_url = 'https://vuex.vuejs.org/'
+    end
+
     def get_latest_version(opts)
-      get_npm_version('vuex', opts)
+      get_npm_version('vuex', opts, 'next')
     end
   end
 end