|
|
@@ -2,46 +2,48 @@ module Docs
|
|
|
class Codeception
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
def get_name
|
|
|
- (subpath.scan(/\d\d/).first || '') + ' ' + (at_css('h1') || at_css('h2')).content
|
|
|
- end
|
|
|
+ name = (at_css('h1') || at_css('h2')).content
|
|
|
|
|
|
- def get_type
|
|
|
- return 'Module::' + (at_css('h1') || at_css('h2')).content if subpath.start_with?('modules')
|
|
|
- return 'Guides' if subpath =~ /\d\d/
|
|
|
- (at_css('h1') || at_css('h2')).content
|
|
|
+ if number = subpath[/\A\d+/]
|
|
|
+ name.prepend "#{number.to_i}. "
|
|
|
+ end
|
|
|
+
|
|
|
+ name
|
|
|
end
|
|
|
|
|
|
- def include_default_entry?
|
|
|
- return true if %w(Guides).include? type
|
|
|
- return true if type =~ /(Module)|(Util)/
|
|
|
- false
|
|
|
+ def get_type
|
|
|
+ if subpath =~ /\d\d/
|
|
|
+ 'Guides'
|
|
|
+ elsif subpath.start_with?('modules')
|
|
|
+ "Module: #{name}"
|
|
|
+ elsif name.include?('Util')
|
|
|
+ "Util Class: #{name.split('\\').last}"
|
|
|
+ else
|
|
|
+ "Reference: #{name}"
|
|
|
+ end
|
|
|
end
|
|
|
|
|
|
def additional_entries
|
|
|
-
|
|
|
if type =~ /Module/
|
|
|
- prefix = type.sub(/Module::/, '')+ '::'
|
|
|
+ prefix = "#{name}::"
|
|
|
pattern = '#actions ~ h4'
|
|
|
elsif type =~ /Functions/
|
|
|
prefix = ''
|
|
|
- pattern = 'h4'
|
|
|
- elsif type =~ /Util/
|
|
|
- prefix = type.sub(/Codeception\/Util/, '')+ '::'
|
|
|
+ pattern = '#page h4'
|
|
|
+ elsif name =~ /Util/
|
|
|
+ prefix = "#{name.remove('Codeception\\Util\\')}::"
|
|
|
pattern = 'h3'
|
|
|
elsif type =~ /(Commands)|(Configuration)/
|
|
|
- prefix = ''
|
|
|
- pattern = 'h2'
|
|
|
- else
|
|
|
prefix = ''
|
|
|
- pattern = 'none'
|
|
|
+ pattern = 'h2'
|
|
|
end
|
|
|
|
|
|
+ return [] unless pattern
|
|
|
+
|
|
|
css(pattern).map do |node|
|
|
|
[prefix + node.content, node['id']]
|
|
|
end.compact
|
|
|
-
|
|
|
end
|
|
|
-
|
|
|
end
|
|
|
end
|
|
|
end
|