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 { ._rethinkdb {
> h2 { @extend %block-heading; } @extend %simple;
code { @extend %label; }
.infobox-alert { @extend %note-orange; }
.api_command_illustration { .api_command_illustration {
float: right; float: right;

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

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

@ -2,7 +2,9 @@ module Docs
class Rethinkdb < UrlScraper class Rethinkdb < UrlScraper
self.name = 'RethinkDB' self.name = 'RethinkDB'
self.type = '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 = { self.links = {
home: 'https://rethinkdb.com/', home: 'https://rethinkdb.com/',
code: 'https://github.com/rethinkdb/rethinkdb' code: 'https://github.com/rethinkdb/rethinkdb'
@ -10,44 +12,57 @@ module Docs
html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html' html_filters.push 'rethinkdb/entries', 'rethinkdb/clean_html'
options[:trailing_slash] = false options[:trailing_slash] = true
options[:container] = '.docs-article' 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 options[:attribution] = <<-HTML
&copy; RethinkDB contributors<br> &copy; RethinkDB contributors<br>
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
HTML HTML
version 'JavaScript' do %w(JavaScript Ruby Python Java).each do |name|
self.base_url = 'https://rethinkdb.com/api/javascript/' path = name.downcase
instance_eval <<-CODE
options[:fix_urls] = ->(url) do version '#{name}' do
url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/javascript/' self.initial_paths = %w(api/#{path}/)
end
end
version 'Ruby' do options[:only_patterns] += [/\\Aapi\\/#{path}\\//]
self.base_url = 'https://rethinkdb.com/api/ruby/'
options[:fix_urls] = ->(url) do 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
end end
CODE
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 end
version 'Java' do private
self.base_url = 'https://rethinkdb.com/api/java/'
options[:fix_urls] = ->(url) do def process_response?(response)
url.sub! %r{rethinkdb.com/api/(?!javascript|ruby|python|java)}, 'rethinkdb.com/api/java/' return false unless super
end response.body !~ /http-equiv="refresh"/i
end end
end 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