History

Update Rust documentation (1.17.0)

Thibaut Courouble committed 9 years ago

Commit 49bb9051 parent 78f839a4 files · +41 −49Browse files

Unified · Split

4 files
  1. assets/stylesheets/pages/_rust.scss +1 −1
  2. lib/docs/filters/rust/clean_html.rb +34 −33
  3. lib/docs/filters/rust/entries.rb +3 −13
  4. lib/docs/scrapers/rust.rb +3 −2
assets/stylesheets/pages/_rust.scss+1−1
@@ -7,5 +7,5 @@ · 6 unmodified lines
7 div.stability { margin-bottom: 1em; }7 div.stability { margin-bottom: 1em; }
8 em.stab, span.stab { @extend %label; }8 em.stab, span.stab { @extend %label; }
9 em.stab.unstable, span.stab.unstable { @extend %label-orange; }9 em.stab.unstable, span.stab.unstable { @extend %label-orange; }
10 .since { float: right; }10 .since, .out-of-band { float: right; }
11}11}
lib/docs/filters/rust/clean_html.rb+34−33
@@ -2,21 +2,49 @@ module Docs · 1 unmodified line
2 class Rust2 class Rust
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 if slug.start_with?('book')5 puts subpath if at_css('#versioninfo')
6 book6
7 elsif slug.start_with?('reference') || slug == 'error-index'7 if slug.start_with?('book') || slug.start_with?('reference')
8 reference8 @doc = at_css('#content')
9 elsif slug == 'error-index'
10 css('.error-undescribed').remove
11
12 css('.error-described').each do |node|
13 node.before(node.children).remove
14 end
9 else15 else
10 api16 @doc = at_css('#main')
17
18 css('.toggle-wrapper').remove
19
20 css('h1.fqn').each do |node|
21 node.content = node.at_css('.in-band').content
22 end
23
24 css('.stability .stab').each do |node|
25 node.name = 'span'
26 node.content = node.content
27 end
11 end28 end
12 29
13 css('.rusttest', '.test-arrow', 'hr').remove30 css('.rusttest', '.test-arrow', 'hr').remove
14 31
32 css('a.header').each do |node|
33 node.first_element_child['id'] = node['name']
34 node.before(node.children).remove
35 end
36
15 css('.docblock > h1').each { |node| node.name = 'h4' }37 css('.docblock > h1').each { |node| node.name = 'h4' }
16 css('h2.section-header').each { |node| node.name = 'h3' }38 css('h2.section-header').each { |node| node.name = 'h3' }
17 css('h1.section-header').each { |node| node.name = 'h2' }39 css('h1.section-header').each { |node| node.name = 'h2' }
18 40
19 css('> .impl-items', '> .docblock').each do |node|41 if at_css('h1 ~ h1')
42 css('h1 ~ h1', 'h2', 'h3').each do |node|
43 node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
44 end
45 end
46
47 css('> .impl-items', '> .docblock', 'pre > pre').each do |node|
20 node.before(node.children).remove48 node.before(node.children).remove
21 end49 end
22 50
@@ -36,33 +64,6 @@ module Docs · 13 unmodified lines
36 64
37 doc65 doc
38 end66 end
39
40 def book
41 @doc = at_css('#page')
42 end
43
44 def reference
45 css('#versioninfo', '.error-undescribed').remove
46
47 css('.error-described').each do |node|
48 node.before(node.children).remove
49 end
50 end
51
52 def api
53 @doc = at_css('#main')
54
55 css('.toggle-wrapper').remove
56
57 css('h1.fqn').each do |node|
58 node.content = node.at_css('.in-band').content
59 end
60
61 css('.stability .stab').each do |node|
62 node.name = 'span'
63 node.content = node.content
64 end
65 end
66 end67 end
67 end68 end
68end69end
lib/docs/filters/rust/entries.rb+3−13
@@ -2,10 +2,8 @@ module Docs · 1 unmodified line
2 class Rust2 class Rust
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 if slug.start_with?('book')5 if slug.start_with?('book') || slug.start_with?('reference')
6 at_css("#toc a[href='#{File.basename(slug)}']").content6 at_css("#sidebar a[href='#{File.basename(slug)}']").content
7 elsif slug.start_with?('reference')
8 'Reference'
9 elsif slug == 'error-index'7 elsif slug == 'error-index'
10 'Compiler Errors'8 'Compiler Errors'
11 else9 else
@@ -37,16 +35,8 @@ module Docs · 25 unmodified lines
37 end35 end
38 36
39 def additional_entries37 def additional_entries
40 if slug.start_with?('book')38 if slug.start_with?('book') || slug.start_with?('reference')
41 []39 []
42 elsif slug.start_with?('reference')
43 css('#TOC > ul > li > a', '#TOC > ul > li > ul > li > a').map do |node|
44 name = node.content
45 name.sub! %r{(\d)\ }, '\1. '
46 name.sub! '10.0.', '10.'
47 id = node['href'].remove('#')
48 [name, id]
49 end
50 elsif slug == 'error-index'40 elsif slug == 'error-index'
51 css('.error-described h2.section-header').each_with_object [] do |node, entries|41 css('.error-described h2.section-header').each_with_object [] do |node, entries|
52 entries << [node.content, node['id']] unless node.content.include?('Note:')42 entries << [node.content, node['id']] unless node.content.include?('Note:')
lib/docs/scrapers/rust.rb+3−2
@@ -1,11 +1,11 @@
1module Docs1module Docs
2 class Rust < UrlScraper2 class Rust < UrlScraper
3 self.type = 'rust'3 self.type = 'rust'
4 self.release = '1.16.0'4 self.release = '1.17.0'
5 self.base_url = 'https://doc.rust-lang.org/'5 self.base_url = 'https://doc.rust-lang.org/'
6 self.root_path = 'book/index.html'6 self.root_path = 'book/index.html'
7 self.initial_paths = %w(7 self.initial_paths = %w(
8 reference.html8 reference/introduction.html
9 collections/index.html9 collections/index.html
10 std/index.html10 std/index.html
11 error-index.html)11 error-index.html)
@@ -18,6 +18,7 @@ module Docs · 6 unmodified lines
18 18
19 options[:only_patterns] = [19 options[:only_patterns] = [
20 /\Abook\//,20 /\Abook\//,
21 /\Areference\//,
21 /\Acollections\//,22 /\Acollections\//,
22 /\Astd\// ]23 /\Astd\// ]
23 24