Browse Source

Add RethinkDB documentation

Thibaut 11 years ago
parent
commit
79e574e695

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


+ 4 - 1
assets/javascripts/news.json

@@ -1,5 +1,8 @@
 [
-  [ "2014-11-30",
+  [ "2014-12-20",
+    "New <a href=\"/rethinkdb/\">RethinkDB</a> documentation"
+  ], [
+    "2014-11-30",
     "New <a href=\"/phpunit/\">PHPUnit</a> and <a href=\"/nokogiri/\">Nokogiri</a> documentations"
   ], [
     "2014-11-16",

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

@@ -263,6 +263,11 @@ credits = [
     '2010-2014 The Dojo Foundation',
     'MIT',
     'https://raw.githubusercontent.com/jrburke/requirejs/master/LICENSE'
+  ], [
+    'RethinkDB',
+    'RethinkDB contributors',
+    'CC BY-SA',
+    'https://raw.githubusercontent.com/rethinkdb/docs/master/LICENSE'
   ], [
     'Ruby',
     '1993-2014 Yukihiro Matsumoto',

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

@@ -0,0 +1,4 @@
+#= require views/pages/base
+#= require views/pages/underscore
+
+app.views.RethinkdbPage = app.views.UnderscorePage

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

@@ -59,6 +59,7 @@
         'pages/rdoc',
         'pages/redis',
         'pages/requirejs',
+        'pages/rethinkdb',
         'pages/rfc',
         'pages/sinon',
         'pages/sphinx',

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

@@ -4,7 +4,7 @@
   width: 1rem;
   height: 1rem;
   background-image: image-url('icons.png');
-  background-size: 5rem 12rem;
+  background-size: 5rem 13rem;
 }
 
 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -72,3 +72,4 @@
 ._icon-mongoose:before      { background-position: -2rem -11rem; }
 ._icon-phpunit:before       { background-position: -3rem -11rem; }
 ._icon-nokogiri:before      { background-position: -4rem -11rem; }
+._icon-rethinkdb:before     { background-position: 0 -12rem; }

+ 9 - 0
assets/stylesheets/pages/_rethinkdb.scss

@@ -0,0 +1,9 @@
+._rethinkdb {
+  > h2 { @extend %block-heading; }
+  code { @extend %label; }
+
+  .api_command_illustration {
+    float: right;
+    margin: 0 0 1em 1em;
+  }
+}

+ 38 - 0
lib/docs/filters/rethinkdb/clean_html.rb

@@ -0,0 +1,38 @@
+module Docs
+  class Rethinkdb
+    class CleanHtmlFilter < Filter
+      def call
+        if root_page?
+          doc.inner_html = '<h1>ReQL command reference</h1>'
+          return doc
+        end
+
+        css('#api-header').each do |node|
+          node.replace(node.at_css('h1'))
+        end
+
+        css('.linksbox-container').remove
+
+        css('.highlight').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('.command-body').each do |node|
+          node.name = 'pre'
+          node.inner_html = node.inner_html.gsub('</p>', "</p>\n")
+        end
+
+        css('pre').each do |node|
+          node.content = node.content
+        end
+
+        css('h1').each do |node|
+          next if node['class'].to_s.include?('title')
+          node.name = 'h2'
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 15 - 0
lib/docs/filters/rethinkdb/entries.rb

@@ -0,0 +1,15 @@
+module Docs
+  class Rethinkdb
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('.title').content.remove('ReQL command:')
+      end
+
+      def get_type
+        link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/javascript/"]')
+        dir = link['href'][/javascript\/([^\/]+)/, 1]
+        dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and')
+      end
+    end
+  end
+end

+ 22 - 0
lib/docs/scrapers/rethinkdb.rb

@@ -0,0 +1,22 @@
+module Docs
+  class Rethinkdb < UrlScraper
+    self.name = 'RethinkDB'
+    self.type = 'rethinkdb'
+    self.version = '1.15.2'
+    self.base_url = 'http://rethinkdb.com/api/javascript/'
+
+    html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html'
+
+    options[:trailing_slash] = false
+    options[:container] = '.container .section'
+
+    options[:fix_urls] = ->(url) do
+      url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python)}, 'rethinkdb.com/api/javascript/'
+    end
+
+    options[:attribution] = <<-HTML
+      &copy; RethinkDB contributors<br>
+      Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
+    HTML
+  end
+end

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


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


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

@@ -0,0 +1 @@
+http://rethinkdb.com/