History

Update MDN documentations

Thibaut Courouble committed 9 years ago

Commit 66e38481 parent 3ac71429 files · +34 −34Browse files

Unified · Split

9 files
  1. assets/stylesheets/pages/_mdn.scss +2 −0
  2. lib/app.rb +2 −0
  3. lib/docs/filters/css/entries.rb +5 −4
  4. lib/docs/filters/dom/clean_html.rb +6 −0
  5. lib/docs/filters/dom/entries.rb +6 −1
  6. lib/docs/filters/html/clean_html.rb +2 −10
  7. lib/docs/filters/html/entries.rb +6 −18
  8. lib/docs/scrapers/mdn/css.rb +3 −1
  9. lib/docs/scrapers/mdn/xslt_xpath.rb +2 −0
assets/stylesheets/pages/_mdn.scss+2−0
@@ -24,6 +24,8 @@ · 23 unmodified lines
2424 > h3 { @extend %block-label, %label-blue; }
2525 > h4 { font-size: 1em; }
2626
27+ p > code { @extend %label; }
28+
2729 > .note,
2830 .notice,
2931 .warning,
lib/app.rb+2−0
@@ -293,6 +293,8 @@ class App < Sinatra::Application · 292 unmodified lines
293293 '/css-data-types/' => '/css-values-units/',
294294 '/css-at-rules/' => '/?q=css%20%40',
295295 '/html/article' => '/html/element/article',
296+ 'html-html5/' => 'html-elements/',
297+ 'html-standard/' => 'html-elements/',
296298 '/http-status-codes/' => '/http-status/'
297299 }.each do |path, url|
298300 class_eval <<-CODE, __FILE__, __LINE__ + 1
lib/docs/filters/css/entries.rb+5−4
@@ -6,17 +6,17 @@ module Docs · 5 unmodified lines
66 'CSS_Background_and_Borders' => 'Backgrounds & Borders',
77 'CSS_Columns' => 'Multi-column Layout',
88 'CSS_Flexible_Box_Layout' => 'Flexible Box Layout',
9+ 'CSS_Grid_Layout' => 'Grid Layout',
910 'CSS_Images' => 'Image Values',
1011 'CSS_Lists_and_Counters' => 'Lists & Counters',
1112 'CSS_Transforms' => 'Transforms',
1213 'Media_Queries' => 'Media Queries',
13− '@media' => 'Media Queries',
1414 'transform-function' => 'Transforms',
15+ '@media' => 'Media Queries',
1516 'text-size-adjust' => 'Miscellaneous',
1617 'resolved_value' => 'Miscellaneous',
1718 'touch-action' => 'Miscellaneous',
18− 'will-change' => 'Miscellaneous',
19− 'align-self' => 'Flexible Box Layout'
19+ 'will-change' => 'Miscellaneous'
2020 }
2121
2222 DATA_TYPE_SLUGS = %w(angle basic-shape color_value counter frequency
@@ -53,6 +53,7 @@ module Docs · 30 unmodified lines
5353 type.remove! %r{\(.*\)}
5454 type.sub! 'and', '&'
5555 type.strip!
56+ type = 'Grid Layout' if type.include?('Grid Layout')
5657 type = 'Scroll Snap' if type.include?('Scroll Snap')
5758 type = 'Compositing & Blending' if type.include?('Compositing')
5859 type = 'Animations & Transitions' if type.in?(%w(Animations Transitions))
@@ -118,7 +119,7 @@ module Docs · 59 unmodified lines
118119 %w(step-end step-end) ],
119120 'color_value' => [
120121 %w(transparent transparent_keyword),
121− %w(currentColor currentColor_keyword),
122+ %w(currentColor currentcolor_keyword),
122123 %w(rgb() rgb),
123124 %w(hsl() hsl),
124125 %w(rgba() rgba),
lib/docs/filters/dom/clean_html.rb+6−0
@@ -10,9 +10,15 @@ module Docs · 9 unmodified lines
1010 end
1111
1212 def other
13+ css('h1 + br').remove
14+
1315 # Bug fix: HTMLElement.offsetWidth
1416 css('#offsetContainer .comment').remove
1517
18+ css('section', 'font').each do |node|
19+ node.before(node.children).remove
20+ end
21+
1622 # Bug fix: CompositionEvent, DataTransfer, etc.
1723 if (div = at_css('div[style]')) && div['style'].include?('border: solid #ddd 2px')
1824 div.remove
lib/docs/filters/dom/entries.rb+6−1
@@ -24,6 +24,7 @@ module Docs · 23 unmodified lines
2424 'High Resolution Time' => 'Web Performance',
2525 'Intersection' => 'Intersection Observer',
2626 'Media Capture' => 'Media',
27+ 'Media Session' => 'Media Session',
2728 'Media Source' => 'Media',
2829 'MediaStream' => 'Media Streams',
2930 'Navigation Timing' => 'Web Performance',
@@ -69,6 +70,7 @@ module Docs · 39 unmodified lines
6970 'element' => 'Element',
7071 'event' => 'Event',
7172 'Event' => 'Event',
73+ 'EventSource' => 'Server-Sent Events',
7274 'Fetch' => 'Fetch',
7375 'File' => 'File',
7476 'GlobalEventHandlers' => 'GlobalEventHandlers',
@@ -78,7 +80,8 @@ module Docs · 3 unmodified lines
7880 'IDB' => 'IndexedDB',
7981 'location' => 'Location',
8082 'navigator' => 'Navigator',
81− 'MediaQuery' => 'MediaQuery',
83+ 'MediaMetadata' => 'Media Session',
84+ 'MediaSession' => 'Media Session',
8285 'MediaTrack' => 'Media Streams',
8386 'Node' => 'Node',
8487 'Notification' => 'Notification',
@@ -92,10 +95,12 @@ module Docs · 7 unmodified lines
9295 'RTC' => 'WebRTC',
9396 'screen' => 'Screen',
9497 'Selection' => 'Selection',
98+ 'Shadow' => 'Shadow DOM',
9599 'Storage' => 'Web Storage',
96100 'StyleSheet' => 'CSS',
97101 'Stylesheet' => 'CSS',
98102 'SVG' => 'SVG',
103+ 'TimeRanges' => 'Media',
99104 'timing' => 'Web Performance',
100105 'Timing' => 'Web Performance',
101106 'Touch' => 'Touch Events',
lib/docs/filters/html/clean_html.rb+2−10
@@ -2,16 +2,8 @@ module Docs · 1 unmodified line
22 class Html
33 class CleanHtmlFilter < Filter
44 def call
5− css('span > .icon-thumbs-down-alt:first-child:last-child').each do |node|
6− node.parent.replace('deprecated')
7− end
8−
9− css('span > .icon-trash:first-child:last-child').each do |node|
10− node.parent.replace('deleted')
11− end
12−
13− css('span > .icon-warning-sign:first-child:last-child').each do |node|
14− node.parent.replace('non standard')
5+ css('section', 'div.section', 'div.row').each do |node|
6+ node.before(node.children).remove
157 end
168
179 doc
lib/docs/filters/html/entries.rb+6−18
@@ -1,7 +1,6 @@
11 module Docs
22 class Html
33 class EntriesFilter < Docs::EntriesFilter
4− HTML5 = %w(content element video)
54 OBSOLETE = %w(frame frameset hgroup noframes)
65 ADDITIONAL_ENTRIES = { 'Element/Heading_Elements' => (1..6).map { |n| ["h#{n}"] } }
76
@@ -14,23 +13,16 @@ module Docs · 6 unmodified lines
1413 end
1514
1615 def get_type
17− slug = self.slug.remove('Element/')
16+ return 'Miscellaneous' if slug.include?('CORS') || slug.include?('Using')
1817
19− if self.slug.start_with?('Global_attr')
18+ if slug.start_with?('Global_attr')
2019 'Attributes'
21− elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug)
20+ elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug.remove('Element/'))
2221 'Obsolete'
22+ elsif slug.start_with?('Element/')
23+ 'Elements'
2324 else
24− spec = css('.standard-table').last.try(:content)
25− if (spec && html5_spec?(spec)) || HTML5.include?(slug)
26− 'HTML5'
27− else
28− if self.slug.start_with?('Element/')
29− 'Standard'
30− else
31− 'Miscellaneous'
32− end
33− end
25+ 'Miscellaneous'
3426 end
3527 end
3628
@@ -60,10 +52,6 @@ module Docs · 23 unmodified lines
6052 []
6153 end
6254 end
63−
64− def html5_spec?(spec)
65− (spec =~ /HTML\s?5/ || spec.include?('WHATWG HTML Living Standard')) && spec !~ /HTML\s?4/
66− end
6755 end
6856 end
6957 end
lib/docs/scrapers/mdn/css.rb+3−1
@@ -19,7 +19,9 @@ module Docs · 18 unmodified lines
1919 '/symbols' => '/@counter-style/symbols',
2020 '/system' => '/@counter-style/system',
2121 '/var' => '/var()',
22− '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes'
22+ '/element' => '/element()',
23+ '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes',
24+ '/currentColor' => '/color_value'
2325 }
2426
2527 options[:fix_urls] = ->(url) do
lib/docs/scrapers/mdn/xslt_xpath.rb+2−0
@@ -8,6 +8,8 @@ module Docs · 7 unmodified lines
88
99 html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title'
1010
11+ options[:root_title] = 'XSLT'
12+
1113 options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]
1214
1315 options[:fix_urls] = ->(url) do