|
|
@@ -2,60 +2,52 @@ module Docs
|
|
|
class Ember
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
def get_name
|
|
|
- if base_url.path.start_with?('/api')
|
|
|
- name = at_css('h1').child.content.strip
|
|
|
- # Remove "Ember." prefix if the next character is uppercase
|
|
|
- name.sub! %r{\AEmber\.([A-Z])(?!EATURES)}, '\1'
|
|
|
+ name = at_css('h1').content
|
|
|
+ if base_url.host.start_with?('api')
|
|
|
+ name.gsub!('Package', '')
|
|
|
+ name.gsub!('Class', '')
|
|
|
+ name.strip!
|
|
|
name << ' (methods)' if subpath.end_with?('/methods')
|
|
|
name << ' (properties)' if subpath.end_with?('/properties')
|
|
|
name << ' (events)' if subpath.end_with?('/events')
|
|
|
- name
|
|
|
- else
|
|
|
- name = at_css('article h1').content.remove('Edit Page').strip
|
|
|
- name = at_css('li.toc-level-0.selected > a').content if name == 'Introduction'
|
|
|
- name
|
|
|
end
|
|
|
+ name
|
|
|
end
|
|
|
|
|
|
def get_type
|
|
|
- if base_url.path.start_with?('/api')
|
|
|
+ if base_url.host.start_with?('api')
|
|
|
name = self.name.remove(/ \(.*/)
|
|
|
- if name =~ /\A[a-z\-]+\z/
|
|
|
- 'Modules'
|
|
|
- elsif name.start_with?('DS')
|
|
|
- 'Data'
|
|
|
- elsif name.start_with?('RSVP')
|
|
|
- 'RSVP'
|
|
|
- elsif name.start_with?('Test')
|
|
|
- 'Test'
|
|
|
- elsif name.start_with?('Ember')
|
|
|
- name.split('.')[0..1].join('.')
|
|
|
+ if name == 'Function'
|
|
|
+ '3. Functions'
|
|
|
+ elsif at_css('h1').content.start_with?('Package')
|
|
|
+ '2. Packages'
|
|
|
else
|
|
|
- name.split('.').first
|
|
|
+ name = name.remove(' (methods)').remove(' (properties)').remove(' (events)')
|
|
|
+ # Reference gets sorted to the top by default, need to have it with other classes so add a zero width space
|
|
|
+ name == 'Reference' ? 'Reference' : name
|
|
|
end
|
|
|
else
|
|
|
- if node = at_css('li.toc-level-0.selected > a')
|
|
|
- "Guide: #{node.content.strip}"
|
|
|
- else
|
|
|
- 'Guide'
|
|
|
- end
|
|
|
+ '1. Guide'
|
|
|
end
|
|
|
end
|
|
|
|
|
|
+ def include_default_entry?
|
|
|
+ return false if name == 'Function' # these should be included in the corresponding Package page
|
|
|
+
|
|
|
+ super
|
|
|
+ end
|
|
|
+
|
|
|
def additional_entries
|
|
|
- return [] unless base_url.path.start_with?('/api')
|
|
|
+ return [] unless base_url.host.start_with?('api')
|
|
|
|
|
|
css('section').each_with_object [] do |node, entries|
|
|
|
- next unless heading = node.at_css('h3[data-anchor]')
|
|
|
- next if node.at_css('.github-link').content.include?('Inherited')
|
|
|
+ next unless heading = node.at_css('> h3[data-anchor]')
|
|
|
+
|
|
|
name = heading.at_css('span').content.strip
|
|
|
|
|
|
- # Give their own type to "Ember.platform", "Ember.run", etc.
|
|
|
- if self.type != 'Data' && name.include?('.')
|
|
|
- type = "#{self.name.remove(/ \(.*/)}.#{name.split('.').first}"
|
|
|
- end
|
|
|
+ next if name.start_with?('_') # exclude private methods/properties
|
|
|
|
|
|
- name.prepend "#{self.name.remove(/ \(.*/)}."
|
|
|
+ name.prepend "#{self.name.remove(/ \(.*/)}." unless self.name == 'Function'
|
|
|
name << '()' if node['class'].include?('method')
|
|
|
name << ' (event)' if node['class'].include?('event')
|
|
|
|