History

Update MDN docs

Closes #476.

Thibaut Courouble committed 10 years ago

Commit f7ec3361 parent c7af9e68 files · +40 −17Browse files

Unified · Split

8 files
  1. assets/stylesheets/pages/_mdn.scss +4 −0
  2. lib/docs/filters/css/clean_html.rb +4 −0
  3. lib/docs/filters/css/entries.rb +8 −1
  4. lib/docs/filters/dom/entries.rb +7 −3
  5. lib/docs/filters/dom_events/clean_html.rb +1 −4
  6. lib/docs/filters/dom_events/entries.rb +12 −6
  7. lib/docs/filters/mdn/clean_html.rb +1 −1
  8. lib/docs/scrapers/mdn/css.rb +3 −2
assets/stylesheets/pages/_mdn.scss+4−0
@@ -22,9 +22,11 @@ · 21 unmodified lines
2222
2323 > h2 { @extend %block-heading; }
2424 > h3 { @extend %block-label, %label-blue; }
25+ > h4 { font-size: 1em; }
2526
2627 > .note,
2728 .notice,
29+ .warning,
2830 .overheadIndicator,
2931 .syntaxbox, // CSS, JavaScript
3032 .twopartsyntaxbox, // CSS
@@ -33,6 +35,8 @@ · 2 unmodified lines
3335 @extend %note;
3436 }
3537
38+ .warning { @extend %note-red; }
39+
3640 > .note {
3741 em {
3842 font-style: normal;
lib/docs/filters/css/clean_html.rb+4−0
@@ -12,6 +12,10 @@ module Docs · 11 unmodified lines
1212 end
1313
1414 def other
15+ css('.syntaxbox > .syntaxbox').each do |node|
16+ node.parent.before(node.parent.children).remove
17+ end
18+
1519 # Remove "|" and "||" links in syntax box (e.g. animation, all, etc.)
1620 css('.syntaxbox', '.twopartsyntaxbox').css('a').each do |node|
1721 if node.content == '|' || node.content == '||'
lib/docs/filters/css/entries.rb+8−1
@@ -42,7 +42,9 @@ module Docs · 41 unmodified lines
4242 end
4343
4444 def get_type
45− if type = TYPE_BY_PATH[slug.split('/').first]
45+ if slug.include?('-webkit') || slug.include?('-moz')
46+ 'Extensions'
47+ elsif type = TYPE_BY_PATH[slug.split('/').first]
4648 type
4749 elsif type = get_spec
4850 type.remove! 'CSS '
@@ -123,6 +125,11 @@ module Docs · 74 unmodified lines
123125 def additional_entries
124126 ADDITIONAL_ENTRIES[slug] || []
125127 end
128+
129+ def include_default_entry?
130+ return true unless warning = at_css('.warning').try(:content)
131+ !warning.include?('CSS Flexible Box') && !warning.include?('replaced in newer drafts')
132+ end
126133 end
127134 end
128135 end
lib/docs/filters/dom/entries.rb+7−3
@@ -23,9 +23,10 @@ module Docs · 22 unmodified lines
2323 'Intersection' => 'Intersection Observer',
2424 'Media Capture' => 'Media',
2525 'Media Source' => 'Media',
26− 'MediaStream' => 'Stream',
26+ 'MediaStream' => 'Media Streams',
2727 'Navigation Timing' => 'Web Performance',
2828 'Network Information' => 'Network Information',
29+ 'Payment Request' => 'Payment Request',
2930 'Performance Timeline' => 'Web Performance',
3031 'Pointer Events' => 'Pointer Events',
3132 'Push API' => 'Push',
@@ -33,7 +34,8 @@ module Docs · 1 unmodified line
3334 'Shadow DOM' => 'Shadow DOM',
3435 'Server-Sent Events' => 'Server-Sent Events',
3536 'Service Workers' => 'Service Workers',
36− 'Stream API' => 'Stream',
37+ 'Stream API' => 'Media Streams',
38+ 'Streams' => 'Media Streams',
3739 'Touch Events' => 'Touch Events',
3840 'Web Animations' => 'Animation',
3941 'Web App Manifest' => 'Web App Manifest',
@@ -71,6 +73,7 @@ module Docs · 31 unmodified lines
7173 'location' => 'Location',
7274 'navigator' => 'Navigator',
7375 'MediaQuery' => 'MediaQuery',
76+ 'MediaTrack' => 'Media Streams',
7477 'Node' => 'Node',
7578 'Notification' => 'Notification',
7679 'OffscreenCanvas' => 'Canvas',
@@ -108,7 +111,8 @@ module Docs · 31 unmodified lines
108111 'ImageData' => 'Canvas',
109112 'IndexedDB' => 'IndexedDB',
110113 'Media Source' => 'Media',
111− 'MediaStream' => 'Stream',
114+ 'MediaStream' => 'Media Streams',
115+ 'Media Streams' => 'Media Streams',
112116 'NodeList' => 'Node',
113117 'Path2D' => 'Canvas',
114118 'Pointer' => 'Pointer Events',
lib/docs/filters/dom_events/clean_html.rb+1−4
@@ -7,11 +7,8 @@ module Docs · 6 unmodified lines
77 end
88
99 def root
10− # Remove parapraph mentioning non-standard events
11− at_css('#Standard_events').previous_element.remove
12−
1310 # Remove everything after "Standard events"
14− css('.standard-table ~ *').remove
11+ css('#Non-standard_events', '#Non-standard_events ~ *').remove
1512
1613 # Remove events we don't want
1714 css('tr').each do |tr|
lib/docs/filters/dom_events/entries.rb+12−6
@@ -4,6 +4,7 @@ module Docs · 3 unmodified lines
44 TYPE_BY_INFO = {
55 'applicationCache' => 'Application Cache',
66 'Battery' => 'Battery',
7+ 'Call' => 'Telephony',
78 'Clipboard' => 'Clipboard',
89 'CSS' => 'CSS',
910 'Drag' => 'Drag & Drop',
@@ -27,6 +28,7 @@ module Docs · 17 unmodified lines
2728 'Push' => 'Push',
2829 'Progress' => 'Progress',
2930 'Proximity' => 'Device',
31+ 'Selection' => 'Selection',
3032 'Server Sent' => 'Server Sent Events',
3133 'Speech' => 'Web Speech',
3234 'Storage' => 'Web Storage',
@@ -37,6 +39,7 @@ module Docs · 4 unmodified lines
3739 'Web App Manifest' => 'Web App Manifest',
3840 'Web Audio' => 'Web Audio',
3941 'Web Messaging' => 'Web Messaging',
42+ 'WebGL' => 'WebGL',
4043 'WebRTC' => 'WebRTC',
4144 'WebVR' => 'WebVR',
4245 'Wheel' => 'Mouse',
@@ -47,7 +50,7 @@ module Docs · 4 unmodified lines
4750 LOAD_SLUGS = %w(abort beforeunload DOMContentLoaded error load
4851 readystatechange unload)
4952
50− APPEND_TYPE = %w(Application\ Cache IndexedDB Progress
53+ APPEND_TYPE = %w(Application\ Cache IndexedDB Progress Telephony
5154 Server\ Sent\ Events WebSocket Web\ Messaging Web\ Workers)
5255
5356 def get_name
@@ -62,10 +65,9 @@ module Docs · 8 unmodified lines
6265 elsif LOAD_SLUGS.include?(slug)
6366 'Load'
6467 else
65− if info = at_css('.eventinfo, .properties').try(:content)
66− TYPE_BY_INFO.each_pair do |key, value|
67− return value if info.include?(key)
68− end
68+ info = css('.eventinfo, .properties, .standard-table').map(&:content).join
69+ TYPE_BY_INFO.each_pair do |key, value|
70+ return value if info.include?(key)
6971 end
7072
7173 'Miscellaneous'
@@ -73,7 +75,11 @@ module Docs · 1 unmodified line
7375 end
7476
7577 def include_default_entry?
76− !doc.content.include?('Firefox OS specific')
78+ content = doc.content
79+ !content.include?('Firefox OS specific') &&
80+ !content.include?('Addons specific') &&
81+ !content.include?('Mozilla specific') &&
82+ content !~ /Specification\s+XUL/
7783 end
7884 end
7985 end
lib/docs/filters/mdn/clean_html.rb+1−1
@@ -21,7 +21,7 @@ module Docs · 20 unmodified lines
2121 node.name = 'th'
2222 end
2323
24− css('nobr', 'span[style*="font"]', 'pre code').each do |node|
24+ css('nobr', 'span[style*="font"]', 'pre code', 'h2 strong').each do |node|
2525 node.before(node.children).remove
2626 end
2727
lib/docs/scrapers/mdn/css.rb+3−2
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
1010
1111 options[:skip] = %w(/CSS3 /Media/Visual /paged_media)
1212 options[:skip] += %w(/mq-boolean /single-transition-timing-function) # bug
13− options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/]
13+ options[:skip_patterns] = [/Extensions/, /Tools/, /@media\/-webkit/, /webkit-mask/, /-moz-system-metric/]
1414
1515 options[:replace_paths] = {
1616 '/%3Cbasic-shape%3E' => '/basic-shape',
@@ -18,7 +18,8 @@ module Docs · 1 unmodified line
1818 '/range' => '/@counter-style/range',
1919 '/symbols' => '/@counter-style/symbols',
2020 '/system' => '/@counter-style/system',
21− '/var' => '/var()'
21+ '/var' => '/var()',
22+ '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes'
2223 }
2324
2425 options[:fix_urls] = ->(url) do