@@ -2,60 +2,50 @@ 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 . start_with? ( '@' ) || name == 'rsvp'
21+ 'Packages'
22+ elsif name == 'Function'
23+ 'Functions'
3324 else
34- name . split ( '.' ) . first
25+ 'Classes'
3526 end
3627 else
37- if node = at_css ( 'li.toc-level-0.selected > a' )
38- "Guide: #{ node . content . strip } "
39- else
40- 'Guide'
41- end
28+ 'Guide'
4229 end
4330 end
4431
32+ def include_default_entry?
33+ return false if name == 'Function' # these should be included in the corresponding Package page
34+
35+ super
36+ end
37+
4538 def additional_entries
46- return [ ] unless base_url . path . start_with? ( '/ api' )
39+ return [ ] unless base_url . host . start_with? ( 'api' )
4740
4841 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' )
42+ next unless heading = node . at_css ( '> h3[data-anchor]' )
43+
5144 name = heading . at_css ( 'span' ) . content . strip
5245
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
46+ next if name . start_with? ( '_' ) # exclude private methods/properties
5747
58- name . prepend "#{ self . name . remove ( / \( .*/ ) } ."
48+ name . prepend "#{ self . name . remove ( / \( .*/ ) } ." unless self . name == 'Function'
5949 name << '()' if node [ 'class' ] . include? ( 'method' )
6050 name << ' (event)' if node [ 'class' ] . include? ( 'event' )
6151
0 commit comments