Unified · Split
Binary file not shown.
Binary file not shown.
| @@ -1,6 +1,7 @@ | |||
| 1 | ._rethinkdb { | 1 | ._rethinkdb { |
| 2 | > h2 { @extend %block-heading; } | 2 | @extend %simple; |
| 3 | code { @extend %label; } | 3 | |
| 4 | .infobox-alert { @extend %note-orange; } | ||
| 4 | 5 | ||
| 5 | .api_command_illustration { | 6 | .api_command_illustration { |
| 6 | float: right; | 7 | float: right; |
| @@ -2,16 +2,13 @@ module Docs · 1 unmodified line | |||
| 2 | class Rethinkdb | 2 | class Rethinkdb |
| 3 | class CleanHtmlFilter < Filter | 3 | class CleanHtmlFilter < Filter |
| 4 | def call | 4 | def call |
| 5 | if root_page? | 5 | @doc = at_css('.docs-article') |
| 6 | doc.inner_html = '<h1>ReQL command reference</h1>' | ||
| 7 | return doc | ||
| 8 | end | ||
| 9 | 6 | ||
| 10 | css('header .title').each do |node| | 7 | css('header .title').each do |node| |
| 11 | node.parent.replace(node) | 8 | node.parent.replace(node) |
| 12 | end | 9 | end |
| 13 | 10 | ||
| 14 | css('.lang-selector').remove | 11 | css('.lang-selector', '.platform-buttons img', 'hr', '#in-this-article').remove |
| 15 | 12 | ||
| 16 | css('.command-syntax').each do |node| | 13 | css('.command-syntax').each do |node| |
| 17 | node.name = 'pre' | 14 | node.name = 'pre' |
| @@ -22,19 +19,33 @@ module Docs · 4 unmodified lines | |||
| 22 | node.content = node.content | 19 | node.content = node.content |
| 23 | end | 20 | end |
| 24 | 21 | ||
| 25 | css('.highlight', '> section', '.highlighter-rouge').each do |node| | 22 | css('.highlight', 'section', 'div.highlighter-rouge', 'a > p', 'li > h1').each do |node| |
| 26 | node.before(node.children).remove | 23 | node.before(node.children).remove |
| 27 | end | 24 | end |
| 28 | 25 | ||
| 26 | css('h2, h3, h4').each do |node| | ||
| 27 | node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } | ||
| 28 | end | ||
| 29 | |||
| 29 | css('h1').each do |node| | 30 | css('h1').each do |node| |
| 30 | next if node['class'].to_s.include?('title') | 31 | next if node['class'].to_s.include?('title') |
| 31 | node.name = 'h2' | 32 | node.name = 'h2' |
| 32 | end | 33 | end |
| 33 | 34 | ||
| 35 | css('td h2').each do |node| | ||
| 36 | node.name = 'h5' | ||
| 37 | end | ||
| 38 | |||
| 34 | css('pre').each do |node| | 39 | css('pre').each do |node| |
| 35 | node['data-language'] = current_url.path[/\A\/api\/(\w+)\//, 1] | 40 | node['data-language'] = current_url.path[/\A\/api\/(\w+)\//, 1] |
| 36 | end | 41 | end |
| 37 | 42 | ||
| 43 | css('.infobox').each do |node| | ||
| 44 | node.name = 'blockquote' | ||
| 45 | end | ||
| 46 | |||
| 47 | css('> .infobox:last-child:contains("Contribute:")').remove | ||
| 48 | |||
| 38 | doc | 49 | doc |
| 39 | end | 50 | end |
| 40 | end | 51 | end |
| @@ -2,20 +2,34 @@ module Docs · 1 unmodified line | |||
| 2 | class Rethinkdb | 2 | class Rethinkdb |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | def get_name | 4 | def get_name |
| 5 | at_css('.title').content.remove('ReQL command:').split(', ').first | 5 | if subpath.start_with?('api') |
| 6 | at_css('.title').content.remove('ReQL command:').split(', ').first | ||
| 7 | else | ||
| 8 | at_css('.docs-nav .active').content | ||
| 9 | end | ||
| 6 | end | 10 | end |
| 7 | 11 | ||
| 8 | def get_type | 12 | def get_type |
| 9 | link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/"]') | 13 | if subpath.start_with?('api') |
| 10 | dir = link['href'][/api\/\w+\/([^\/]+)/, 1] | 14 | link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/"]') |
| 11 | dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and') | 15 | dir = link['href'][/api\/\w+\/([^\/]+)/, 1] |
| 16 | return 'Reference' if dir == 'index.md' | ||
| 17 | dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and') | ||
| 18 | else | ||
| 19 | at_css('.docs-nav .expanded').previous_element.content.prepend('Guides: ') | ||
| 20 | end | ||
| 12 | end | 21 | end |
| 13 | 22 | ||
| 14 | def additional_entries | 23 | def additional_entries |
| 24 | return [] unless subpath.start_with?('api') | ||
| 15 | at_css('.title').content.split(', ')[1..-1].map do |name| | 25 | at_css('.title').content.split(', ')[1..-1].map do |name| |
| 16 | [name] | 26 | [name] |
| 17 | end | 27 | end |
| 18 | end | 28 | end |
| 29 | |||
| 30 | def include_default_entry? | ||
| 31 | at_css('.docs-article p').try(:content) != 'Choose your language:' | ||
| 32 | end | ||
| 19 | end | 33 | end |
| 20 | end | 34 | end |
| 21 | end | 35 | end |
| @@ -2,7 +2,9 @@ module Docs · 1 unmodified line | |||
| 2 | class Rethinkdb < UrlScraper | 2 | class Rethinkdb < UrlScraper |
| 3 | self.name = 'RethinkDB' | 3 | self.name = 'RethinkDB' |
| 4 | self.type = 'rethinkdb' | 4 | self.type = 'rethinkdb' |
| 5 | self.release = '2.3.2' | 5 | self.base_url = 'https://rethinkdb.com/' |
| 6 | self.release = '2.3.5' | ||
| 7 | self.root_path = 'docs/' | ||
| 6 | self.links = { | 8 | self.links = { |
| 7 | home: 'https://rethinkdb.com/', | 9 | home: 'https://rethinkdb.com/', |
| 8 | code: 'https://github.com/rethinkdb/rethinkdb' | 10 | code: 'https://github.com/rethinkdb/rethinkdb' |
| @@ -10,44 +12,57 @@ module Docs · 1 unmodified line | |||
| 10 | 12 | ||
| 11 | html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html' | 13 | html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html' |
| 12 | 14 | ||
| 13 | options[:trailing_slash] = false | 15 | options[:trailing_slash] = true |
| 14 | options[:container] = '.docs-article' | 16 | options[:container] = '.documentation' |
| 17 | |||
| 18 | options[:only_patterns] = [/\Adocs/] | ||
| 19 | options[:skip_patterns] = [/docs\/install(\-drivers)?\/./] | ||
| 20 | options[:skip] = %w( | ||
| 21 | docs/build/ | ||
| 22 | docs/tutorials/elections/ | ||
| 23 | docs/tutorials/superheroes/) | ||
| 24 | |||
| 25 | MULTILANG_DOCS = %w( | ||
| 26 | changefeeds | ||
| 27 | cookbook | ||
| 28 | dates-and-times | ||
| 29 | geo-support | ||
| 30 | guide | ||
| 31 | nested-fields | ||
| 32 | publish-subscribe | ||
| 33 | rabbitmq | ||
| 34 | secondary-indexes | ||
| 35 | sql-to-reql | ||
| 36 | storing-binary) | ||
| 15 | 37 | ||
| 16 | options[:attribution] = <<-HTML | 38 | options[:attribution] = <<-HTML |
| 17 | © RethinkDB contributors<br> | 39 | © RethinkDB contributors<br> |
| 18 | Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. | 40 | Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. |
| 19 | HTML | 41 | HTML |
| 20 | 42 | ||
| 21 | version 'JavaScript' do | 43 | %w(JavaScript Ruby Python Java).each do |name| |
| 22 | self.base_url = 'https://rethinkdb.com/api/javascript/' | 44 | path = name.downcase |
| 23 | 45 | instance_eval <<-CODE | |
| 24 | options[:fix_urls] = ->(url) do | 46 | version '#{name}' do |
| 25 | url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/javascript/' | 47 | self.initial_paths = %w(api/#{path}/) |
| 26 | end | ||
| 27 | end | ||
| 28 | |||
| 29 | version 'Ruby' do | ||
| 30 | self.base_url = 'https://rethinkdb.com/api/ruby/' | ||
| 31 | |||
| 32 | options[:fix_urls] = ->(url) do | ||
| 33 | url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/ruby/' | ||
| 34 | end | ||
| 35 | end | ||
| 36 | 48 | ||
| 37 | version 'Python' do | 49 | options[:only_patterns] += [/\\Aapi\\/#{path}\\//] |
| 38 | self.base_url = 'https://rethinkdb.com/api/python/' | ||
| 39 | 50 | ||
| 40 | options[:fix_urls] = ->(url) do | 51 | options[:fix_urls] = ->(url) do |
| 41 | url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/python/' | 52 | url.sub! %r{rethinkdb.com/docs/(#{MULTILANG_DOCS.join('|')})\\z}, 'rethinkdb.com/docs/\\1/#{path}/' |
| 42 | end | 53 | url.sub! %r{rethinkdb.com/docs/(#{MULTILANG_DOCS.join('|')})/(?!#{path}/).*}, 'rethinkdb.com/docs/\\1/#{path}/' |
| 54 | url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/#{path}/' | ||
| 55 | url | ||
| 56 | end | ||
| 57 | end | ||
| 58 | CODE | ||
| 43 | end | 59 | end |
| 44 | 60 | ||
| 45 | version 'Java' do | 61 | private |
| 46 | self.base_url = 'https://rethinkdb.com/api/java/' | ||
| 47 | 62 | ||
| 48 | options[:fix_urls] = ->(url) do | 63 | def process_response?(response) |
| 49 | url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/java/' | 64 | return false unless super |
| 50 | end | 65 | response.body !~ /http-equiv="refresh"/i |
| 51 | end | 66 | end |
| 52 | end | 67 | end |
| 53 | end | 68 | end |
Binary file not shown.
Binary file not shown.