瀏覽代碼

Update MDN documentations

Closes #615.
Thibaut Courouble 8 年之前
父節點
當前提交
df2af95a54

+ 1 - 3
assets/stylesheets/pages/_mdn.scss

@@ -24,7 +24,7 @@
   > h3 { @extend %block-label, %label-blue; }
   > h4 { font-size: 1em; }
 
-  p > code { @extend %label; }
+  p > code, li > code { @extend %label; }
 
   > .note,
   .notice,
@@ -104,6 +104,4 @@
   .cleared { clear: both; } // CSS/box-shadow
 
   code > strong { font-weight: normal; }
-
-  #compat-desktop, #compat-mobile { @extend ._table; }
 }

+ 2 - 2
lib/docs/filters/dom/entries.rb

@@ -225,8 +225,8 @@ module Docs
         entries = []
 
         if slug == 'history' || slug == 'XMLHttpRequest'
-          css('dt a[title*="not yet been written"]').each do |node|
-            next if node.parent.at_css('.obsolete')
+          css('dt a[href^="https://developer.mozilla.org"]').each do |node|
+            next if node.parent.at_css('.obsolete') || node.content.include?('moz')
             name = node.content.sub('History', 'history')
             id = node.parent['id'] = name.parameterize
             entries << [name, id]

+ 3 - 2
lib/docs/filters/dom_events/entries.rb

@@ -8,7 +8,7 @@ module Docs
         'Clipboard'        => 'Clipboard',
         'CSS'              => 'CSS',
         'Drag'             => 'Drag & Drop',
-        'Focus'            => 'Focus',
+        'Fetch'            => 'Fetch',
         'Fullscreen'       => 'Fullscreen',
         'Gamepad'          => 'Gamepad',
         'HashChange'       => 'History',
@@ -43,7 +43,8 @@ module Docs
         'WebRTC'           => 'WebRTC',
         'WebVR'            => 'WebVR',
         'Wheel'            => 'Mouse',
-        'Worker'           => 'Web Workers' }
+        'Worker'           => 'Web Workers',
+        'Focus'            => 'Focus' }
 
       FORM_SLUGS = %w(change compositionend compositionstart compositionupdate
         input invalid reset select submit)

+ 5 - 0
lib/docs/filters/http/entries.rb

@@ -83,6 +83,11 @@ module Docs
           [2, 5, 6],
           [3, 4],
           []
+        ],
+        'rfc5023' => [
+          [],
+          [],
+          []
         ]
       }
 

+ 0 - 5
lib/docs/filters/javascript/clean_html.rb

@@ -7,11 +7,6 @@ module Docs
       end
 
       def root
-        # Move "Global Objects" lists to the same level as the other ones
-        css('#Global_Objects + p').remove
-        div = at_css '#Global_Objects + div'
-        div.css('h3').each { |node| node.name = 'h2' }
-        at_css('#Global_Objects').replace(div.children)
       end
 
       def other

+ 15 - 1
lib/docs/filters/mdn/clean_html.rb

@@ -21,12 +21,16 @@ module Docs
           node.name = 'th'
         end
 
-        css('nobr', 'span[style*="font"]', 'pre code', 'h2 strong').each do |node|
+        css('nobr', 'span[style*="font"]', 'pre code', 'h2 strong', 'div:not([class])', 'span.seoSummary').each do |node|
           node.before(node.children).remove
         end
 
         css('h2[style]', 'pre[style]', 'th[style]', 'div[style*="line-height"]', 'table[style]', 'pre p[style]').remove_attr('style')
 
+        css('a[title]', 'span[title]').remove_attr('title')
+        css('a.glossaryLink').remove_attr('class')
+        css('*[lang]').remove_attr('lang')
+
         css('h2 > a[name]', 'h3 > a[name]').each do |node|
           node.parent['id'] = node['name']
           node.before(node.content).remove
@@ -37,6 +41,16 @@ module Docs
           node.remove_attribute('class')
         end
 
+        css('pre.eval').each do |node|
+          node.content = node.content
+          node.remove_attribute('class')
+        end
+
+        css('table').each do |node|
+          node.before %(<div class="_table"></div>)
+          node.previous_element << node
+        end
+
         doc
       end
     end

+ 10 - 14
lib/docs/scrapers/http.rb

@@ -8,26 +8,21 @@ module Docs
     html_filters.push 'http/clean_html', 'http/entries', 'title'
 
     options[:root_title] = 'HTTP'
-    options[:title] = ->(filter) {
-      filter.current_url.host == 'tools.ietf.org' ? false : filter.default_title
-    }
-    options[:container] = ->(filter) {
-      filter.current_url.host == 'tools.ietf.org' ? '.content' : nil
-    }
-    options[:skip_links] = ->(filter) {
-      filter.current_url.host == 'tools.ietf.org' ? true : false
-    }
-    options[:fix_urls] = ->(url) {
+    options[:title] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? false : filter.default_title }
+    options[:container] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? '.content' : nil }
+    options[:skip_links] = ->(filter) { filter.current_url.host == 'tools.ietf.org' ? true : false }
+    options[:fix_urls] = ->(url) do
       url.sub! %r{(Status/\d\d\d)_[A-Z].+}, '\1'
       url
-    }
-    options[:attribution] = ->(filter) {
+    end
+
+    options[:attribution] = ->(filter) do
       if filter.current_url.host == 'tools.ietf.org'
         "&copy; document authors. All rights reserved."
       else
         Docs::Mdn.options[:attribution]
       end
-    }
+    end
 
     def initial_urls
       %w(https://developer.mozilla.org/en-US/docs/Web/HTTP
@@ -38,7 +33,8 @@ module Docs
          https://tools.ietf.org/html/rfc7232
          https://tools.ietf.org/html/rfc7233
          https://tools.ietf.org/html/rfc7234
-         https://tools.ietf.org/html/rfc7235)
+         https://tools.ietf.org/html/rfc7235
+         https://tools.ietf.org/html/rfc5023)
     end
   end
 end

+ 1 - 0
lib/docs/scrapers/mdn/css.rb

@@ -21,6 +21,7 @@ module Docs
       '/var' => '/var()',
       '/element' => '/element()',
       '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes',
+      '/flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes',
       '/currentColor' => '/color_value'
     }
 

+ 2 - 0
lib/docs/scrapers/mdn/html.rb

@@ -1,5 +1,7 @@
 module Docs
   class Html < Mdn
+    prepend FixInternalUrlsBehavior
+
     self.name = 'HTML'
     self.base_url = 'https://developer.mozilla.org/en-US/docs/Web/HTML'
 

+ 1 - 1
lib/docs/scrapers/mdn/mdn.rb

@@ -6,7 +6,7 @@ module Docs
     params[:raw] = 1
     params[:macros] = 1
 
-    html_filters.push 'mdn/clean_html'
+    html_filters.push 'mdn/clean_html', 'images'
     text_filters.insert_before 'attribution', 'mdn/contribute_link'
 
     options[:trailing_slash] = false