History

Merge pull request #1459 from MasterEnoc/socketio

Add Socketio version 2 and 3

Simon Legner committed 5 years ago

Commit 2e6d7952 parents d03c98e 96930b73 files · +26 −12Browse files

Unified · Split

3 files
  1. lib/docs/filters/socketio/clean_html.rb +8 −6
  2. lib/docs/filters/socketio/entries.rb +5 −1
  3. lib/docs/scrapers/socketio.rb +13 −5
lib/docs/filters/socketio/clean_html.rb+8−6
@@ -2,17 +2,19 @@ module Docs · 1 unmodified line
2 class Socketio2 class Socketio
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 @doc = at_css('.entry-content')
6 5
7 css('p > br').each do |node|6 css('p > br').each do |node|
8 node.remove unless node.next.content =~ /\s*\-/7 node.remove unless node.next.content =~ /\s*\-/
9 end8 end
10 9
11 css('h1, h2, h3').each do |node|10 # version documentation message
12 next if node == doc.first_element_child11 css('.warning').remove
13 node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }12
14 node['id'] = node.content.strip.parameterize13 css('header').remove
15 end14
15 css('aside').remove
16
17 css('footer').remove
16 18
17 css('pre').each do |node|19 css('pre').each do |node|
18 node.content = node.content20 node.content = node.content
lib/docs/filters/socketio/entries.rb+5−1
@@ -6,7 +6,11 @@ module Docs · 5 unmodified lines
6 end6 end
7 7
8 def get_type8 def get_type
9 'Guides'9 if slug =~ /events|room|emit/ && version.eql?('3')
10 'Events'
11 else
12 'Guides'
13 end
10 end14 end
11 15
12 def additional_entries16 def additional_entries
lib/docs/scrapers/socketio.rb+13−5
@@ -3,8 +3,6 @@ module Docs · 2 unmodified lines
3 self.name = 'Socket.IO'3 self.name = 'Socket.IO'
4 self.slug = 'socketio'4 self.slug = 'socketio'
5 self.type = 'socketio'5 self.type = 'socketio'
6 self.release = '1.4.5'
7 self.base_url = 'http://socket.io/docs/'
8 self.links = {6 self.links = {
9 home: 'http://socket.io/',7 home: 'http://socket.io/',
10 code: 'https://github.com/socketio/socket.io'8 code: 'https://github.com/socketio/socket.io'
@@ -12,17 +10,27 @@ module Docs · 1 unmodified line
12 10
13 html_filters.push 'socketio/clean_html', 'socketio/entries'11 html_filters.push 'socketio/clean_html', 'socketio/entries'
14 12
15 options[:container] = '#content'
16 options[:trailing_slash] = false13 options[:trailing_slash] = false
17 options[:skip] = %w(faq)14 options[:skip] = %w(/faq /glossary)
18 15
19 options[:attribution] = <<-HTML16 options[:attribution] = <<-HTML
20 &copy; 2014&ndash;2015 Automattic<br>17 &copy; 2014&ndash;2020 Automattic<br>
21 Licensed under the MIT License.18 Licensed under the MIT License.
22 HTML19 HTML
23 20
21 version '3' do
22 self.release = '3.0.5'
23 self.base_url = "https://socket.io/docs/v#{version}"
24 end
25
26 version '2' do
27 self.release = '2.4.0'
28 self.base_url = "https://socket.io/docs/v#{version}"
29 end
30
24 def get_latest_version(opts)31 def get_latest_version(opts)
25 get_npm_version('socket.io', opts)32 get_npm_version('socket.io', opts)
26 end33 end
34
27 end35 end
28end36end