Ver código fonte

Add Socket.IO documentation

Thibaut 11 anos atrás
pai
commit
34934b27cb

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,6 +1,6 @@
 [
   [ "2014-12-21",
-    "New <a href=\"/react/\">React</a> and <a href=\"/rethinkdb/\">RethinkDB</a> documentations"
+    "New <a href=\"/react/\">React</a>, <a href=\"/rethinkdb/\">RethinkDB</a> and <a href=\"/socketio/\">Socket.IO</a> documentations"
   ], [
     "2014-11-30",
     "New <a href=\"/phpunit/\">PHPUnit</a> and <a href=\"/nokogiri/\">Nokogiri</a> documentations"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -293,6 +293,11 @@ credits = [
     '2010-2014 Christian Johansen',
     'BSD',
     'https://raw.githubusercontent.com/cjohansen/Sinon.JS/master/LICENSE'
+  ], [
+    'Socket.io',
+    '2014 Automattic',
+    'MIT',
+    'https://raw.githubusercontent.com/Automattic/socket.io/master/LICENSE'
   ], [
     'Underscore.js',
     '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',

+ 4 - 0
assets/javascripts/views/pages/socketio.coffee

@@ -0,0 +1,4 @@
+#= require views/pages/base
+#= require views/pages/requirejs
+
+app.views.SocketioPage = app.views.RequirejsPage

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -63,6 +63,7 @@
         'pages/rethinkdb',
         'pages/rfc',
         'pages/sinon',
+        'pages/socketio',
         'pages/sphinx',
         'pages/underscore',
         'pages/yard',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -74,3 +74,4 @@
 ._icon-nokogiri:before      { background-position: -4rem -11rem; }
 ._icon-rethinkdb:before     { background-position: 0 -12rem; }
 ._icon-react:before         { background-position: -1rem -12rem; }
+._icon-socketio:before      { background-position: -2rem -12rem; }

+ 24 - 0
assets/stylesheets/pages/_socketio.scss

@@ -0,0 +1,24 @@
+._socketio {
+  > h2 { @extend %block-heading; }
+  > h3 { @extend %block-label, %label-blue; }
+  > h2, > h3 { clear: both; }
+  h4 { font-size: 1em; }
+
+  .ezcol-one-half {
+    margin: .5em 0 1.5em;
+    float: left;
+    width: 50%;
+    padding-right: .5em;
+    @extend %border-box;
+
+    &.ezcol-last {
+      float: right;
+      padding: 0 0 0 .5em;
+    }
+
+    > h4 { margin: 0 0 1em; }
+    > pre { margin: 1em 0 0; }
+  }
+
+  code { @extend %label; }
+}

+ 25 - 0
lib/docs/filters/socketio/clean_html.rb

@@ -0,0 +1,25 @@
+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
+
+        css('pre').each do |node|
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 27 - 0
lib/docs/filters/socketio/entries.rb

@@ -0,0 +1,27 @@
+module Docs
+  class Socketio
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('h1').content
+      end
+
+      def get_type
+        'Guides'
+      end
+
+      def additional_entries
+        return [] unless slug.end_with?('api')
+
+        css('h3').each_with_object([]) do |node, entries|
+          name = node.content
+          name.remove! %r{\(.*}
+          name.remove! %r{\:.*}
+
+          unless entries.any? { |entry| entry[0] == name }
+            entries << [name, node['id'], self.name.remove(' API')]
+          end
+        end
+      end
+    end
+  end
+end

+ 20 - 0
lib/docs/scrapers/socketio.rb

@@ -0,0 +1,20 @@
+module Docs
+  class Socketio < UrlScraper
+    self.name = 'Socket.IO'
+    self.slug = 'socketio'
+    self.type = 'socketio'
+    self.version = '1.2.1'
+    self.base_url = 'http://socket.io/docs/'
+
+    html_filters.push 'socketio/clean_html', 'socketio/entries'
+
+    options[:container] = '#content'
+    options[:trailing_slash] = false
+    options[:skip] = %w(faq)
+
+    options[:attribution] = <<-HTML
+      &copy; 2014 Automattic<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

BIN
public/icons/docs/socketio/16.png


BIN
public/icons/docs/socketio/16@2x.png


+ 1 - 0
public/icons/docs/socketio/SOURCE

@@ -0,0 +1 @@
+http://socket.io/