History

Fix how 'notable trait' sections were displayed

- Fix error in reference/introduction.html while scraping

MasterEnoc committed 5 years ago

Commit 8e3b2ce1 parent 4d3bae42 files · +20 −1Browse files

Unified · Split

2 files
  1. lib/docs/filters/rust/clean_html.rb +16 −0
  2. lib/docs/filters/rust/entries.rb +4 −1
lib/docs/filters/rust/clean_html.rb+16−0
@@ -97,6 +97,22 @@ module Docs · 96 unmodified lines
9797 node.previous_element.before(node)
9898 end
9999
100+ css('.collapse-toggle').remove
101+
102+ # Fix how notable-traits sections are shown
103+
104+ css('.method').each do |node|
105+ traitSection = node.at_css('.notable-traits')
106+
107+ if traitSection
108+ traitSectionContent = traitSection.css('.notable-traits-tooltiptext')
109+ traitSection.css('.notable-traits-tooltip').remove
110+ traitSection.add_child(traitSectionContent)
111+ node.after(traitSection)
112+ end
113+
114+ end
115+
100116 doc
101117 end
102118 end
lib/docs/filters/rust/entries.rb+4−1
@@ -1,9 +1,11 @@
11 module Docs
22 class Rust
33 class EntriesFilter < Docs::EntriesFilter
4+
45 def get_name
56 if slug.start_with?('book') || slug.start_with?('reference')
6− at_css("#sidebar a[href='#{File.basename(slug)}']").content
7+ name = at_css("#sidebar a[href='#{File.basename(slug)}']")
8+ name ? name.content : 'Introduction'
79 elsif slug == 'error-index'
810 'Compiler Errors'
911 else
@@ -51,6 +53,7 @@ module Docs · 41 unmodified lines
5153 }.values
5254 end
5355 end
56+
5457 end
5558 end
5659 end