History

Update Rust documentation (1.10.0)

Thibaut Courouble committed 10 years ago

Commit a83459b1 parent 922754a3 files · +17 −4Browse files

Unified · Split

3 files
  1. lib/docs/filters/rust/clean_html.rb +6 −2
  2. lib/docs/filters/rust/entries.rb +8 −0
  3. lib/docs/scrapers/rust.rb +3 −2
lib/docs/filters/rust/clean_html.rb+6−2
@@ -4,7 +4,7 @@ module Docs · 3 unmodified lines
44 def call
55 if slug.start_with?('book')
66 book
7− elsif slug.start_with?('reference')
7+ elsif slug.start_with?('reference') || slug == 'error-index'
88 reference
99 else
1010 api
@@ -41,7 +41,11 @@ module Docs · 30 unmodified lines
4141 end
4242
4343 def reference
44− css('#versioninfo').remove
44+ css('#versioninfo', '.error-undescribed').remove
45+
46+ css('.error-described').each do |node|
47+ node.before(node.children).remove
48+ end
4549 end
4650
4751 def api
lib/docs/filters/rust/entries.rb+8−0
@@ -6,6 +6,8 @@ module Docs · 5 unmodified lines
66 at_css("#toc a[href='#{File.basename(slug)}']").content
77 elsif slug.start_with?('reference')
88 'Reference'
9+ elsif slug == 'error-index'
10+ 'Compiler Errors'
911 else
1012 name = at_css('h1.fqn .in-band').content.remove(/\A.+\s/)
1113 mod = slug.split('/').first
@@ -21,6 +23,8 @@ module Docs · 9 unmodified lines
2123 'Guide'
2224 elsif slug.start_with?('reference')
2325 'Reference'
26+ elsif slug == 'error-index'
27+ 'Compiler Errors'
2428 else
2529 path = name.split('::')
2630 heading = at_css('h1.fqn .in-band').content.strip
@@ -43,6 +47,10 @@ module Docs · 16 unmodified lines
4347 id = node['href'].remove('#')
4448 [name, id]
4549 end
50+ elsif slug == 'error-index'
51+ css('.error-described h2.section-header').map do |node|
52+ [node.content, node['id']]
53+ end
4654 else
4755 css('#methods + * + div > .method', '#required-methods + div > .method', '#provided-methods + div > .method').map do |node|
4856 name = node.at_css('.fnname').content
lib/docs/scrapers/rust.rb+3−2
@@ -1,13 +1,14 @@
11 module Docs
22 class Rust < UrlScraper
33 self.type = 'rust'
4− self.release = '1.9.0'
4+ self.release = '1.10.0'
55 self.base_url = 'https://doc.rust-lang.org/'
66 self.root_path = 'book/index.html'
77 self.initial_paths = %w(
88 reference.html
99 collections/index.html
10− std/index.html)
10+ std/index.html
11+ error-index.html)
1112 self.links = {
1213 home: 'https://www.rust-lang.org/',
1314 code: 'https://github.com/rust-lang/rust'