@@ -2,46 +2,48 @@ module Docs
22 class Codeception
33 class EntriesFilter < Docs ::EntriesFilter
44 def get_name
5- ( subpath . scan ( /\d \d / ) . first || '' ) + ' ' + ( at_css ( 'h1' ) || at_css ( 'h2' ) ) . content
6- end
5+ name = ( at_css ( 'h1' ) || at_css ( 'h2' ) ) . content
76
8- def get_type
9- return 'Module::' + ( at_css ( 'h1' ) || at_css ( 'h2' ) ) . content if subpath . start_with? ( 'modules' )
10- return 'Guides' if subpath =~ /\d \d /
11- ( at_css ( 'h1' ) || at_css ( 'h2' ) ) . content
7+ if number = subpath [ /\A \d +/ ]
8+ name . prepend "#{ number . to_i } . "
9+ end
10+
11+ name
1212 end
1313
14- def include_default_entry?
15- return true if %w( Guides ) . include? type
16- return true if type =~ /(Module)|(Util)/
17- false
14+ def get_type
15+ if subpath =~ /\d \d /
16+ 'Guides'
17+ elsif subpath . start_with? ( 'modules' )
18+ "Module: #{ name } "
19+ elsif name . include? ( 'Util' )
20+ "Util Class: #{ name . split ( '\\' ) . last } "
21+ else
22+ "Reference: #{ name } "
23+ end
1824 end
1925
2026 def additional_entries
21-
2227 if type =~ /Module/
23- prefix = type . sub ( /Module::/ , '' ) + '::'
28+ prefix = " #{ name } ::"
2429 pattern = '#actions ~ h4'
2530 elsif type =~ /Functions/
2631 prefix = ''
27- pattern = 'h4'
28- elsif type =~ /Util/
29- prefix = type . sub ( / Codeception\/ Util/ , '' ) + '::'
32+ pattern = '#page h4'
33+ elsif name =~ /Util/
34+ prefix = " #{ name . remove ( ' Codeception\\ Util\\' ) } ::"
3035 pattern = 'h3'
3136 elsif type =~ /(Commands)|(Configuration)/
32- prefix = ''
33- pattern = 'h2'
34- else
3537 prefix = ''
36- pattern = 'none '
38+ pattern = 'h2 '
3739 end
3840
41+ return [ ] unless pattern
42+
3943 css ( pattern ) . map do |node |
4044 [ prefix + node . content , node [ 'id' ] ]
4145 end . compact
42-
4346 end
44-
4547 end
4648 end
4749end
0 commit comments