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
24 > h3 { @extend %block-label, %label-blue; }24 > h3 { @extend %block-label, %label-blue; }
25 > h4 { font-size: 1em; }25 > h4 { font-size: 1em; }
26 26
27 p > code { @extend %label; }
28
27 > .note,29 > .note,
28 .notice,30 .notice,
29 .warning,31 .warning,
lib/app.rb+2−0
@@ -293,6 +293,8 @@ class App < Sinatra::Application · 292 unmodified lines
293 '/css-data-types/' => '/css-values-units/',293 '/css-data-types/' => '/css-values-units/',
294 '/css-at-rules/' => '/?q=css%20%40',294 '/css-at-rules/' => '/?q=css%20%40',
295 '/html/article' => '/html/element/article',295 '/html/article' => '/html/element/article',
296 'html-html5/' => 'html-elements/',
297 'html-standard/' => 'html-elements/',
296 '/http-status-codes/' => '/http-status/'298 '/http-status-codes/' => '/http-status/'
297 }.each do |path, url|299 }.each do |path, url|
298 class_eval <<-CODE, __FILE__, __LINE__ + 1300 class_eval <<-CODE, __FILE__, __LINE__ + 1
lib/docs/filters/css/entries.rb+5−4
@@ -6,17 +6,17 @@ module Docs · 5 unmodified lines
6 'CSS_Background_and_Borders' => 'Backgrounds & Borders',6 'CSS_Background_and_Borders' => 'Backgrounds & Borders',
7 'CSS_Columns' => 'Multi-column Layout',7 'CSS_Columns' => 'Multi-column Layout',
8 'CSS_Flexible_Box_Layout' => 'Flexible Box Layout',8 'CSS_Flexible_Box_Layout' => 'Flexible Box Layout',
9 'CSS_Grid_Layout' => 'Grid Layout',
9 'CSS_Images' => 'Image Values',10 'CSS_Images' => 'Image Values',
10 'CSS_Lists_and_Counters' => 'Lists & Counters',11 'CSS_Lists_and_Counters' => 'Lists & Counters',
11 'CSS_Transforms' => 'Transforms',12 'CSS_Transforms' => 'Transforms',
12 'Media_Queries' => 'Media Queries',13 'Media_Queries' => 'Media Queries',
13 '@media' => 'Media Queries',
14 'transform-function' => 'Transforms',14 'transform-function' => 'Transforms',
15 '@media' => 'Media Queries',
15 'text-size-adjust' => 'Miscellaneous',16 'text-size-adjust' => 'Miscellaneous',
16 'resolved_value' => 'Miscellaneous',17 'resolved_value' => 'Miscellaneous',
17 'touch-action' => 'Miscellaneous',18 'touch-action' => 'Miscellaneous',
18 'will-change' => 'Miscellaneous',19 'will-change' => 'Miscellaneous'
19 'align-self' => 'Flexible Box Layout'
20 }20 }
21 21
22 DATA_TYPE_SLUGS = %w(angle basic-shape color_value counter frequency22 DATA_TYPE_SLUGS = %w(angle basic-shape color_value counter frequency
@@ -53,6 +53,7 @@ module Docs · 30 unmodified lines
53 type.remove! %r{\(.*\)}53 type.remove! %r{\(.*\)}
54 type.sub! 'and', '&'54 type.sub! 'and', '&'
55 type.strip!55 type.strip!
56 type = 'Grid Layout' if type.include?('Grid Layout')
56 type = 'Scroll Snap' if type.include?('Scroll Snap')57 type = 'Scroll Snap' if type.include?('Scroll Snap')
57 type = 'Compositing & Blending' if type.include?('Compositing')58 type = 'Compositing & Blending' if type.include?('Compositing')
58 type = 'Animations & Transitions' if type.in?(%w(Animations Transitions))59 type = 'Animations & Transitions' if type.in?(%w(Animations Transitions))
@@ -118,7 +119,7 @@ module Docs · 59 unmodified lines
118 %w(step-end step-end) ],119 %w(step-end step-end) ],
119 'color_value' => [120 'color_value' => [
120 %w(transparent transparent_keyword),121 %w(transparent transparent_keyword),
121 %w(currentColor currentColor_keyword),122 %w(currentColor currentcolor_keyword),
122 %w(rgb() rgb),123 %w(rgb() rgb),
123 %w(hsl() hsl),124 %w(hsl() hsl),
124 %w(rgba() rgba),125 %w(rgba() rgba),
lib/docs/filters/dom/clean_html.rb+6−0
@@ -10,9 +10,15 @@ module Docs · 9 unmodified lines
10 end10 end
11 11
12 def other12 def other
13 css('h1 + br').remove
14
13 # Bug fix: HTMLElement.offsetWidth15 # Bug fix: HTMLElement.offsetWidth
14 css('#offsetContainer .comment').remove16 css('#offsetContainer .comment').remove
15 17
18 css('section', 'font').each do |node|
19 node.before(node.children).remove
20 end
21
16 # Bug fix: CompositionEvent, DataTransfer, etc.22 # Bug fix: CompositionEvent, DataTransfer, etc.
17 if (div = at_css('div[style]')) && div['style'].include?('border: solid #ddd 2px')23 if (div = at_css('div[style]')) && div['style'].include?('border: solid #ddd 2px')
18 div.remove24 div.remove
lib/docs/filters/dom/entries.rb+6−1
@@ -24,6 +24,7 @@ module Docs · 23 unmodified lines
24 'High Resolution Time' => 'Web Performance',24 'High Resolution Time' => 'Web Performance',
25 'Intersection' => 'Intersection Observer',25 'Intersection' => 'Intersection Observer',
26 'Media Capture' => 'Media',26 'Media Capture' => 'Media',
27 'Media Session' => 'Media Session',
27 'Media Source' => 'Media',28 'Media Source' => 'Media',
28 'MediaStream' => 'Media Streams',29 'MediaStream' => 'Media Streams',
29 'Navigation Timing' => 'Web Performance',30 'Navigation Timing' => 'Web Performance',
@@ -69,6 +70,7 @@ module Docs · 39 unmodified lines
69 'element' => 'Element',70 'element' => 'Element',
70 'event' => 'Event',71 'event' => 'Event',
71 'Event' => 'Event',72 'Event' => 'Event',
73 'EventSource' => 'Server-Sent Events',
72 'Fetch' => 'Fetch',74 'Fetch' => 'Fetch',
73 'File' => 'File',75 'File' => 'File',
74 'GlobalEventHandlers' => 'GlobalEventHandlers',76 'GlobalEventHandlers' => 'GlobalEventHandlers',
@@ -78,7 +80,8 @@ module Docs · 3 unmodified lines
78 'IDB' => 'IndexedDB',80 'IDB' => 'IndexedDB',
79 'location' => 'Location',81 'location' => 'Location',
80 'navigator' => 'Navigator',82 'navigator' => 'Navigator',
81 'MediaQuery' => 'MediaQuery',83 'MediaMetadata' => 'Media Session',
84 'MediaSession' => 'Media Session',
82 'MediaTrack' => 'Media Streams',85 'MediaTrack' => 'Media Streams',
83 'Node' => 'Node',86 'Node' => 'Node',
84 'Notification' => 'Notification',87 'Notification' => 'Notification',
@@ -92,10 +95,12 @@ module Docs · 7 unmodified lines
92 'RTC' => 'WebRTC',95 'RTC' => 'WebRTC',
93 'screen' => 'Screen',96 'screen' => 'Screen',
94 'Selection' => 'Selection',97 'Selection' => 'Selection',
98 'Shadow' => 'Shadow DOM',
95 'Storage' => 'Web Storage',99 'Storage' => 'Web Storage',
96 'StyleSheet' => 'CSS',100 'StyleSheet' => 'CSS',
97 'Stylesheet' => 'CSS',101 'Stylesheet' => 'CSS',
98 'SVG' => 'SVG',102 'SVG' => 'SVG',
103 'TimeRanges' => 'Media',
99 'timing' => 'Web Performance',104 'timing' => 'Web Performance',
100 'Timing' => 'Web Performance',105 'Timing' => 'Web Performance',
101 'Touch' => 'Touch Events',106 'Touch' => 'Touch Events',
lib/docs/filters/html/clean_html.rb+2−10
@@ -2,16 +2,8 @@ module Docs · 1 unmodified line
2 class Html2 class Html
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 css('span > .icon-thumbs-down-alt:first-child:last-child').each do |node|5 css('section', 'div.section', 'div.row').each do |node|
6 node.parent.replace('deprecated')6 node.before(node.children).remove
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')
15 end7 end
16 8
17 doc9 doc
lib/docs/filters/html/entries.rb+6−18
@@ -1,7 +1,6 @@
1module Docs1module Docs
2 class Html2 class Html
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 HTML5 = %w(content element video)
5 OBSOLETE = %w(frame frameset hgroup noframes)4 OBSOLETE = %w(frame frameset hgroup noframes)
6 ADDITIONAL_ENTRIES = { 'Element/Heading_Elements' => (1..6).map { |n| ["h#{n}"] } }5 ADDITIONAL_ENTRIES = { 'Element/Heading_Elements' => (1..6).map { |n| ["h#{n}"] } }
7 6
@@ -14,23 +13,16 @@ module Docs · 6 unmodified lines
14 end13 end
15 14
16 def get_type15 def get_type
17 slug = self.slug.remove('Element/')16 return 'Miscellaneous' if slug.include?('CORS') || slug.include?('Using')
18 17
19 if self.slug.start_with?('Global_attr')18 if slug.start_with?('Global_attr')
20 'Attributes'19 'Attributes'
21 elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug)20 elsif at_css('.obsoleteHeader', '.deprecatedHeader', '.nonStandardHeader') || OBSOLETE.include?(slug.remove('Element/'))
22 'Obsolete'21 'Obsolete'
22 elsif slug.start_with?('Element/')
23 'Elements'
23 else24 else
24 spec = css('.standard-table').last.try(:content)25 'Miscellaneous'
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
34 end26 end
35 end27 end
36 28
@@ -60,10 +52,6 @@ module Docs · 23 unmodified lines
60 []52 []
61 end53 end
62 end54 end
63
64 def html5_spec?(spec)
65 (spec =~ /HTML\s?5/ || spec.include?('WHATWG HTML Living Standard')) && spec !~ /HTML\s?4/
66 end
67 end55 end
68 end56 end
69end57end
lib/docs/scrapers/mdn/css.rb+3−1
@@ -19,7 +19,9 @@ module Docs · 18 unmodified lines
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 '/element' => '/element()',
23 '/Flexbox' => '/CSS_Flexible_Box_Layout/Using_CSS_flexible_boxes',
24 '/currentColor' => '/color_value'
23 }25 }
24 26
25 options[:fix_urls] = ->(url) do27 options[:fix_urls] = ->(url) do
lib/docs/scrapers/mdn/xslt_xpath.rb+2−0
@@ -8,6 +8,8 @@ module Docs · 7 unmodified lines
8 8
9 html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title'9 html_filters.push 'xslt_xpath/clean_html', 'xslt_xpath/entries', 'title'
10 10
11 options[:root_title] = 'XSLT'
12
11 options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]13 options[:only_patterns] = [/\A\/XSLT/, /\A\/XPath/]
12 14
13 options[:fix_urls] = ->(url) do15 options[:fix_urls] = ->(url) do