Update Ember.js documentation (2.14.0)

pull/656/head
Thibaut Courouble 8 years ago
parent 9b28702e3a
commit 1c6c7c06e1

@ -1,22 +1,20 @@
._ember { ._ember {
@extend %simple; @extend %simple;
blockquote.class-info { @extend %note-blue; }
blockquote.class-info > p { margin: 0; }
.pre-title { @extend %pre-heading; } .pre-title { @extend %pre-heading; }
h2 > .flag, h2 > .type { h3 > .access {
margin-left: .5em; float: right;
color: $textColorLight; color: $textColorLight;
font-weight: normal; font-weight: normal;
} }
h2 > .type { float: right; } h3 > .args,
h3 > .return-type {
.meta { color: $textColorLight; } font-weight: normal;
}
dl { margin: 0 1em; } p.github-link {
dt + dt, dd + dt { margin-top: .5em; } color: $textColorLight;
dt > code { @extend %label; } }
} }

@ -13,79 +13,69 @@ module Docs
node['data-language'] = node['data-language'].sub(/(hbs|handlebars)/, 'html') node['data-language'] = node['data-language'].sub(/(hbs|handlebars)/, 'html')
end end
if base_url.path.start_with?('/api') base_url.path.start_with?('/api') ? api : guide
root_page? ? root : api
else
guide
end
doc doc
end end
def root def api
css('#back-to-top').remove css('h1 .access').each do |node|
node.replace(" (#{node.content})")
# Remove "Projects" and "Tag" links
css('.level-1:nth-child(1)', '.level-1:nth-child(2)').remove
# Turn section links (e.g. Modules) into headings
css('.level-1 > a').each do |node|
node.name = 'h2'
node.remove_attribute 'href'
end end
# Remove root-level list css('*[data-anchor]').each do |node|
css('.level-1').each do |node| node['id'] = node['data-anchor']
node.before(node.elements).remove node.remove_attribute('data-anchor')
end end
css('ol').each do |node| css('> h3[id]').each do |node|
node.name = 'ul' node.name = 'h2'
end end
end
def api if subpath.end_with?('/methods') || subpath.end_with?('/properties') || subpath.end_with?('/events')
css('#api-options', '.toc-anchor', '.inherited').remove css('.attributes ~ *').each do |node|
break if node['class'] == 'tabbed-layout'
# Remove tabs and "Index" node.remove
css('.tabs').each do |node| end
panes = node.css '#methods', '#events', '#properties'
panes.remove_attr 'style'
node.before(panes).remove
end end
css('.method', '.property', '.event').remove_attr('id') css('.attributes').each do |node|
html = node.inner_html
html.gsub! %r{<span class="attribute-label">(.+?)</span>}, '<th>\1</th>'
html.gsub! %r{<span class="attribute-value">(.+?)</span>}, '<td>\1</td>'
html.gsub! %r{<div class="attribute">(.+?)</div>}, '<tr>\1</tr>'
node.replace("<table>#{html}</table>")
end
css('h3[data-id]').each do |node| css('div.attribute').each do |node|
heading = Nokogiri::XML::Node.new 'h2', doc node.name = 'p'
heading['id'] = node['data-id']
node.before(heading).remove
heading.content = node.content
heading.add_child(heading.next_element) while heading.next_element.name == 'span'
end end
css('> .class-info').each do |node| css('.tabbed-layout').each do |node|
node.name = 'blockquote' node.before(node.at_css('.api__index__content', '.api-index-filter')).remove
end end
css('div.meta').each do |node| css('div.ember-view', 'dl > div').each do |node|
node.name = 'p' node.before(node.children).remove
end end
css('span.type').each do |node| css('section > h3').each do |node|
node.name = 'code' node.name = 'h4' if node.previous_element
end end
css('.pane', '.item-entry').each do |node| css('section').each do |node|
node.before(node.children).remove node.before(node.children).remove
end end
css('ul', 'h3', 'h4', 'a').remove_attr('class')
css('a[id]').remove_attr('id')
end end
def guide def guide
@doc = at_css('article') @doc = at_css('article')
if root_page? if root_page?
at_css('h1').remove at_css('h1').content = 'Ember.js'
end end
css('.previous-guide', '.next-guide').remove css('.previous-guide', '.next-guide').remove

@ -3,10 +3,13 @@ module Docs
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
if base_url.path.start_with?('/api') if base_url.path.start_with?('/api')
name = at_css('.api-header').content.split.first name = at_css('h1').child.content.strip
# Remove "Ember." prefix if the next character is uppercase # Remove "Ember." prefix if the next character is uppercase
name.sub! %r{\AEmber\.([A-Z])(?!EATURES)}, '\1' name.sub! %r{\AEmber\.([A-Z])(?!EATURES)}, '\1'
name == 'Handlebars.helpers' ? 'Handlebars Helpers' : name name << ' (methods)' if subpath.end_with?('/methods')
name << ' (properties)' if subpath.end_with?('/properties')
name << ' (events)' if subpath.end_with?('/events')
name
else else
name = at_css('article h1').content.remove('Edit Page').strip name = at_css('article h1').content.remove('Edit Page').strip
name = at_css('li.toc-level-0.selected > a').content if name == 'Introduction' name = at_css('li.toc-level-0.selected > a').content if name == 'Introduction'
@ -16,13 +19,14 @@ module Docs
def get_type def get_type
if base_url.path.start_with?('/api') if base_url.path.start_with?('/api')
if at_css('.api-header').content.include?('Module') name = self.name.remove(/ \(.*/)
if name =~ /\A[a-z\-]+\z/
'Modules' 'Modules'
elsif name.start_with? 'DS' elsif name.start_with?('DS')
'Data' 'Data'
elsif name.start_with? 'RSVP' elsif name.start_with?('RSVP')
'RSVP' 'RSVP'
elsif name.start_with? 'Test' elsif name.start_with?('Test')
'Test' 'Test'
elsif name.start_with?('Ember') elsif name.start_with?('Ember')
name.split('.')[0..1].join('.') name.split('.')[0..1].join('.')
@ -41,29 +45,21 @@ module Docs
def additional_entries def additional_entries
return [] unless base_url.path.start_with?('/api') return [] unless base_url.path.start_with?('/api')
css('.item-entry:not(.inherited)').map do |node| css('section').each_with_object [] do |node, entries|
heading = node.at_css('h3[data-id]') next unless heading = node.at_css('h3[data-anchor]')
name = heading.content.strip next if node.at_css('.github-link').content.include?('Inherited')
name = heading.at_css('span').content.strip
if self.name == 'Handlebars Helpers'
name << ' (handlebars helper)'
next [name, heading['data-id']]
end
# Give their own type to "Ember.platform", "Ember.run", etc. # Give their own type to "Ember.platform", "Ember.run", etc.
if self.type != 'Data' && name.include?('.') if self.type != 'Data' && name.include?('.')
type = "#{self.name}.#{name.split('.').first}" type = "#{self.name.remove(/ \(.*/)}.#{name.split('.').first}"
end end
# "." = class method, "#" = instance method name.prepend "#{self.name.remove(/ \(.*/)}."
separator = '#' name << '()' if node['class'].include?('method')
separator = '.' if self.name == 'Ember' || self.name.split('.').last =~ /\A[a-z]/ || node.at_css('.static') name << ' (event)' if node['class'].include?('event')
name.prepend self.name + separator
name << '()' if node['class'].include? 'method'
name << ' event' if node['class'].include? 'event'
[name, heading['data-id'], type] entries << [name, heading['data-anchor'], type]
end end
end end
end end

@ -5,35 +5,56 @@ module Docs
self.name = 'Ember.js' self.name = 'Ember.js'
self.slug = 'ember' self.slug = 'ember'
self.type = 'ember' self.type = 'ember'
self.release = '2.13.0' self.release = '2.14.0'
self.base_urls = ['https://emberjs.com/api/', 'https://guides.emberjs.com/v2.13.0/'] self.base_urls = [
'https://guides.emberjs.com/v2.14.0/',
'https://emberjs.com/api/ember/2.14/',
'https://emberjs.com/api/ember-data/2.14/'
]
self.links = { self.links = {
home: 'https://emberjs.com/', home: 'https://emberjs.com/',
code: 'https://github.com/emberjs/ember.js' code: 'https://github.com/emberjs/ember.js'
} }
html_filters.push 'ember/entries', 'ember/clean_html', 'title' html_filters.push 'ember/entries', 'ember/clean_html'
options[:trailing_slash] = false options[:trailing_slash] = false
options[:title] = false
options[:root_title] = 'Ember.js'
options[:container] = ->(filter) do options[:container] = ->(filter) do
if filter.base_url.path.start_with?('/api') if filter.base_url.path.start_with?('/api')
filter.root_page? ? '#toc-list' : '#content' 'main article'
else else
'main' 'main'
end end
end end
# Duplicates options[:fix_urls] = ->(url) do
options[:skip] = %w(classes/String.html data/classes/DS.html) url.sub! '?anchor=', '#'
options[:skip_patterns] = [/\._/, /contributing/] url.sub! %r{/methods/[^?#/]+}, '/methods'
url.sub! %r{/properties/[^?#/]+}, '/properties'
url.sub! %r{/events/[^?#/]+}, '/events'
url
end
options[:skip_patterns] = [
/\._/,
/contributing/,
/classes\/String/,
/namespaces\/Ember/,
/namespaces\/DS/
]
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2017 Yehuda Katz, Tom Dale and Ember.js contributors<br> &copy; 2017 Yehuda Katz, Tom Dale and Ember.js contributors<br>
Licensed under the MIT License. Licensed under the MIT License.
HTML HTML
def initial_urls
%w(
https://guides.emberjs.com/v2.14.0/
https://emberjs.com/api/ember/2.14/classes/Ember
https://emberjs.com/api/ember-data/2.14/classes/DS
)
end
end end
end end

Loading…
Cancel
Save