Jelajahi Sumber

Update MDN documentations

Thibaut Courouble 8 tahun lalu
induk
melakukan
66e3848b5b

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

@@ -24,6 +24,8 @@
   > h3 { @extend %block-label, %label-blue; }
   > h4 { font-size: 1em; }
 
+  p > code { @extend %label; }
+
   > .note,
   .notice,
   .warning,

+ 2 - 0
lib/app.rb

@@ -293,6 +293,8 @@ class App < Sinatra::Application
     '/css-data-types/'    => '/css-values-units/',
     '/css-at-rules/'      => '/?q=css%20%40',
     '/html/article'       => '/html/element/article',
+    'html-html5/'         => 'html-elements/',
+    'html-standard/'      => 'html-elements/',
     '/http-status-codes/' => '/http-status/'
   }.each do |path, url|
     class_eval <<-CODE, __FILE__, __LINE__ + 1

+ 5 - 4
lib/docs/filters/css/entries.rb

@@ -6,17 +6,17 @@ module Docs
         'CSS_Background_and_Borders' => 'Backgrounds & Borders',
         'CSS_Columns' => 'Multi-column Layout',
         'CSS_Flexible_Box_Layout' => 'Flexible Box Layout',
+        'CSS_Grid_Layout' => 'Grid Layout',
         'CSS_Images' => 'Image Values',
         'CSS_Lists_and_Counters' => 'Lists & Counters',
         'CSS_Transforms' => 'Transforms',
         'Media_Queries' => 'Media Queries',
-        '@media' => 'Media Queries',
         'transform-function' => 'Transforms',
+        '@media' => 'Media Queries',
         'text-size-adjust' => 'Miscellaneous',
         'resolved_value' => 'Miscellaneous',
         'touch-action' => 'Miscellaneous',
-        'will-change' => 'Miscellaneous',
-        'align-self' => 'Flexible Box Layout'
+        'will-change' => 'Miscellaneous'
       }
 
       DATA_TYPE_SLUGS = %w(angle basic-shape color_value counter frequency
@@ -53,6 +53,7 @@ module Docs
           type.remove! %r{\(.*\)}
           type.sub! 'and', '&'
           type.strip!
+          type = 'Grid Layout' if type.include?('Grid Layout')
           type = 'Scroll Snap' if type.include?('Scroll Snap')
           type = 'Compositing & Blending' if type.include?('Compositing')
           type = 'Animations & Transitions' if type.in?(%w(Animations Transitions))
@@ -118,7 +119,7 @@ module Docs
           %w(step-end step-end) ],
         'color_value' => [
           %w(transparent transparent_keyword),
-          %w(currentColor currentColor_keyword),
+          %w(currentColor currentcolor_keyword),
           %w(rgb() rgb),
           %w(hsl() hsl),
           %w(rgba() rgba),

+ 6 - 0
lib/docs/filters/dom/clean_html.rb

@@ -10,9 +10,15 @@ module Docs
       end
 
       def other
+        css('h1 + br').remove
+
         # Bug fix: HTMLElement.offsetWidth
         css('#offsetContainer .comment').remove
 
+        css('section', 'font').each do |node|
+          node.before(node.children).remove
+        end
+
         # Bug fix: CompositionEvent, DataTransfer, etc.
         if (div = at_css('div[style]')) && div['style'].include?('border: solid #ddd 2px')
           div.remove

+ 6 - 1
lib/docs/filters/dom/entries.rb

@@ -24,6 +24,7 @@ module Docs
         'High Resolution Time' => 'Web Performance',
         'Intersection'        => 'Intersection Observer',
         'Media Capture'       => 'Media',
+        'Media Session'       => 'Media Session',
         'Media Source'        => 'Media',
         'MediaStream'         => 'Media Streams',
         'Navigation Timing'   => 'Web Performance',
@@ -69,6 +70,7 @@ module Docs
         'element'             => 'Element',
         'event'               => 'Event',
         'Event'               => 'Event',
+        'EventSource'         => 'Server-Sent Events',
         'Fetch'               => 'Fetch',
         'File'                => 'File',
         'GlobalEventHandlers' => 'GlobalEventHandlers',
@@ -78,7 +80,8 @@ module Docs
         'IDB'                 => 'IndexedDB',
         'location'            => 'Location',
         'navigator'           => 'Navigator',
-        'MediaQuery'          => 'MediaQuery',
+        'MediaMetadata'       => 'Media Session',
+        'MediaSession'        => 'Media Session',
         'MediaTrack'          => 'Media Streams',
         'Node'                => 'Node',
         'Notification'        => 'Notification',
@@ -92,10 +95,12 @@ module Docs
         'RTC'                 => 'WebRTC',
         'screen'              => 'Screen',
         'Selection'           => 'Selection',
+        'Shadow'              => 'Shadow DOM',
         'Storage'             => 'Web Storage',
         'StyleSheet'          => 'CSS',
         'Stylesheet'          => 'CSS',
         'SVG'                 => 'SVG',
+        'TimeRanges'          => 'Media',
         'timing'              => 'Web Performance',
         'Timing'              => 'Web Performance',
         'Touch'               => 'Touch Events',

+ 2 - 10
lib/docs/filters/html/clean_html.rb

@@ -2,16 +2,8 @@ module Docs
   class Html
     class CleanHtmlFilter < Filter
       def call
-        css('span > .icon-thumbs-down-alt:first-child:last-child').each do |node|
-          node.parent.replace('deprecated')
-        end
-
-        css('span > .icon-trash:first-child:last-child').each do |node|
-          node.parent.replace('deleted')
-        end
-
-        css('span > .icon-warning-sign:first-child:last-child').each do |node|
-          node.parent.replace('non standard')
+        css('section', 'div.section', 'div.row').each do |node|
+          node.before(node.children).remove
         end
 
         doc

+ 6 - 18
lib/docs/filters/html/entries.rb

@@ -1,7 +1,6 @@
 module Docs
   class Html
     class EntriesFilter < Docs::EntriesFilter
-      HTML5 = %w(content element video)
       OBSOLETE = %w(frame frameset hgroup noframes)
       ADDITIONAL_ENTRIES = { 'Element/Heading_Elements' => (1..6).map { |n| ["h#{n}"] } }
 
@@ -14,23 +13,16 @@ module Docs
       end
 
       def get_type
-        slug = self.slug.remove('Element/')
+        return 'Miscellaneous' if slug.include?('CORS') || slug.include?('Using')
 
-        if self.slug.start_with?('Global_attr')
+        if slug.start_with?('Global_attr')
           'Attributes'
-        elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug)
+        elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug.remove('Element/'))
           'Obsolete'
+        elsif slug.start_with?('Element/')
+          'Elements'
         else
-          spec = css('.standard-table').last.try(:content)
-          if (spec && html5_spec?(spec)) || HTML5.include?(slug)
-            'HTML5'
-          else
-            if self.slug.start_with?('Element/')
-              'Standard'
-            else
-              'Miscellaneous'
-            end
-          end
+          'Miscellaneous'
         end
       end
 
@@ -60,10 +52,6 @@ module Docs
           []
         end
       end
-
-      def html5_spec?(spec)
-        (spec =~ /HTML\s?5/ || spec.include?('WHATWG HTML Living Standard')) && spec !~ /HTML\s?4/
-      end
     end
   end
 end

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

@@ -19,7 +19,9 @@ module Docs
       '/symbols' => '/@counter-style/symbols',
       '/system' => '/@counter-style/system',
       '/var' => '/var()',
-      '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes'
+      '/element' => '/element()',
+      '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes',
+      '/currentColor' => '/color_value'
     }
 
     options[:fix_urls] = ->(url) do

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

@@ -8,6 +8,8 @@ module Docs
 
     html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title'
 
+    options[:root_title] = 'XSLT'
+
     options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]
 
     options[:fix_urls] = ->(url) do