1
0
Thibaut Courouble 9 жил өмнө
parent
commit
787dc64809

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

@@ -21,6 +21,7 @@
   }
 
   > h2 { @extend %block-heading; }
+  > h3 { @extend %block-label, %label-blue; }
 
   > .note,
   .notice,
@@ -87,6 +88,7 @@
   dl > dt > code {    // CSS property value, Javascript function argument
     font-family: inherit;
     font-weight: bold;
+    font-size: inherit;
   }
 
   .eventinfo { // DOM event

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

@@ -18,6 +18,10 @@ module Docs
             node.replace node.content
           end
         end
+
+        css('img[style*="float"]').each do |node|
+          node['style'] = node['style'] + ';float: none; display: block;'
+        end
       end
     end
   end

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

@@ -11,7 +11,12 @@ module Docs
         'CSS_Transforms' => 'Transforms',
         'Media_Queries' => 'Media Queries',
         '@media' => 'Media Queries',
-        'transform-function' => 'Transforms'
+        'transform-function' => 'Transforms',
+        'text-size-adjust' => 'Miscellaneous',
+        'resolved_value' => 'Miscellaneous',
+        'touch-action' => 'Miscellaneous',
+        'will-change' => 'Miscellaneous',
+        'align-self' => 'Flexible Box Layout'
       }
 
       DATA_TYPE_SLUGS = %w(angle basic-shape color_value counter frequency
@@ -37,7 +42,9 @@ module Docs
       end
 
       def get_type
-        if type = get_spec
+        if type = TYPE_BY_PATH[slug.split('/').first]
+          type
+        elsif type = get_spec
           type.remove! 'CSS '
           type.remove! ' Module'
           type.remove! %r{ Level \d\z}
@@ -49,8 +56,6 @@ module Docs
           type = 'Variables' if type == 'Custom Properties for Cascading Variables'
           type.prepend 'Miscellaneous ' if type =~ /\ALevel \d\z/
           type
-        elsif type = TYPE_BY_PATH[slug.split('/').first]
-          type
         elsif name.start_with?('::')
           'Pseudo-Elements'
         elsif name.start_with?(':')
@@ -110,10 +115,10 @@ module Docs
         'color_value' => [
           %w(transparent transparent_keyword),
           %w(currentColor currentColor_keyword),
-          %w(rgb() rgb()),
-          %w(hsl() hsl()),
-          %w(rgba() rgba()),
-          %w(hsla() hsla()) ]}
+          %w(rgb() rgb),
+          %w(hsl() hsl),
+          %w(rgba() rgba),
+          %w(hsla() hsla) ]}
 
       def additional_entries
         ADDITIONAL_ENTRIES[slug] || []

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

@@ -20,9 +20,10 @@ module Docs
         'Geolocation'         => 'Geolocation',
         'Geometry'            => 'Geometry',
         'High Resolution Time' => 'Web Performance',
+        'Intersection'        => 'Intersection Observer',
         'Media Capture'       => 'Media',
         'Media Source'        => 'Media',
-        'MediaStream'         => 'Media',
+        'MediaStream'         => 'Stream',
         'Navigation Timing'   => 'Web Performance',
         'Network Information' => 'Network Information',
         'Performance Timeline' => 'Web Performance',
@@ -32,8 +33,10 @@ module Docs
         'Shadow DOM'          => 'Shadow DOM',
         'Server-Sent Events'  => 'Server-Sent Events',
         'Service Workers'     => 'Service Workers',
+        'Stream API'          => 'Stream',
         'Touch Events'        => 'Touch Events',
         'Web Animations'      => 'Animation',
+        'Web App Manifest'    => 'Web App Manifest',
         'Web Audio'           => 'Web Audio',
         'Web Messaging'       => 'Web Messaging',
         'Web MIDI'            => 'Web MIDI',
@@ -70,8 +73,10 @@ module Docs
         'MediaQuery'          => 'MediaQuery',
         'Node'                => 'Node',
         'Notification'        => 'Notification',
+        'OffscreenCanvas'     => 'Canvas',
         'ParentNode'          => 'Node',
         'Performance'         => 'Web Performance',
+        'Presentation'        => 'Presentation',
         'Push'                => 'Push',
         'Range'               => 'Range',
         'Resource Timing'     => 'Web Performance',
@@ -87,11 +92,13 @@ module Docs
         'Touch'               => 'Touch Events',
         'TreeWalker'          => 'TreeWalker',
         'URL'                 => 'URL',
+        'VR'                  => 'WebVR',
         'window'              => 'Window',
         'Window'              => 'Window',
         'XMLHttpRequest'      => 'XMLHTTPRequest' }
 
       TYPE_BY_NAME_INCLUDES = {
+        'Animation'     => 'Animation',
         'ChildNode'     => 'Node',
         'Crypto'        => 'Web Cryptography',
         'Drag'          => 'Drag & Drop',
@@ -101,7 +108,7 @@ module Docs
         'ImageData'     => 'Canvas',
         'IndexedDB'     => 'IndexedDB',
         'Media Source'  => 'Media',
-        'MediaStream'   => 'Media',
+        'MediaStream'   => 'Stream',
         'NodeList'      => 'Node',
         'Path2D'        => 'Canvas',
         'Pointer'       => 'Pointer Events',

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

@@ -34,9 +34,11 @@ module Docs
         'Transition'       => 'CSS',
         'PageTransition'   => 'History',
         'WebSocket'        => 'WebSocket',
+        'Web App Manifest' => 'Web App Manifest',
         'Web Audio'        => 'Web Audio',
         'Web Messaging'    => 'Web Messaging',
         'WebRTC'           => 'WebRTC',
+        'WebVR'            => 'WebVR',
         'Wheel'            => 'Mouse',
         'Worker'           => 'Web Workers' }
 

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

@@ -21,11 +21,11 @@ module Docs
           node.name = 'th'
         end
 
-        css('nobr').each do |node|
+        css('nobr', 'span[style*="font"]', 'pre code').each do |node|
           node.before(node.children).remove
         end
 
-        css('h2[style]', 'pre[style]', 'th[style]', 'div[style*="line-height"]').remove_attr('style')
+        css('h2[style]', 'pre[style]', 'th[style]', 'div[style*="line-height"]', 'table[style]', 'pre p[style]').remove_attr('style')
 
         css('h2 > a[name]', 'h3 > a[name]').each do |node|
           node.parent['id'] = node['name']

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

@@ -13,7 +13,12 @@ module Docs
     options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/]
 
     options[:replace_paths] = {
-      '/%3Cbasic-shape%3E' => '/basic-shape'
+      '/%3Cbasic-shape%3E' => '/basic-shape',
+      '/fallback' => '/@counter-style/fallback',
+      '/range' => '/@counter-style/range',
+      '/symbols' => '/@counter-style/symbols',
+      '/system' => '/@counter-style/system',
+      '/var' => '/var()'
     }
 
     options[:fix_urls] = ->(url) do

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

@@ -31,5 +31,10 @@ module Docs
       '/Element/h5' => '/Element/Heading_Elements',
       '/Element/h6' => '/Element/Heading_Elements',
       '/Global_attributes/data-%2A' => '/Global_attributes/data-*' }
+
+    options[:fix_urls] = ->(url) do
+      url.sub! 'https://developer.mozilla.org/en-US/docs/HTML/', "#{Html.base_url}/" unless url.include?('Content_categories')
+      url
+    end
   end
 end