From 4c116c34d15fcc2d4a7e7d3985a3c72809e3556f Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 19 Apr 2015 11:15:49 -0400 Subject: [PATCH] Update RethinkDB documentation (2.0.1) --- lib/docs/filters/rethinkdb/clean_html.rb | 16 ++++++++-------- lib/docs/filters/rethinkdb/entries.rb | 8 +++++++- lib/docs/scrapers/rethinkdb.rb | 8 ++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/docs/filters/rethinkdb/clean_html.rb b/lib/docs/filters/rethinkdb/clean_html.rb index ecaa2762..9ea75aa3 100644 --- a/lib/docs/filters/rethinkdb/clean_html.rb +++ b/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('

', "

\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' diff --git a/lib/docs/filters/rethinkdb/entries.rb b/lib/docs/filters/rethinkdb/entries.rb index 949cb891..e3fbc8f7 100644 --- a/lib/docs/filters/rethinkdb/entries.rb +++ b/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 diff --git a/lib/docs/scrapers/rethinkdb.rb b/lib/docs/scrapers/rethinkdb.rb index 9470e05d..a7ae4b6c 100644 --- a/lib/docs/scrapers/rethinkdb.rb +++ b/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/'