@@ -3,13 +3,22 @@ class Rust
33 class EntriesFilter < Docs ::EntriesFilter
44
55 def get_name
6- if slug . start_with? ( 'book' ) || slug . start_with? ( 'reference' )
7- name = at_css ( "h2" , "h1" )
8- ch1 = slug [ /ch(\d +)-(\d +)/ , 1 ]
9- ch2 = slug [ /ch(\d +)-(\d +)/ , 2 ]
6+ if slug . start_with? ( 'book' )
7+ name = at_css ( 'main h1' , 'main h2' )
8+
9+ if slug . start_with? ( 'book/appendix' )
10+ return name ? name . content : 'Appendix'
11+ end
12+
13+ ch1 = slug [ /ch(\d +)-(\d +)/ , 1 ] || '00'
14+ ch2 = slug [ /ch(\d +)-(\d +)/ , 2 ] || '00'
1015 name ? "#{ ch1 } .#{ ch2 } . #{ name . content } " : 'Introduction'
11- elsif slug == 'error-index'
16+ elsif slug . start_with? ( 'reference' )
17+ at_css ( 'main h1' ) . content
18+ elsif slug == 'error_codes/error-index'
1219 'Compiler Errors'
20+ elsif slug . start_with? ( 'error_codes' )
21+ slug . split ( '/' ) . last . upcase
1322 else
1423 at_css ( 'main h1' ) . at_css ( 'button' ) &.remove
1524 name = at_css ( 'main h1' ) . content . remove ( /\A .+\s / ) . remove ( '⎘' )
@@ -26,7 +35,7 @@ def get_type
2635 'Guide'
2736 elsif slug . start_with? ( 'reference' )
2837 'Reference'
29- elsif slug == 'error-index'
38+ elsif slug . start_with? ( 'error_codes' )
3039 'Compiler Errors'
3140 else
3241 path = name . split ( '::' )
@@ -40,12 +49,8 @@ def get_type
4049 end
4150
4251 def additional_entries
43- if slug . start_with? ( 'book' ) || slug . start_with? ( 'reference' )
52+ if slug . start_with? ( 'book' ) || slug . start_with? ( 'reference' ) || slug . start_with? ( 'error_codes' )
4453 [ ]
45- elsif slug == 'error-index'
46- css ( '.error-described h2.section-header' ) . each_with_object [ ] do |node , entries |
47- entries << [ node . content , node [ 'id' ] ] unless node . content . include? ( 'Note:' )
48- end
4954 else
5055 css ( '.method' )
5156 . each_with_object ( { } ) { |node , entries |
0 commit comments