From 66e3848b5b0c29a3b571f86e83c704cd4299edd5 Mon Sep 17 00:00:00 2001 From: Thibaut Courouble Date: Sat, 22 Apr 2017 11:48:34 -0400 Subject: [PATCH] Update MDN documentations --- assets/stylesheets/pages/_mdn.scss | 2 ++ lib/app.rb | 2 ++ lib/docs/filters/css/entries.rb | 9 +++++---- lib/docs/filters/dom/clean_html.rb | 6 ++++++ lib/docs/filters/dom/entries.rb | 7 ++++++- lib/docs/filters/html/clean_html.rb | 12 ++---------- lib/docs/filters/html/entries.rb | 24 ++++++------------------ lib/docs/scrapers/mdn/css.rb | 4 +++- lib/docs/scrapers/mdn/xslt_xpath.rb | 2 ++ 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/assets/stylesheets/pages/_mdn.scss b/assets/stylesheets/pages/_mdn.scss index b59faece..778b4cf5 100644 --- a/assets/stylesheets/pages/_mdn.scss +++ b/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, diff --git a/lib/app.rb b/lib/app.rb index 2a718305..08c41ff8 100644 --- a/lib/app.rb +++ b/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 diff --git a/lib/docs/filters/css/entries.rb b/lib/docs/filters/css/entries.rb index e46415d1..ffd8fd0a 100644 --- a/lib/docs/filters/css/entries.rb +++ b/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), diff --git a/lib/docs/filters/dom/clean_html.rb b/lib/docs/filters/dom/clean_html.rb index 1e7a45b2..12610c1f 100644 --- a/lib/docs/filters/dom/clean_html.rb +++ b/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 diff --git a/lib/docs/filters/dom/entries.rb b/lib/docs/filters/dom/entries.rb index 0a1df952..e418bbd5 100644 --- a/lib/docs/filters/dom/entries.rb +++ b/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', diff --git a/lib/docs/filters/html/clean_html.rb b/lib/docs/filters/html/clean_html.rb index 92c6704a..0d6b43b4 100644 --- a/lib/docs/filters/html/clean_html.rb +++ b/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 diff --git a/lib/docs/filters/html/entries.rb b/lib/docs/filters/html/entries.rb index aeefac29..11a0e03b 100644 --- a/lib/docs/filters/html/entries.rb +++ b/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 diff --git a/lib/docs/scrapers/mdn/css.rb b/lib/docs/scrapers/mdn/css.rb index 322d8b4e..56daa563 100644 --- a/lib/docs/scrapers/mdn/css.rb +++ b/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 diff --git a/lib/docs/scrapers/mdn/xslt_xpath.rb b/lib/docs/scrapers/mdn/xslt_xpath.rb index 8d781e65..5d812dd4 100644 --- a/lib/docs/scrapers/mdn/xslt_xpath.rb +++ b/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