Update and improve RethinkDB documentation

pull/459/merge
Thibaut Courouble 9 years ago
parent 190d95c371
commit c0179b22ac

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 123 KiB

@ -1,6 +1,7 @@
._rethinkdb {
> h2 { @extend %block-heading; }
code { @extend %label; }
@extend %simple;
.infobox-alert { @extend %note-orange; }
.api_command_illustration {
float: right;

@ -2,16 +2,13 @@ module Docs
class Rethinkdb
class CleanHtmlFilter < Filter
def call
if root_page?
doc.inner_html = '<h1>ReQL command reference</h1>'
return doc
end
@doc = at_css('.docs-article')
css('header .title').each do |node|
node.parent.replace(node)
end
css('.lang-selector').remove
css('.lang-selector', '.platform-buttons img', 'hr', '#in-this-article').remove
css('.command-syntax').each do |node|
node.name = 'pre'
@ -22,19 +19,33 @@ module Docs
node.content = node.content
end
css('.highlight', '> section', '.highlighter-rouge').each do |node|
css('.highlight', 'section', 'div.highlighter-rouge', 'a > p', 'li > h1').each do |node|
node.before(node.children).remove
end
css('h2, h3, h4').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
css('h1').each do |node|
next if node['class'].to_s.include?('title')
node.name = 'h2'
end
css('td h2').each do |node|
node.name = 'h5'
end
css('pre').each do |node|
node['data-language'] = current_url.path[/\A\/api\/(\w+)\//, 1]
end
css('.infobox').each do |node|
node.name = 'blockquote'
end
css('> .infobox:last-child:contains("Contribute:")').remove
doc
end
end

@ -2,20 +2,34 @@ module Docs
class Rethinkdb
class EntriesFilter < Docs::EntriesFilter
def get_name
if subpath.start_with?('api')
at_css('.title').content.remove('ReQL command:').split(', ').first
else
at_css('.docs-nav .active').content
end
end
def get_type
if subpath.start_with?('api')
link = at_css('a[href^="https://github.com/rethinkdb/docs/blob/master/api/"]')
dir = link['href'][/api\/\w+\/([^\/]+)/, 1]
return 'Reference' if dir == 'index.md'
dir.titleize.gsub('Rql', 'ReQL').gsub('And', 'and')
else
at_css('.docs-nav .expanded').previous_element.content.prepend('Guides: ')
end
end
def additional_entries
return [] unless subpath.start_with?('api')
at_css('.title').content.split(', ')[1..-1].map do |name|
[name]
end
end
def include_default_entry?
at_css('.docs-article p').try(:content) != 'Choose your language:'
end
end
end
end

@ -2,7 +2,9 @@ module Docs
class Rethinkdb < UrlScraper
self.name = 'RethinkDB'
self.type = 'rethinkdb'
self.release = '2.3.2'
self.base_url = 'https://rethinkdb.com/'
self.release = '2.3.5'
self.root_path = 'docs/'
self.links = {
home: 'https://rethinkdb.com/',
code: 'https://github.com/rethinkdb/rethinkdb'
@ -10,44 +12,57 @@ module Docs
html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html'
options[:trailing_slash] = false
options[:container] = '.docs-article'
options[:trailing_slash] = true
options[:container] = '.documentation'
options[:only_patterns] = [/\Adocs/]
options[:skip_patterns] = [/docs\/install(\-drivers)?\/./]
options[:skip] = %w(
docs/build/
docs/tutorials/elections/
docs/tutorials/superheroes/)
MULTILANG_DOCS = %w(
changefeeds
cookbook
dates-and-times
geo-support
guide
nested-fields
publish-subscribe
rabbitmq
secondary-indexes
sql-to-reql
storing-binary)
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
%w(JavaScript Ruby Python Java).each do |name|
path = name.downcase
instance_eval <<-CODE
version '#{name}' do
self.initial_paths = %w(api/#{path}/)
version 'Ruby' do
self.base_url = 'https://rethinkdb.com/api/ruby/'
options[:only_patterns] += [/\\Aapi\\/#{path}\\//]
options[:fix_urls] = ->(url) do
url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/ruby/'
url.sub! %r{rethinkdb.com/docs/(#{MULTILANG_DOCS.join('|')})\\z}, 'rethinkdb.com/docs/\\1/#{path}/'
url.sub! %r{rethinkdb.com/docs/(#{MULTILANG_DOCS.join('|')})/(?!#{path}/).*}, 'rethinkdb.com/docs/\\1/#{path}/'
url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/#{path}/'
url
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
CODE
end
version 'Java' do
self.base_url = 'https://rethinkdb.com/api/java/'
private
options[:fix_urls] = ->(url) do
url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/java/'
end
def process_response?(response)
return false unless super
response.body !~ /http-equiv="refresh"/i
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 B

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 271 B

After

Width:  |  Height:  |  Size: 495 B

Loading…
Cancel
Save