Update Rust documentation (1.17.0)

pull/621/merge
Thibaut Courouble 8 years ago
parent 78f839a913
commit 49bb905c93

@ -7,5 +7,5 @@
div.stability { margin-bottom: 1em; } div.stability { margin-bottom: 1em; }
em.stab, span.stab { @extend %label; } em.stab, span.stab { @extend %label; }
em.stab.unstable, span.stab.unstable { @extend %label-orange; } em.stab.unstable, span.stab.unstable { @extend %label-orange; }
.since { float: right; } .since, .out-of-band { float: right; }
} }

@ -2,21 +2,49 @@ module Docs
class Rust class Rust
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
if slug.start_with?('book') puts subpath if at_css('#versioninfo')
book
elsif slug.start_with?('reference') || slug == 'error-index' if slug.start_with?('book') || slug.start_with?('reference')
reference @doc = at_css('#content')
elsif slug == 'error-index'
css('.error-undescribed').remove
css('.error-described').each do |node|
node.before(node.children).remove
end
else else
api @doc = at_css('#main')
css('.toggle-wrapper').remove
css('h1.fqn').each do |node|
node.content = node.at_css('.in-band').content
end
css('.stability .stab').each do |node|
node.name = 'span'
node.content = node.content
end
end end
css('.rusttest', '.test-arrow', 'hr').remove css('.rusttest', '.test-arrow', 'hr').remove
css('a.header').each do |node|
node.first_element_child['id'] = node['name']
node.before(node.children).remove
end
css('.docblock > h1').each { |node| node.name = 'h4' } css('.docblock > h1').each { |node| node.name = 'h4' }
css('h2.section-header').each { |node| node.name = 'h3' } css('h2.section-header').each { |node| node.name = 'h3' }
css('h1.section-header').each { |node| node.name = 'h2' } css('h1.section-header').each { |node| node.name = 'h2' }
css('> .impl-items', '> .docblock').each do |node| if at_css('h1 ~ h1')
css('h1 ~ h1', 'h2', 'h3').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
end
css('> .impl-items', '> .docblock', 'pre > pre').each do |node|
node.before(node.children).remove node.before(node.children).remove
end end
@ -36,33 +64,6 @@ module Docs
doc doc
end end
def book
@doc = at_css('#page')
end
def reference
css('#versioninfo', '.error-undescribed').remove
css('.error-described').each do |node|
node.before(node.children).remove
end
end
def api
@doc = at_css('#main')
css('.toggle-wrapper').remove
css('h1.fqn').each do |node|
node.content = node.at_css('.in-band').content
end
css('.stability .stab').each do |node|
node.name = 'span'
node.content = node.content
end
end
end end
end end
end end

@ -2,10 +2,8 @@ module Docs
class Rust class Rust
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
if slug.start_with?('book') if slug.start_with?('book') || slug.start_with?('reference')
at_css("#toc a[href='#{File.basename(slug)}']").content at_css("#sidebar a[href='#{File.basename(slug)}']").content
elsif slug.start_with?('reference')
'Reference'
elsif slug == 'error-index' elsif slug == 'error-index'
'Compiler Errors' 'Compiler Errors'
else else
@ -37,16 +35,8 @@ module Docs
end end
def additional_entries def additional_entries
if slug.start_with?('book') if slug.start_with?('book') || slug.start_with?('reference')
[] []
elsif slug.start_with?('reference')
css('#TOC > ul > li > a', '#TOC > ul > li > ul > li > a').map do |node|
name = node.content
name.sub! %r{(\d)\ }, '\1. '
name.sub! '10.0.', '10.'
id = node['href'].remove('#')
[name, id]
end
elsif slug == 'error-index' elsif slug == 'error-index'
css('.error-described h2.section-header').each_with_object [] do |node, entries| css('.error-described h2.section-header').each_with_object [] do |node, entries|
entries << [node.content, node['id']] unless node.content.include?('Note:') entries << [node.content, node['id']] unless node.content.include?('Note:')

@ -1,11 +1,11 @@
module Docs module Docs
class Rust < UrlScraper class Rust < UrlScraper
self.type = 'rust' self.type = 'rust'
self.release = '1.16.0' self.release = '1.17.0'
self.base_url = 'https://doc.rust-lang.org/' self.base_url = 'https://doc.rust-lang.org/'
self.root_path = 'book/index.html' self.root_path = 'book/index.html'
self.initial_paths = %w( self.initial_paths = %w(
reference.html reference/introduction.html
collections/index.html collections/index.html
std/index.html std/index.html
error-index.html) error-index.html)
@ -18,6 +18,7 @@ module Docs
options[:only_patterns] = [ options[:only_patterns] = [
/\Abook\//, /\Abook\//,
/\Areference\//,
/\Acollections\//, /\Acollections\//,
/\Astd\// ] /\Astd\// ]

Loading…
Cancel
Save