[devdocsgjs/main: 1478/1867] Update Vuex documentation (3.6.2 and 4.0.0-rc.2)




commit bf248f0dff1cd10d8055e15d377707895061d013
Author: Simon Legner <Simon Legner gmail com>
Date:   Sat Jan 30 00:32:43 2021 +0100

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

 lib/docs/core/doc.rb                |  4 ++--
 lib/docs/filters/vuex/clean_html.rb |  9 ++++++++-
 lib/docs/scrapers/vuex.rb           | 14 +++++++++++---
 3 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb
index 5eae27aa..88080328 100644
--- a/lib/docs/core/doc.rb
+++ b/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)
diff --git a/lib/docs/filters/vuex/clean_html.rb b/lib/docs/filters/vuex/clean_html.rb
index 4aad55a9..e6875441 100644
--- a/lib/docs/filters/vuex/clean_html.rb
+++ b/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
diff --git a/lib/docs/scrapers/vuex.rb b/lib/docs/scrapers/vuex.rb
index 57e761ce..223d9854 100644
--- a/lib/docs/scrapers/vuex.rb
+++ b/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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]