Sfoglia il codice sorgente

Update MDN docs

Closes #476.
Thibaut Courouble 9 anni fa
parent
commit
f7ec336112

+ 4 - 0
assets/stylesheets/pages/_mdn.scss

@@ -22,9 +22,11 @@
 
   > h2 { @extend %block-heading; }
   > h3 { @extend %block-label, %label-blue; }
+  > h4 { font-size: 1em; }
 
   > .note,
   .notice,
+  .warning,
   .overheadIndicator,
   .syntaxbox,           // CSS, JavaScript
   .twopartsyntaxbox,    // CSS
@@ -33,6 +35,8 @@
     @extend %note;
   }
 
+  .warning { @extend %note-red; }
+
   > .note {
     em {
       font-style: normal;

+ 4 - 0
lib/docs/filters/css/clean_html.rb

@@ -12,6 +12,10 @@ module Docs
       end
 
       def other
+        css('.syntaxbox > .syntaxbox').each do |node|
+          node.parent.before(node.parent.children).remove
+        end
+
         # Remove "|" and "||" links in syntax box (e.g. animation, all, etc.)
         css('.syntaxbox', '.twopartsyntaxbox').css('a').each do |node|
           if node.content == '|' || node.content == '||'

+ 8 - 1
lib/docs/filters/css/entries.rb

@@ -42,7 +42,9 @@ module Docs
       end
 
       def get_type
-        if type = TYPE_BY_PATH[slug.split('/').first]
+        if slug.include?('-webkit') || slug.include?('-moz')
+          'Extensions'
+        elsif type = TYPE_BY_PATH[slug.split('/').first]
           type
         elsif type = get_spec
           type.remove! 'CSS '
@@ -123,6 +125,11 @@ module Docs
       def additional_entries
         ADDITIONAL_ENTRIES[slug] || []
       end
+
+      def include_default_entry?
+        return true unless warning = at_css('.warning').try(:content)
+        !warning.include?('CSS Flexible Box') && !warning.include?('replaced in newer drafts')
+      end
     end
   end
 end

+ 7 - 3
lib/docs/filters/dom/entries.rb

@@ -23,9 +23,10 @@ module Docs
         'Intersection'        => 'Intersection Observer',
         'Media Capture'       => 'Media',
         'Media Source'        => 'Media',
-        'MediaStream'         => 'Stream',
+        'MediaStream'         => 'Media Streams',
         'Navigation Timing'   => 'Web Performance',
         'Network Information' => 'Network Information',
+        'Payment Request'     => 'Payment Request',
         'Performance Timeline' => 'Web Performance',
         'Pointer Events'      => 'Pointer Events',
         'Push API'            => 'Push',
@@ -33,7 +34,8 @@ module Docs
         'Shadow DOM'          => 'Shadow DOM',
         'Server-Sent Events'  => 'Server-Sent Events',
         'Service Workers'     => 'Service Workers',
-        'Stream API'          => 'Stream',
+        'Stream API'          => 'Media Streams',
+        'Streams'             => 'Media Streams',
         'Touch Events'        => 'Touch Events',
         'Web Animations'      => 'Animation',
         'Web App Manifest'    => 'Web App Manifest',
@@ -71,6 +73,7 @@ module Docs
         'location'            => 'Location',
         'navigator'           => 'Navigator',
         'MediaQuery'          => 'MediaQuery',
+        'MediaTrack'          => 'Media Streams',
         'Node'                => 'Node',
         'Notification'        => 'Notification',
         'OffscreenCanvas'     => 'Canvas',
@@ -108,7 +111,8 @@ module Docs
         'ImageData'     => 'Canvas',
         'IndexedDB'     => 'IndexedDB',
         'Media Source'  => 'Media',
-        'MediaStream'   => 'Stream',
+        'MediaStream'   => 'Media Streams',
+        'Media Streams' => 'Media Streams',
         'NodeList'      => 'Node',
         'Path2D'        => 'Canvas',
         'Pointer'       => 'Pointer Events',

+ 1 - 4
lib/docs/filters/dom_events/clean_html.rb

@@ -7,11 +7,8 @@ module Docs
       end
 
       def root
-        # Remove parapraph mentioning non-standard events
-        at_css('#Standard_events').previous_element.remove
-
         # Remove everything after "Standard events"
-        css('.standard-table ~ *').remove
+        css('#Non-standard_events', '#Non-standard_events ~ *').remove
 
         # Remove events we don't want
         css('tr').each do |tr|

+ 12 - 6
lib/docs/filters/dom_events/entries.rb

@@ -4,6 +4,7 @@ module Docs
       TYPE_BY_INFO = {
         'applicationCache' => 'Application Cache',
         'Battery'          => 'Battery',
+        'Call'             => 'Telephony',
         'Clipboard'        => 'Clipboard',
         'CSS'              => 'CSS',
         'Drag'             => 'Drag & Drop',
@@ -27,6 +28,7 @@ module Docs
         'Push'             => 'Push',
         'Progress'         => 'Progress',
         'Proximity'        => 'Device',
+        'Selection'        => 'Selection',
         'Server Sent'      => 'Server Sent Events',
         'Speech'           => 'Web Speech',
         'Storage'          => 'Web Storage',
@@ -37,6 +39,7 @@ module Docs
         'Web App Manifest' => 'Web App Manifest',
         'Web Audio'        => 'Web Audio',
         'Web Messaging'    => 'Web Messaging',
+        'WebGL'            => 'WebGL',
         'WebRTC'           => 'WebRTC',
         'WebVR'            => 'WebVR',
         'Wheel'            => 'Mouse',
@@ -47,7 +50,7 @@ module Docs
       LOAD_SLUGS = %w(abort beforeunload DOMContentLoaded error load
         readystatechange unload)
 
-      APPEND_TYPE = %w(Application\ Cache IndexedDB Progress
+      APPEND_TYPE = %w(Application\ Cache IndexedDB Progress Telephony
         Server\ Sent\ Events WebSocket Web\ Messaging Web\ Workers)
 
       def get_name
@@ -62,10 +65,9 @@ module Docs
         elsif LOAD_SLUGS.include?(slug)
           'Load'
         else
-          if info = at_css('.eventinfo, .properties').try(:content)
-            TYPE_BY_INFO.each_pair do |key, value|
-              return value if info.include?(key)
-            end
+          info = css('.eventinfo, .properties, .standard-table').map(&:content).join
+          TYPE_BY_INFO.each_pair do |key, value|
+            return value if info.include?(key)
           end
 
           'Miscellaneous'
@@ -73,7 +75,11 @@ module Docs
       end
 
       def include_default_entry?
-        !doc.content.include?('Firefox OS specific')
+        content = doc.content
+        !content.include?('Firefox OS specific') &&
+        !content.include?('Addons specific') &&
+        !content.include?('Mozilla specific') &&
+        content !~ /Specification\s+XUL/
       end
     end
   end

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

@@ -21,7 +21,7 @@ module Docs
           node.name = 'th'
         end
 
-        css('nobr', 'span[style*="font"]', 'pre code').each do |node|
+        css('nobr', 'span[style*="font"]', 'pre code', 'h2 strong').each do |node|
           node.before(node.children).remove
         end
 

+ 3 - 2
lib/docs/scrapers/mdn/css.rb

@@ -10,7 +10,7 @@ module Docs
 
     options[:skip] = %w(/CSS3 /Media/Visual /paged_media)
     options[:skip] += %w(/mq-boolean /single-transition-timing-function) # bug
-    options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/]
+    options[:skip_patterns] = [/Extensions/, /Tools/, /@media\/-webkit/, /webkit-mask/, /-moz-system-metric/]
 
     options[:replace_paths] = {
       '/%3Cbasic-shape%3E' => '/basic-shape',
@@ -18,7 +18,8 @@ module Docs
       '/range' => '/@counter-style/range',
       '/symbols' => '/@counter-style/symbols',
       '/system' => '/@counter-style/system',
-      '/var' => '/var()'
+      '/var' => '/var()',
+      '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes'
     }
 
     options[:fix_urls] = ->(url) do