@@ -3,13 +3,22 @@ class Rust
3
3
class EntriesFilter < Docs ::EntriesFilter
4
4
5
5
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'
10
15
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'
12
19
'Compiler Errors'
20
+ elsif slug . start_with? ( 'error_codes' )
21
+ slug . split ( '/' ) . last . upcase
13
22
else
14
23
at_css ( 'main h1' ) . at_css ( 'button' ) &.remove
15
24
name = at_css ( 'main h1' ) . content . remove ( /\A .+\s / ) . remove ( '⎘' )
@@ -26,7 +35,7 @@ def get_type
26
35
'Guide'
27
36
elsif slug . start_with? ( 'reference' )
28
37
'Reference'
29
- elsif slug == 'error-index'
38
+ elsif slug . start_with? ( 'error_codes' )
30
39
'Compiler Errors'
31
40
else
32
41
path = name . split ( '::' )
@@ -40,12 +49,8 @@ def get_type
40
49
end
41
50
42
51
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' )
44
53
[ ]
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
49
54
else
50
55
css ( '.method' )
51
56
. each_with_object ( { } ) { |node , entries |
0 commit comments