@@ -2,60 +2,52 @@ module Docs
22 class Ember
33 class EntriesFilter < Docs ::EntriesFilter
44 def get_name
5- if base_url . path . start_with? ( '/api' )
6- name = at_css ( 'h1' ) . child . content . strip
7- # Remove "Ember." prefix if the next character is uppercase
8- name . sub! %r{\A Ember\. ([A-Z])(?!EATURES)} , '\1'
5+ name = at_css ( 'h1' ) . content
6+ if base_url . host . start_with? ( 'api' )
7+ name . gsub! ( 'Package' , '' )
8+ name . gsub! ( 'Class' , '' )
9+ name . strip!
910 name << ' (methods)' if subpath . end_with? ( '/methods' )
1011 name << ' (properties)' if subpath . end_with? ( '/properties' )
1112 name << ' (events)' if subpath . end_with? ( '/events' )
12- name
13- else
14- name = at_css ( 'article h1' ) . content . remove ( 'Edit Page' ) . strip
15- name = at_css ( 'li.toc-level-0.selected > a' ) . content if name == 'Introduction'
16- name
1713 end
14+ name
1815 end
1916
2017 def get_type
21- if base_url . path . start_with? ( '/ api' )
18+ if base_url . host . start_with? ( 'api' )
2219 name = self . name . remove ( / \( .*/ )
23- if name =~ /\A [a-z\- ]+\z /
24- 'Modules'
25- elsif name . start_with? ( 'DS' )
26- 'Data'
27- elsif name . start_with? ( 'RSVP' )
28- 'RSVP'
29- elsif name . start_with? ( 'Test' )
30- 'Test'
31- elsif name . start_with? ( 'Ember' )
32- name . split ( '.' ) [ 0 ..1 ] . join ( '.' )
20+ if name == 'Function'
21+ '3. Functions'
22+ elsif at_css ( 'h1' ) . content . start_with? ( 'Package' )
23+ '2. Packages'
3324 else
34- name . split ( '.' ) . first
25+ name = name . remove ( ' (methods)' ) . remove ( ' (properties)' ) . remove ( ' (events)' )
26+ # Reference gets sorted to the top by default, need to have it with other classes so add a zero width space
27+ name == 'Reference' ? 'Reference' : name
3528 end
3629 else
37- if node = at_css ( 'li.toc-level-0.selected > a' )
38- "Guide: #{ node . content . strip } "
39- else
40- 'Guide'
41- end
30+ '1. Guide'
4231 end
4332 end
4433
34+ def include_default_entry?
35+ return false if name == 'Function' # these should be included in the corresponding Package page
36+
37+ super
38+ end
39+
4540 def additional_entries
46- return [ ] unless base_url . path . start_with? ( '/ api' )
41+ return [ ] unless base_url . host . start_with? ( 'api' )
4742
4843 css ( 'section' ) . each_with_object [ ] do |node , entries |
49- next unless heading = node . at_css ( 'h3[data-anchor]' )
50- next if node . at_css ( '.github-link' ) . content . include? ( 'Inherited' )
44+ next unless heading = node . at_css ( '> h3[data-anchor]' )
45+
5146 name = heading . at_css ( 'span' ) . content . strip
5247
53- # Give their own type to "Ember.platform", "Ember.run", etc.
54- if self . type != 'Data' && name . include? ( '.' )
55- type = "#{ self . name . remove ( / \( .*/ ) } .#{ name . split ( '.' ) . first } "
56- end
48+ next if name . start_with? ( '_' ) # exclude private methods/properties
5749
58- name . prepend "#{ self . name . remove ( / \( .*/ ) } ."
50+ name . prepend "#{ self . name . remove ( / \( .*/ ) } ." unless self . name == 'Function'
5951 name << '()' if node [ 'class' ] . include? ( 'method' )
6052 name << ' (event)' if node [ 'class' ] . include? ( 'event' )
6153
0 commit comments