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
22 class Socketio
33 class CleanHtmlFilter < Filter
44 def call
5− @doc = at_css('.entry-content')
65
76 css('p > br').each do |node|
87 node.remove unless node.next.content =~ /\s*\-/
98 end
109
11− css('h1, h2, h3').each do |node|
12− next if node == doc.first_element_child
13− node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
14− node['id'] = node.content.strip.parameterize
15− end
10+ # version documentation message
11+ css('.warning').remove
12+
13+ css('header').remove
14+
15+ css('aside').remove
16+
17+ css('footer').remove
1618
1719 css('pre').each do |node|
1820 node.content = node.content
lib/docs/filters/socketio/entries.rb+5−1
@@ -6,7 +6,11 @@ module Docs · 5 unmodified lines
66 end
77
88 def get_type
9− 'Guides'
9+ if slug =~ /events|room|emit/ && version.eql?('3')
10+ 'Events'
11+ else
12+ 'Guides'
13+ end
1014 end
1115
1216 def additional_entries
lib/docs/scrapers/socketio.rb+13−5
@@ -3,8 +3,6 @@ module Docs · 2 unmodified lines
33 self.name = 'Socket.IO'
44 self.slug = 'socketio'
55 self.type = 'socketio'
6− self.release = '1.4.5'
7− self.base_url = 'http://socket.io/docs/'
86 self.links = {
97 home: 'http://socket.io/',
108 code: 'https://github.com/socketio/socket.io'
@@ -12,17 +10,27 @@ module Docs · 1 unmodified line
1210
1311 html_filters.push 'socketio/clean_html', 'socketio/entries'
1412
15− options[:container] = '#content'
1613 options[:trailing_slash] = false
17− options[:skip] = %w(faq)
14+ options[:skip] = %w(/faq /glossary)
1815
1916 options[:attribution] = <<-HTML
20− &copy; 2014&ndash;2015 Automattic<br>
17+ &copy; 2014&ndash;2020 Automattic<br>
2118 Licensed under the MIT License.
2219 HTML
2320
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+
2431 def get_latest_version(opts)
2532 get_npm_version('socket.io', opts)
2633 end
34+
2735 end
2836 end