update Ember docs to latest version
Unified · Split
| @@ -273,7 +273,7 @@ credits = [ · 272 unmodified lines | ||
| 273 | 273 | 'https://www.gnu.org/licenses/gpl-3.0.html' |
| 274 | 274 | ], [ |
| 275 | 275 | 'Ember.js', |
| 276 | − '2017 Yehuda Katz, Tom Dale and Ember.js contributors', | |
| 276 | + '2020 Yehuda Katz, Tom Dale and Ember.js contributors', | |
| 277 | 277 | 'MIT', |
| 278 | 278 | 'https://raw.githubusercontent.com/emberjs/ember.js/master/LICENSE' |
| 279 | 279 | ], [ |
| @@ -2,8 +2,14 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Ember |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − css('hr', '.edit-page').remove | |
| 5 | + css('hr', '.edit-page', '.heading__link__edit', 'aside', '.old-version-warning').remove | |
| 6 | 6 | |
| 7 | + base_url.host.start_with?('api') ? api : guide | |
| 8 | + | |
| 9 | + doc | |
| 10 | + end | |
| 11 | + | |
| 12 | + def api | |
| 7 | 13 | # Remove code highlighting |
| 8 | 14 | css('.highlight').each do |node| |
| 9 | 15 | node.before(%(<div class="pre-title"><code>#{node.at_css('thead').content.strip}</code></div>)) if node.at_css('thead') |
| @@ -13,12 +19,6 @@ module Docs · 3 unmodified lines | ||
| 13 | 19 | node['data-language'] = node['data-language'].sub(/(hbs|handlebars)/, 'html') |
| 14 | 20 | end |
| 15 | 21 | |
| 16 | − base_url.path.start_with?('/api') ? api : guide | |
| 17 | − | |
| 18 | − doc | |
| 19 | − end | |
| 20 | − | |
| 21 | − def api | |
| 22 | 22 | css('h1 .access').each do |node| |
| 23 | 23 | node.replace(" (#{node.content})") |
| 24 | 24 | end |
| @@ -72,7 +72,13 @@ module Docs · 47 unmodified lines | ||
| 72 | 72 | end |
| 73 | 73 | |
| 74 | 74 | def guide |
| 75 | − @doc = at_css('article') | |
| 75 | + # Remove code highlighting | |
| 76 | + css('.filename').each do |node| | |
| 77 | + node.content = node.at_css('pre code').content | |
| 78 | + node.name = 'pre' | |
| 79 | + node['data-language'] = node['class'][/(javascript|js|html|hbs|handlebars)/, 1] | |
| 80 | + node['data-language'] = node['data-language'].sub(/(hbs|handlebars)/, 'html') | |
| 81 | + end | |
| 76 | 82 | |
| 77 | 83 | if root_page? |
| 78 | 84 | at_css('h1').content = 'Ember.js' |
| @@ -2,60 +2,52 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Ember |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | 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{\AEmber\.([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! | |
| 9 | 10 | name << ' (methods)' if subpath.end_with?('/methods') |
| 10 | 11 | name << ' (properties)' if subpath.end_with?('/properties') |
| 11 | 12 | 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 | |
| 17 | 13 | end |
| 14 | + name | |
| 18 | 15 | end |
| 19 | 16 | |
| 20 | 17 | def get_type |
| 21 | − if base_url.path.start_with?('/api') | |
| 18 | + if base_url.host.start_with?('api') | |
| 22 | 19 | 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' | |
| 33 | 24 | 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 | |
| 35 | 28 | end |
| 36 | 29 | 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' | |
| 42 | 31 | end |
| 43 | 32 | end |
| 44 | 33 | |
| 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 | + | |
| 45 | 40 | def additional_entries |
| 46 | − return [] unless base_url.path.start_with?('/api') | |
| 41 | + return [] unless base_url.host.start_with?('api') | |
| 47 | 42 | |
| 48 | 43 | 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 | + | |
| 51 | 46 | name = heading.at_css('span').content.strip |
| 52 | 47 | |
| 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 | |
| 57 | 49 | |
| 58 | − name.prepend "#{self.name.remove(/ \(.*/)}." | |
| 50 | + name.prepend "#{self.name.remove(/ \(.*/)}." unless self.name == 'Function' | |
| 59 | 51 | name << '()' if node['class'].include?('method') |
| 60 | 52 | name << ' (event)' if node['class'].include?('event') |
| 61 | 53 | |
| @@ -1,3 +1,5 @@ | ||
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 1 | 3 | module Docs |
| 2 | 4 | class Ember < UrlScraper |
| 3 | 5 | include MultipleBaseUrls |
| @@ -5,12 +7,6 @@ module Docs · 1 unmodified line | ||
| 5 | 7 | self.name = 'Ember.js' |
| 6 | 8 | self.slug = 'ember' |
| 7 | 9 | self.type = 'ember' |
| 8 | − self.release = '2.15.0' | |
| 9 | − self.base_urls = [ | |
| 10 | − 'https://guides.emberjs.com/v2.15.0/', | |
| 11 | − 'https://emberjs.com/api/ember/2.15/', | |
| 12 | − 'https://emberjs.com/api/ember-data/2.14/' | |
| 13 | − ] | |
| 14 | 10 | self.links = { |
| 15 | 11 | home: 'https://emberjs.com/', |
| 16 | 12 | code: 'https://github.com/emberjs/ember.js' |
| @@ -21,10 +17,10 @@ module Docs · 4 unmodified lines | ||
| 21 | 17 | options[:trailing_slash] = false |
| 22 | 18 | |
| 23 | 19 | options[:container] = ->(filter) do |
| 24 | − if filter.base_url.path.start_with?('/api') | |
| 25 | − 'main article' | |
| 26 | − else | |
| 20 | + if filter.base_url.host.start_with?('api') | |
| 27 | 21 | 'main' |
| 22 | + else | |
| 23 | + 'main article' | |
| 28 | 24 | end |
| 29 | 25 | end |
| 30 | 26 | |
| @@ -39,26 +35,40 @@ module Docs · 8 unmodified lines | ||
| 39 | 35 | options[:skip_patterns] = [ |
| 40 | 36 | /\._/, |
| 41 | 37 | /contributing/, |
| 42 | − /classes\/String/, | |
| 43 | − /namespaces\/Ember/, | |
| 44 | − /namespaces\/DS/ | |
| 38 | + /tutorial/, | |
| 39 | + /js-primer/, | |
| 40 | + /in-depth-topics$/, | |
| 41 | + /managing-dependencies$/ | |
| 45 | 42 | ] |
| 46 | 43 | |
| 47 | 44 | options[:attribution] = <<-HTML |
| 48 | − © 2017 Yehuda Katz, Tom Dale and Ember.js contributors<br> | |
| 45 | + © 2020 Yehuda Katz, Tom Dale and Ember.js contributors<br> | |
| 49 | 46 | Licensed under the MIT License. |
| 50 | 47 | HTML |
| 51 | 48 | |
| 52 | − def initial_urls | |
| 53 | − %w( | |
| 54 | − https://guides.emberjs.com/v2.15.0/ | |
| 55 | − https://emberjs.com/api/ember/2.15/classes/Ember | |
| 56 | − https://emberjs.com/api/ember-data/2.14/classes/DS | |
| 57 | − ) | |
| 49 | + options[:decode_and_clean_paths] = true # handle paths like @ember/application | |
| 50 | + | |
| 51 | + version '3' do | |
| 52 | + self.release = '3.25.0' | |
| 53 | + self.base_urls = %w[ | |
| 54 | + https://guides.emberjs.com/v3.25.0/ | |
| 55 | + https://api.emberjs.com/ember/3.25/ | |
| 56 | + https://api.emberjs.com/ember-data/3.25/ | |
| 57 | + ] | |
| 58 | + end | |
| 59 | + | |
| 60 | + version '2' do | |
| 61 | + self.release = '2.18.0' | |
| 62 | + self.base_urls = %w[ | |
| 63 | + https://guides.emberjs.com/v2.18.0/ | |
| 64 | + https://api.emberjs.com/ember/2.18/ | |
| 65 | + https://api.emberjs.com/ember-data/2.18/ | |
| 66 | + ] | |
| 67 | + options[:skip_patterns].push(/handlebars-basics$/) | |
| 58 | 68 | end |
| 59 | 69 | |
| 60 | 70 | def get_latest_version(opts) |
| 61 | − doc = fetch_doc('https://emberjs.com/api/ember/release', opts) | |
| 71 | + doc = fetch_doc('https://api.emberjs.com/ember/release', opts) | |
| 62 | 72 | doc.at_css('.sidebar > .select-container .ember-power-select-selected-item').content.strip |
| 63 | 73 | end |
| 64 | 74 | end |