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
22 22
23 > h2 { @extend %block-heading; }23 > h2 { @extend %block-heading; }
24 > h3 { @extend %block-label, %label-blue; }24 > h3 { @extend %block-label, %label-blue; }
25 > h4 { font-size: 1em; }
25 26
26 > .note,27 > .note,
27 .notice,28 .notice,
29 .warning,
28 .overheadIndicator,30 .overheadIndicator,
29 .syntaxbox, // CSS, JavaScript31 .syntaxbox, // CSS, JavaScript
30 .twopartsyntaxbox, // CSS32 .twopartsyntaxbox, // CSS
@@ -33,6 +35,8 @@ · 2 unmodified lines
33 @extend %note;35 @extend %note;
34 }36 }
35 37
38 .warning { @extend %note-red; }
39
36 > .note {40 > .note {
37 em {41 em {
38 font-style: normal;42 font-style: normal;
lib/docs/filters/css/clean_html.rb+4−0
@@ -12,6 +12,10 @@ module Docs · 11 unmodified lines
12 end12 end
13 13
14 def other14 def other
15 css('.syntaxbox > .syntaxbox').each do |node|
16 node.parent.before(node.parent.children).remove
17 end
18
15 # Remove "|" and "||" links in syntax box (e.g. animation, all, etc.)19 # Remove "|" and "||" links in syntax box (e.g. animation, all, etc.)
16 css('.syntaxbox', '.twopartsyntaxbox').css('a').each do |node|20 css('.syntaxbox', '.twopartsyntaxbox').css('a').each do |node|
17 if node.content == '|' || node.content == '||'21 if node.content == '|' || node.content == '||'
lib/docs/filters/css/entries.rb+8−1
@@ -42,7 +42,9 @@ module Docs · 41 unmodified lines
42 end42 end
43 43
44 def get_type44 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]
46 type48 type
47 elsif type = get_spec49 elsif type = get_spec
48 type.remove! 'CSS '50 type.remove! 'CSS '
@@ -123,6 +125,11 @@ module Docs · 74 unmodified lines
123 def additional_entries125 def additional_entries
124 ADDITIONAL_ENTRIES[slug] || []126 ADDITIONAL_ENTRIES[slug] || []
125 end127 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
126 end133 end
127 end134 end
128end135end
lib/docs/filters/dom/entries.rb+7−3
@@ -23,9 +23,10 @@ module Docs · 22 unmodified lines
23 'Intersection' => 'Intersection Observer',23 'Intersection' => 'Intersection Observer',
24 'Media Capture' => 'Media',24 'Media Capture' => 'Media',
25 'Media Source' => 'Media',25 'Media Source' => 'Media',
26 'MediaStream' => 'Stream',26 'MediaStream' => 'Media Streams',
27 'Navigation Timing' => 'Web Performance',27 'Navigation Timing' => 'Web Performance',
28 'Network Information' => 'Network Information',28 'Network Information' => 'Network Information',
29 'Payment Request' => 'Payment Request',
29 'Performance Timeline' => 'Web Performance',30 'Performance Timeline' => 'Web Performance',
30 'Pointer Events' => 'Pointer Events',31 'Pointer Events' => 'Pointer Events',
31 'Push API' => 'Push',32 'Push API' => 'Push',
@@ -33,7 +34,8 @@ module Docs · 1 unmodified line
33 'Shadow DOM' => 'Shadow DOM',34 'Shadow DOM' => 'Shadow DOM',
34 'Server-Sent Events' => 'Server-Sent Events',35 'Server-Sent Events' => 'Server-Sent Events',
35 'Service Workers' => 'Service Workers',36 'Service Workers' => 'Service Workers',
36 'Stream API' => 'Stream',37 'Stream API' => 'Media Streams',
38 'Streams' => 'Media Streams',
37 'Touch Events' => 'Touch Events',39 'Touch Events' => 'Touch Events',
38 'Web Animations' => 'Animation',40 'Web Animations' => 'Animation',
39 'Web App Manifest' => 'Web App Manifest',41 'Web App Manifest' => 'Web App Manifest',
@@ -71,6 +73,7 @@ module Docs · 31 unmodified lines
71 'location' => 'Location',73 'location' => 'Location',
72 'navigator' => 'Navigator',74 'navigator' => 'Navigator',
73 'MediaQuery' => 'MediaQuery',75 'MediaQuery' => 'MediaQuery',
76 'MediaTrack' => 'Media Streams',
74 'Node' => 'Node',77 'Node' => 'Node',
75 'Notification' => 'Notification',78 'Notification' => 'Notification',
76 'OffscreenCanvas' => 'Canvas',79 'OffscreenCanvas' => 'Canvas',
@@ -108,7 +111,8 @@ module Docs · 31 unmodified lines
108 'ImageData' => 'Canvas',111 'ImageData' => 'Canvas',
109 'IndexedDB' => 'IndexedDB',112 'IndexedDB' => 'IndexedDB',
110 'Media Source' => 'Media',113 'Media Source' => 'Media',
111 'MediaStream' => 'Stream',114 'MediaStream' => 'Media Streams',
115 'Media Streams' => 'Media Streams',
112 'NodeList' => 'Node',116 'NodeList' => 'Node',
113 'Path2D' => 'Canvas',117 'Path2D' => 'Canvas',
114 'Pointer' => 'Pointer Events',118 'Pointer' => 'Pointer Events',
lib/docs/filters/dom_events/clean_html.rb+1−4
@@ -7,11 +7,8 @@ module Docs · 6 unmodified lines
7 end7 end
8 8
9 def root9 def root
10 # Remove parapraph mentioning non-standard events
11 at_css('#Standard_events').previous_element.remove
12
13 # Remove everything after "Standard events"10 # Remove everything after "Standard events"
14 css('.standard-table ~ *').remove11 css('#Non-standard_events', '#Non-standard_events ~ *').remove
15 12
16 # Remove events we don't want13 # Remove events we don't want
17 css('tr').each do |tr|14 css('tr').each do |tr|
lib/docs/filters/dom_events/entries.rb+12−6
@@ -4,6 +4,7 @@ module Docs · 3 unmodified lines
4 TYPE_BY_INFO = {4 TYPE_BY_INFO = {
5 'applicationCache' => 'Application Cache',5 'applicationCache' => 'Application Cache',
6 'Battery' => 'Battery',6 'Battery' => 'Battery',
7 'Call' => 'Telephony',
7 'Clipboard' => 'Clipboard',8 'Clipboard' => 'Clipboard',
8 'CSS' => 'CSS',9 'CSS' => 'CSS',
9 'Drag' => 'Drag & Drop',10 'Drag' => 'Drag & Drop',
@@ -27,6 +28,7 @@ module Docs · 17 unmodified lines
27 'Push' => 'Push',28 'Push' => 'Push',
28 'Progress' => 'Progress',29 'Progress' => 'Progress',
29 'Proximity' => 'Device',30 'Proximity' => 'Device',
31 'Selection' => 'Selection',
30 'Server Sent' => 'Server Sent Events',32 'Server Sent' => 'Server Sent Events',
31 'Speech' => 'Web Speech',33 'Speech' => 'Web Speech',
32 'Storage' => 'Web Storage',34 'Storage' => 'Web Storage',
@@ -37,6 +39,7 @@ module Docs · 4 unmodified lines
37 'Web App Manifest' => 'Web App Manifest',39 'Web App Manifest' => 'Web App Manifest',
38 'Web Audio' => 'Web Audio',40 'Web Audio' => 'Web Audio',
39 'Web Messaging' => 'Web Messaging',41 'Web Messaging' => 'Web Messaging',
42 'WebGL' => 'WebGL',
40 'WebRTC' => 'WebRTC',43 'WebRTC' => 'WebRTC',
41 'WebVR' => 'WebVR',44 'WebVR' => 'WebVR',
42 'Wheel' => 'Mouse',45 'Wheel' => 'Mouse',
@@ -47,7 +50,7 @@ module Docs · 4 unmodified lines
47 LOAD_SLUGS = %w(abort beforeunload DOMContentLoaded error load50 LOAD_SLUGS = %w(abort beforeunload DOMContentLoaded error load
48 readystatechange unload)51 readystatechange unload)
49 52
50 APPEND_TYPE = %w(Application\ Cache IndexedDB Progress53 APPEND_TYPE = %w(Application\ Cache IndexedDB Progress Telephony
51 Server\ Sent\ Events WebSocket Web\ Messaging Web\ Workers)54 Server\ Sent\ Events WebSocket Web\ Messaging Web\ Workers)
52 55
53 def get_name56 def get_name
@@ -62,10 +65,9 @@ module Docs · 8 unmodified lines
62 elsif LOAD_SLUGS.include?(slug)65 elsif LOAD_SLUGS.include?(slug)
63 'Load'66 'Load'
64 else67 else
65 if info = at_css('.eventinfo, .properties').try(:content)68 info = css('.eventinfo, .properties, .standard-table').map(&:content).join
66 TYPE_BY_INFO.each_pair do |key, value|69 TYPE_BY_INFO.each_pair do |key, value|
67 return value if info.include?(key)70 return value if info.include?(key)
68 end
69 end71 end
70 72
71 'Miscellaneous'73 'Miscellaneous'
@@ -73,7 +75,11 @@ module Docs · 1 unmodified line
73 end75 end
74 76
75 def include_default_entry?77 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/
77 end83 end
78 end84 end
79 end85 end
lib/docs/filters/mdn/clean_html.rb+1−1
@@ -21,7 +21,7 @@ module Docs · 20 unmodified lines
21 node.name = 'th'21 node.name = 'th'
22 end22 end
23 23
24 css('nobr', 'span[style*="font"]', 'pre code').each do |node|24 css('nobr', 'span[style*="font"]', 'pre code', 'h2 strong').each do |node|
25 node.before(node.children).remove25 node.before(node.children).remove
26 end26 end
27 27
lib/docs/scrapers/mdn/css.rb+3−2
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
10 10
11 options[:skip] = %w(/CSS3 /Media/Visual /paged_media)11 options[:skip] = %w(/CSS3 /Media/Visual /paged_media)
12 options[:skip] += %w(/mq-boolean /single-transition-timing-function) # bug12 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/]
14 14
15 options[:replace_paths] = {15 options[:replace_paths] = {
16 '/%3Cbasic-shape%3E' => '/basic-shape',16 '/%3Cbasic-shape%3E' => '/basic-shape',
@@ -18,7 +18,8 @@ module Docs · 1 unmodified line
18 '/range' => '/@counter-style/range',18 '/range' => '/@counter-style/range',
19 '/symbols' => '/@counter-style/symbols',19 '/symbols' => '/@counter-style/symbols',
20 '/system' => '/@counter-style/system',20 '/system' => '/@counter-style/system',
21 '/var' => '/var()'21 '/var' => '/var()',
22 '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes'
22 }23 }
23 24
24 options[:fix_urls] = ->(url) do25 options[:fix_urls] = ->(url) do