[devdocsgjs/main: 1463/1867] Add Socketio version 2 and 3




commit 96930b75c535585e59b57610c6820cc25c897b62
Author: MasterEnoc <brianhernandez222 hotmail com>
Date:   Tue Jan 5 13:01:23 2021 -0600

    Add Socketio version 2 and 3

 lib/docs/filters/socketio/clean_html.rb | 14 ++++++++------
 lib/docs/filters/socketio/entries.rb    |  6 +++++-
 lib/docs/scrapers/socketio.rb           | 18 +++++++++++++-----
 3 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/lib/docs/filters/socketio/clean_html.rb b/lib/docs/filters/socketio/clean_html.rb
index bbe404f7..98f8d164 100644
--- a/lib/docs/filters/socketio/clean_html.rb
+++ b/lib/docs/filters/socketio/clean_html.rb
@@ -2,17 +2,19 @@ module Docs
   class Socketio
     class CleanHtmlFilter < Filter
       def call
-        @doc = at_css('.entry-content')
 
         css('p > br').each do |node|
           node.remove unless node.next.content =~ /\s*\-/
         end
 
-        css('h1, h2, h3').each do |node|
-          next if node == doc.first_element_child
-          node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
-          node['id'] = node.content.strip.parameterize
-        end
+        # version documentation message
+        css('.warning').remove
+
+        css('header').remove
+
+        css('aside').remove
+
+        css('footer').remove
 
         css('pre').each do |node|
           node.content = node.content
diff --git a/lib/docs/filters/socketio/entries.rb b/lib/docs/filters/socketio/entries.rb
index 656931a2..ee76d4dd 100644
--- a/lib/docs/filters/socketio/entries.rb
+++ b/lib/docs/filters/socketio/entries.rb
@@ -6,7 +6,11 @@ module Docs
       end
 
       def get_type
-        'Guides'
+        if slug =~ /events|room|emit/ && version.eql?('3')
+          'Events'
+        else
+          'Guides'
+        end
       end
 
       def additional_entries
diff --git a/lib/docs/scrapers/socketio.rb b/lib/docs/scrapers/socketio.rb
index e9bc264a..f3fc8fee 100644
--- a/lib/docs/scrapers/socketio.rb
+++ b/lib/docs/scrapers/socketio.rb
@@ -3,8 +3,6 @@ module Docs
     self.name = 'Socket.IO'
     self.slug = 'socketio'
     self.type = 'socketio'
-    self.release = '1.4.5'
-    self.base_url = 'http://socket.io/docs/'
     self.links = {
       home: 'http://socket.io/',
       code: 'https://github.com/socketio/socket.io'
@@ -12,17 +10,27 @@ module Docs
 
     html_filters.push 'socketio/clean_html', 'socketio/entries'
 
-    options[:container] = '#content'
     options[:trailing_slash] = false
-    options[:skip] = %w(faq)
+    options[:skip] = %w(/faq /glossary)
 
     options[:attribution] = <<-HTML
-      &copy; 2014&ndash;2015 Automattic<br>
+      &copy; 2014&ndash;2020 Automattic<br>
       Licensed under the MIT License.
     HTML
 
+    version '3' do
+      self.release = '3.0.5'
+      self.base_url = "https://socket.io/docs/v#{version}";
+    end
+
+    version '2' do
+      self.release = '2.4.0'
+      self.base_url = "https://socket.io/docs/v#{version}";
+    end
+
     def get_latest_version(opts)
       get_npm_version('socket.io', opts)
     end
+
   end
 end


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