History

Update Rust documentation (1.30.1)

Thibaut Courouble committed 7 years ago

Commit f2faacc1 parent 3a8be503 files · +13 −9Browse files

Unified · Split

3 files
  1. lib/docs/filters/rust/clean_html.rb +4 −2
  2. lib/docs/filters/rust/entries.rb +5 −6
  3. lib/docs/scrapers/rust.rb +4 −1
lib/docs/filters/rust/clean_html.rb+4−2
@@ -1,3 +1,5 @@
1# frozen_string_literal: true
2
1module Docs3module Docs
2 class Rust4 class Rust
3 class CleanHtmlFilter < Filter5 class CleanHtmlFilter < Filter
@@ -74,10 +76,10 @@ module Docs · 70 unmodified lines
74 node.remove76 node.remove
75 end77 end
76 78
77 css('h2 .important-traits', 'h3 .important-traits', 'h4 .important-traits').each do |node|79 css('.important-traits').to_a.each_with_index do |node, index|
78 content = node.at_css('.content.hidden .content')80 content = node.at_css('.content.hidden .content')
79 node.at_css('.content.hidden').replace(content) if content81 node.at_css('.content.hidden').replace(content) if content
80 node.parent.after(node)82 node.parent.after(node) if node.parent.name.in?(%(h2 h3 h4))
81 end83 end
82 84
83 css('code.content').each do |node|85 css('code.content').each do |node|
lib/docs/filters/rust/entries.rb+5−6
@@ -43,13 +43,12 @@ module Docs · 42 unmodified lines
43 end43 end
44 else44 else
45 css('.method')45 css('.method')
46 .select {|node| !node.at_css('.fnname').nil?}46 .each_with_object({}) { |node, entries|
47 .map {|node|47 name = node.at_css('.fnname').try(:content)
48 name = node.at_css('.fnname').content48 next unless name
49 name.prepend "#{self.name}::"49 name.prepend "#{self.name}::"
50 [name, node['id']]50 entries[name] ||= [name, node['id']]
51 }51 }.values
52 .uniq {|item| item[0]}
53 end52 end
54 end53 end
55 end54 end
lib/docs/scrapers/rust.rb+4−1
@@ -1,7 +1,9 @@
1# frozen_string_literal: true
2
1module Docs3module Docs
2 class Rust < UrlScraper4 class Rust < UrlScraper
3 self.type = 'rust'5 self.type = 'rust'
4 self.release = '1.29.1'6 self.release = '1.30.1'
5 self.base_url = 'https://doc.rust-lang.org/'7 self.base_url = 'https://doc.rust-lang.org/'
6 self.root_path = 'book/second-edition/index.html'8 self.root_path = 'book/second-edition/index.html'
7 self.initial_paths = %w(9 self.initial_paths = %w(
@@ -28,6 +30,7 @@ module Docs · 20 unmodified lines
28 options[:fix_urls] = ->(url) do30 options[:fix_urls] = ->(url) do
29 url.sub! %r{(#{Rust.base_url}.+/)\z}, '\1index.html'31 url.sub! %r{(#{Rust.base_url}.+/)\z}, '\1index.html'
30 url.sub! '/unicode/u_str', '/unicode/str/'32 url.sub! '/unicode/u_str', '/unicode/str/'
33 url.sub! '/std/std/', '/std/'
31 url34 url
32 end35 end
33 36