Update MDN docs

pull/407/head
Thibaut Courouble 9 years ago
parent 58cfafd7d5
commit 84566eac80

@ -1,15 +0,0 @@
#= require views/pages/base
class app.views.MdnPage extends app.views.BasePage
@className: '_mdn'
LANGUAGE_REGEXP = /brush: ?(\w+)/
prepare: ->
for el in @findAll 'pre[class^="brush"]'
language = el.className.match(LANGUAGE_REGEXP)[1]
.replace('html', 'markup')
.replace('js', 'javascript')
el.className = ''
@highlightCode el, language
return

@ -14,6 +14,7 @@ app.views.GoPage =
app.views.LaravelPage =
app.views.LodashPage =
app.views.MarionettePage =
app.views.MdnPage =
app.views.MeteorPage =
app.views.ModernizrPage =
app.views.MomentPage =

@ -27,6 +27,11 @@ module Docs
css('div > .overheadIndicator:first-child:last-child').each do |node|
node.parent.replace(node)
end
css('.syntaxbox > pre:first-child:last-child').each do |node|
node['class'] = 'syntaxbox'
node.parent.before(node).remove
end
end
end
end

@ -10,6 +10,7 @@ module Docs
'Canvas ' => 'Canvas',
'CSS Font Loading' => 'CSS',
'CSS Object Model' => 'CSS',
'Credential' => 'Credential Management',
'Cryptography' => 'Web Cryptography',
'Device Orientation' => 'Device Orientation',
'Encoding' => 'Encoding',
@ -95,6 +96,7 @@ module Docs
'Crypto' => 'Web Cryptography',
'Drag' => 'Drag & Drop',
'FormData' => 'XMLHTTPRequest',
'History' => 'History',
'ImageBitmap' => 'Canvas',
'ImageData' => 'Canvas',
'IndexedDB' => 'IndexedDB',
@ -216,6 +218,10 @@ module Docs
end
end
if slug == 'History_API'
entries << ['history.pushState()', 'The_pushState()_method']
end
entries
end
end

@ -2,17 +2,6 @@ module Docs
class Html
class CleanHtmlFilter < Filter
def call
root_page? ? root : other
doc
end
def root
css('p').each do |node|
node.remove if node.content.lstrip.start_with? 'The symbol'
end
end
def other
css('span > .icon-thumbs-down-alt:first-child:last-child').each do |node|
node.parent.replace('deprecated')
end
@ -24,6 +13,8 @@ module Docs
css('span > .icon-warning-sign:first-child:last-child').each do |node|
node.parent.replace('non standard')
end
doc
end
end
end

@ -7,27 +7,35 @@ module Docs
def get_name
name = super
name.remove!('Element.').try(:downcase!)
name.sub!('Element.', '').try(:downcase!)
name.sub!('Global attributes.', '').try(:concat, ' (attribute)')
name.sub!(/input.(\w+)/, 'input type="\1"')
name
end
def get_type
slug = self.slug.remove('Element/')
if at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug)
if self.slug.start_with?('Global_attr')
'Attributes'
elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug)
'Obsolete'
else
spec = css('.standard-table').last.try(:content)
if (spec && html5_spec?(spec)) || HTML5.include?(slug)
'HTML5'
else
'Standard'
if self.slug.start_with?('Element/')
'Standard'
else
'Miscellaneous'
end
end
end
end
def include_default_entry?
return false if %w(Attributes Link_types Element/Heading_Elements).include?(slug)
return false if %w(Element/Heading_Elements).include?(slug)
(node = doc.at_css '.overheadIndicator').nil? || node.content.exclude?('not on a standards track')
end
@ -35,10 +43,11 @@ module Docs
return ADDITIONAL_ENTRIES[slug] if ADDITIONAL_ENTRIES.key?(slug)
if slug == 'Attributes'
css('.standard-table td:first-child').map do |node|
css('.standard-table td:first-child').each_with_object [] do |node, entries|
next if node.next_element.content.include?('Global attribute')
name = "#{node.content.strip} (attribute)"
id = node.parent['id'] = name.parameterize
[name, id, 'Attributes']
entries << [name, id, 'Attributes']
end
elsif slug == 'Link_types'
css('.standard-table td:first-child > code').map do |node|

@ -10,6 +10,8 @@ module Docs
'.draftHeader',
'.hidden',
'.button.section-edit',
'.communitybox',
'#Quick_Links',
'hr']
def call
@ -30,6 +32,11 @@ module Docs
node.before(node.content).remove
end
css('pre[class^="brush"]').each do |node|
node['data-language'] = node['class'][/brush: ?(\w+)/, 1]
node.remove_attribute('class')
end
doc
end
end

@ -70,7 +70,7 @@ module Docs
return if url.include?('_') || url.include?('?')
url.sub! 'https://developer.mozilla.org/en-US/docs/DOM/', "#{Dom.base_url}/"
url.sub! 'https://developer.mozilla.org/en/DOM/', "#{Dom.base_url}/"
url.sub! 'https://developer.mozilla.org/Web/API/', "#{Dom.base_url}/"
url.sub! 'https://developer.mozilla.org/Web/API/', "#{Dom.base_url}/"
url.sub! "#{Dom.base_url}/Console", "#{Dom.base_url}/console"
url.sub! "#{Dom.base_url}/Document\/", "#{Dom.base_url}/document\/"
url.sub! "#{Dom.base_url}/Element", "#{Dom.base_url}/element"
@ -82,6 +82,7 @@ module Docs
url.sub! "#{Dom.base_url}/notification", "#{Dom.base_url}/Notification"
url.sub! "#{Dom.base_url}/range", "#{Dom.base_url}/Range"
url.sub! "#{Dom.base_url}/event", "#{Dom.base_url}/Event"
url.sub! '/en/DOM/Manipulating_the_browser_history', "/en-US/docs/Web/API/History_API"
url
end
end

@ -2,8 +2,6 @@ module Docs
class Html < Mdn
self.name = 'HTML'
self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML'
self.root_path = '/Element'
self.initial_paths = %w(/Attributes /Link_types)
html_filters.push 'html/clean_html', 'html/entries', 'title'
@ -12,17 +10,18 @@ module Docs
options[:title] = ->(filter) do
if filter.slug == 'Element/Heading_Elements'
'Heading Elements'
elsif filter.slug == 'Attributes'
'Attributes'
elsif filter.slug == 'Link_types'
'Link types'
else
elsif filter.slug.start_with?('Element/')
"<#{filter.default_title}>"
else
filter.default_title
end
end
options[:skip] = ['/Element/shadow']
options[:only_patterns] = [/\A\/Element/]
options[:skip] = %w(
/index
/Element/shadow
/Element/webkit-meter-optimum-value
)
options[:replace_paths] = {
'/Element/h1' => '/Element/Heading_Elements',
@ -30,6 +29,7 @@ module Docs
'/Element/h3' => '/Element/Heading_Elements',
'/Element/h4' => '/Element/Heading_Elements',
'/Element/h5' => '/Element/Heading_Elements',
'/Element/h6' => '/Element/Heading_Elements' }
'/Element/h6' => '/Element/Heading_Elements',
'/Global_attributes/data-%2A' => '/Global_attributes/data-*' }
end
end

Loading…
Cancel
Save