diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee
index a868b281..0ff146b5 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -273,7 +273,7 @@ credits = [
'https://www.gnu.org/licenses/gpl-3.0.html'
], [
'Ember.js',
- '2017 Yehuda Katz, Tom Dale and Ember.js contributors',
+ '2020 Yehuda Katz, Tom Dale and Ember.js contributors',
'MIT',
'https://raw.githubusercontent.com/emberjs/ember.js/master/LICENSE'
], [
diff --git a/lib/docs/filters/ember/clean_html.rb b/lib/docs/filters/ember/clean_html.rb
index 4f210ce2..d33547af 100644
--- a/lib/docs/filters/ember/clean_html.rb
+++ b/lib/docs/filters/ember/clean_html.rb
@@ -2,8 +2,14 @@ module Docs
class Ember
class CleanHtmlFilter < Filter
def call
- css('hr', '.edit-page').remove
+ css('hr', '.edit-page', '.heading__link__edit', 'aside', '.old-version-warning').remove
+ base_url.host.start_with?('api') ? api : guide
+
+ doc
+ end
+
+ def api
# Remove code highlighting
css('.highlight').each do |node|
node.before(%(
#{node.at_css('thead').content.strip}
)) if node.at_css('thead')
@@ -13,12 +19,6 @@ module Docs
node['data-language'] = node['data-language'].sub(/(hbs|handlebars)/, 'html')
end
- base_url.path.start_with?('/api') ? api : guide
-
- doc
- end
-
- def api
css('h1 .access').each do |node|
node.replace(" (#{node.content})")
end
@@ -72,7 +72,13 @@ module Docs
end
def guide
- @doc = at_css('article')
+ # Remove code highlighting
+ css('.filename').each do |node|
+ node.content = node.at_css('pre code').content
+ node.name = 'pre'
+ node['data-language'] = node['class'][/(javascript|js|html|hbs|handlebars)/, 1]
+ node['data-language'] = node['data-language'].sub(/(hbs|handlebars)/, 'html')
+ end
if root_page?
at_css('h1').content = 'Ember.js'
diff --git a/lib/docs/filters/ember/entries.rb b/lib/docs/filters/ember/entries.rb
index 39125adc..4c469272 100644
--- a/lib/docs/filters/ember/entries.rb
+++ b/lib/docs/filters/ember/entries.rb
@@ -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')
diff --git a/lib/docs/scrapers/ember.rb b/lib/docs/scrapers/ember.rb
index 6f853bb9..c5c3ac72 100644
--- a/lib/docs/scrapers/ember.rb
+++ b/lib/docs/scrapers/ember.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
module Docs
class Ember < UrlScraper
include MultipleBaseUrls
@@ -5,12 +7,6 @@ module Docs
self.name = 'Ember.js'
self.slug = 'ember'
self.type = 'ember'
- self.release = '2.15.0'
- self.base_urls = [
- 'https://guides.emberjs.com/v2.15.0/',
- 'https://emberjs.com/api/ember/2.15/',
- 'https://emberjs.com/api/ember-data/2.14/'
- ]
self.links = {
home: 'https://emberjs.com/',
code: 'https://github.com/emberjs/ember.js'
@@ -21,10 +17,10 @@ module Docs
options[:trailing_slash] = false
options[:container] = ->(filter) do
- if filter.base_url.path.start_with?('/api')
- 'main article'
- else
+ if filter.base_url.host.start_with?('api')
'main'
+ else
+ 'main article'
end
end
@@ -39,26 +35,40 @@ module Docs
options[:skip_patterns] = [
/\._/,
/contributing/,
- /classes\/String/,
- /namespaces\/Ember/,
- /namespaces\/DS/
+ /tutorial/,
+ /js-primer/,
+ /in-depth-topics$/,
+ /managing-dependencies$/
]
options[:attribution] = <<-HTML
- © 2017 Yehuda Katz, Tom Dale and Ember.js contributors
+ © 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
HTML
- def initial_urls
- %w(
- https://guides.emberjs.com/v2.15.0/
- https://emberjs.com/api/ember/2.15/classes/Ember
- https://emberjs.com/api/ember-data/2.14/classes/DS
- )
+ options[:decode_and_clean_paths] = true # handle paths like @ember/application
+
+ version '3' do
+ self.release = '3.25.0'
+ self.base_urls = %w[
+ https://guides.emberjs.com/v3.25.0/
+ https://api.emberjs.com/ember/3.25/
+ https://api.emberjs.com/ember-data/3.25/
+ ]
+ end
+
+ version '2' do
+ self.release = '2.18.0'
+ self.base_urls = %w[
+ https://guides.emberjs.com/v2.18.0/
+ https://api.emberjs.com/ember/2.18/
+ https://api.emberjs.com/ember-data/2.18/
+ ]
+ options[:skip_patterns].push(/handlebars-basics$/)
end
def get_latest_version(opts)
- doc = fetch_doc('https://emberjs.com/api/ember/release', opts)
+ doc = fetch_doc('https://api.emberjs.com/ember/release', opts)
doc.at_css('.sidebar > .select-container .ember-power-select-selected-item').content.strip
end
end