Browse Source

Update RethinkDB documentation (2.0.1)

Thibaut 10 năm trước cách đây
mục cha
commit
4c116c34d1

+ 8 - 8
lib/docs/filters/rethinkdb/clean_html.rb

@@ -7,17 +7,13 @@ module Docs
           return doc
         end
 
-        css('#api-header').each do |node|
-          node.replace(node.at_css('h1'))
+        css('header .title').each do |node|
+          node.parent.replace(node)
         end
 
-        css('.linksbox-container').remove
+        css('.lang-selector').remove
 
-        css('.highlight').each do |node|
-          node.before(node.children).remove
-        end
-
-        css('.command-body').each do |node|
+        css('.command-syntax').each do |node|
           node.name = 'pre'
           node.inner_html = node.inner_html.gsub('</p>', "</p>\n")
         end
@@ -26,6 +22,10 @@ module Docs
           node.content = node.content
         end
 
+        css('.highlight', '> section', '.highlighter-rouge').each do |node|
+          node.before(node.children).remove
+        end
+
         css('h1').each do |node|
           next if node['class'].to_s.include?('title')
           node.name = 'h2'

+ 7 - 1
lib/docs/filters/rethinkdb/entries.rb

@@ -2,7 +2,7 @@ module Docs
   class Rethinkdb
     class EntriesFilter < Docs::EntriesFilter
       def get_name
-        at_css('.title').content.remove('ReQL command:')
+        at_css('.title').content.remove('ReQL command:').split(', ').first
       end
 
       def get_type
@@ -10,6 +10,12 @@ module Docs
         dir = link['href'][/javascript\/([^\/]+)/, 1]
         dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and')
       end
+
+      def additional_entries
+        at_css('.title').content.split(', ')[1..-1].map do |name|
+          [name]
+        end
+      end
     end
   end
 end

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

@@ -2,13 +2,17 @@ module Docs
   class Rethinkdb < UrlScraper
     self.name = 'RethinkDB'
     self.type = 'rethinkdb'
-    self.version = '1.16.0'
+    self.version = '2.0.1'
     self.base_url = 'http://rethinkdb.com/api/javascript/'
+    self.links = {
+      home: 'http://rethinkdb.com/',
+      code: 'https://github.com/rethinkdb/rethinkdb'
+    }
 
     html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html'
 
     options[:trailing_slash] = false
-    options[:container] = '.container .section'
+    options[:container] = '.docs-article'
 
     options[:fix_urls] = ->(url) do
       url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python)}, 'rethinkdb.com/api/javascript/'