Browse Source

Update and version RethinkDB documentation (2.3.0)

Thibaut Courouble 9 years ago
parent
commit
58d2ecd027

+ 0 - 1
assets/javascripts/views/pages/javascript.coffee

@@ -27,7 +27,6 @@ app.views.MongoosePage =
 app.views.NodePage =
 app.views.PhaserPage =
 app.views.RamdaPage =
-app.views.RethinkdbPage =
 app.views.SinonPage =
 app.views.UnderscorePage =
 app.views.WebpackPage =

+ 1 - 0
assets/javascripts/views/pages/simple.coffee

@@ -7,5 +7,6 @@ class app.views.SimplePage extends app.views.BasePage
     return
 
 app.views.MeteorPage =
+app.views.RethinkdbPage =
 app.views.TypescriptPage =
 app.views.SimplePage

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

@@ -31,6 +31,10 @@ module Docs
           node.name = 'h2'
         end
 
+        css('pre').each do |node|
+          node['data-language'] = current_url.path[/\A\/api\/(\w+)\//, 1]
+        end
+
         doc
       end
     end

+ 2 - 2
lib/docs/filters/rethinkdb/entries.rb

@@ -6,8 +6,8 @@ module Docs
       end
 
       def get_type
-        link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/javascript/"]')
-        dir = link['href'][/javascript\/([^\/]+)/, 1]
+        link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/"]')
+        dir = link['href'][/api\/\w+\/([^\/]+)/, 1]
         dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and')
       end
 

+ 33 - 6
lib/docs/scrapers/rethinkdb.rb

@@ -2,8 +2,7 @@ module Docs
   class Rethinkdb < UrlScraper
     self.name = 'RethinkDB'
     self.type = 'rethinkdb'
-    self.release = '2.2.5'
-    self.base_url = 'https://rethinkdb.com/api/javascript/'
+    self.release = '2.3.0'
     self.links = {
       home: 'https://rethinkdb.com/',
       code: 'https://github.com/rethinkdb/rethinkdb'
@@ -14,13 +13,41 @@ module Docs
     options[:trailing_slash] = false
     options[:container] = '.docs-article'
 
-    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
+
+    version 'JavaScript' do
+      self.base_url = 'https://rethinkdb.com/api/javascript/'
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/javascript/'
+      end
+    end
+
+    version 'Ruby' do
+      self.base_url = 'https://rethinkdb.com/api/ruby/'
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/ruby/'
+      end
+    end
+
+    version 'Python' do
+      self.base_url = 'https://rethinkdb.com/api/python/'
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/python/'
+      end
+    end
+
+    version 'Java' do
+      self.base_url = 'https://rethinkdb.com/api/java/'
+
+      options[:fix_urls] = ->(url) do
+        url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/java/'
+      end
+    end
   end
 end