ソースを参照

Add Socketio version 2 and 3

MasterEnoc 4 年 前
コミット
96930b75c5

+ 8 - 6
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

+ 5 - 1
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

+ 13 - 5
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