Fixes #9
Unified · Split
| @@ -7,15 +7,12 @@ module Docs · 6 unmodified lines | |||
| 7 | end | 7 | end |
| 8 | 8 | ||
| 9 | def root | 9 | def root |
| 10 | css(*%w(#About_this_Reference+div #About_this_Reference | 10 | css(*%w(#About_this_Reference+div #About_this_Reference #Comments~* #Comments)).remove |
| 11 | #Typed_array_constructors+ul #Typed_array_constructors | ||
| 12 | #Internationalization_constructors+ul #Internationalization_constructors | ||
| 13 | #Comments~* #Comments)).remove | ||
| 14 | 11 | ||
| 15 | # Move "Global Objects" lists to the same level as the other ones | 12 | # Move "Global Objects" lists to the same level as the other ones |
| 16 | div = at_css '#Global_Objects + div' | 13 | div = at_css '#Global_Objects + div' |
| 17 | div.css('h3').each { |node| node.name = 'h2' } | 14 | div.css('h3').each { |node| node.name = 'h2' } |
| 18 | at_css('#Global_Objects').replace(div) | 15 | at_css('#Global_Objects').replace(div.children) |
| 19 | 16 | ||
| 20 | # Remove heading links | 17 | # Remove heading links |
| 21 | css('h2 > a').each do |node| | 18 | css('h2 > a').each do |node| |
| @@ -25,9 +22,15 @@ module Docs · 3 unmodified lines | |||
| 25 | end | 22 | end |
| 26 | 23 | ||
| 27 | def other | 24 | def other |
| 25 | # Remove "style" attribute | ||
| 28 | css('.inheritsbox', '.overheadIndicator').each do |node| | 26 | css('.inheritsbox', '.overheadIndicator').each do |node| |
| 29 | node.remove_attribute 'style' | 27 | node.remove_attribute 'style' |
| 30 | end | 28 | end |
| 29 | |||
| 30 | # Remove <div> wrapping .overheadIndicator | ||
| 31 | css('div > .overheadIndicator:first-child:last-child').each do |node| | ||
| 32 | node.parent.replace(node) | ||
| 33 | end | ||
| 31 | end | 34 | end |
| 32 | end | 35 | end |
| 33 | end | 36 | end |
| @@ -1,28 +1,17 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Javascript | 2 | class Javascript |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | TYPES = %w(Array Boolean Date Function JSON Math Number Object RegExp String) | 4 | TYPES = %w(Array Boolean Date Function Intl JSON Math Number Object RegExp String) |
| 5 | 5 | INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat) | |
| 6 | ADDITIONAL_ENTRIES = { | ||
| 7 | 'operators/arithmetic_operators' => [ | ||
| 8 | %w(++ .2B.2B_.28Increment.29), | ||
| 9 | %w(-- --_.28Decrement.29) ], | ||
| 10 | 'operators/bitwise_operators' => [ | ||
| 11 | %w(& .26_(Bitwise_AND)), | ||
| 12 | %w(| .7C_(Bitwise_OR)), | ||
| 13 | %w(^ .5E_(Bitwise_XOR)), | ||
| 14 | %w(~ .7E_(Bitwise_NOT)), | ||
| 15 | %w(<< <<_(Left_shift)), | ||
| 16 | %w(>> >>_(Sign-propagating_right_shift)), | ||
| 17 | %w(>>> >>>_(Zero-fill_right_shift)) ]} | ||
| 18 | 6 | ||
| 19 | def get_name | 7 | def get_name |
| 20 | if slug.start_with? 'Global_Objects/' | 8 | if slug.start_with? 'Global_Objects/' |
| 21 | name, method = *slug.sub('Global_Objects/', '').split('/') | 9 | name, method = *slug.sub('Global_Objects/', '').split('/') |
| 10 | name.prepend 'Intl.' if INTL_OBJECTS.include?(name) | ||
| 22 | 11 | ||
| 23 | if method | 12 | if method |
| 24 | unless method == method.upcase || method == 'NaN' | 13 | unless method == method.upcase || method == 'NaN' |
| 25 | method = method[0].downcase + method[1..-1] # e.g. Constructor => constructor | 14 | method = method[0].downcase + method[1..-1] # e.g. Trim => trim |
| 26 | end | 15 | end |
| 27 | name << ".#{method}" | 16 | name << ".#{method}" |
| 28 | end | 17 | end |
| @@ -48,16 +37,26 @@ module Docs · 19 unmodified lines | |||
| 48 | object, method = *slug.sub('Global_Objects/', '').split('/') | 37 | object, method = *slug.sub('Global_Objects/', '').split('/') |
| 49 | if object.end_with? 'Error' | 38 | if object.end_with? 'Error' |
| 50 | 'Errors' | 39 | 'Errors' |
| 40 | elsif INTL_OBJECTS.include?(object) | ||
| 41 | 'Intl' | ||
| 51 | elsif method || TYPES.include?(object) | 42 | elsif method || TYPES.include?(object) |
| 52 | object | 43 | object |
| 53 | else | 44 | else |
| 54 | 'Global Objects' | 45 | 'Global Objects' |
| 55 | end | 46 | end |
| 47 | else | ||
| 48 | 'Miscellaneous' | ||
| 56 | end | 49 | end |
| 57 | end | 50 | end |
| 58 | 51 | ||
| 59 | def additional_entries | 52 | def include_default_entry? |
| 60 | ADDITIONAL_ENTRIES[slug] || [] | 53 | node = doc.at_css '.overheadIndicator' |
| 54 | |||
| 55 | # Can't use :first-child because #doc is a DocumentFragment | ||
| 56 | return true unless node && node.parent == doc && !node.previous_element | ||
| 57 | |||
| 58 | !node.content.include?('not on a standards track') && | ||
| 59 | !node.content.include?('removed from the Web') | ||
| 61 | end | 60 | end |
| 62 | end | 61 | end |
| 63 | end | 62 | end |
| @@ -14,18 +14,12 @@ module Docs · 13 unmodified lines | |||
| 14 | /Deprecated_Features | 14 | /Deprecated_Features |
| 15 | /Deprecated_and_obsolete_features | 15 | /Deprecated_and_obsolete_features |
| 16 | /Functions_and_function_scope | 16 | /Functions_and_function_scope |
| 17 | /Functions_and_function_scope/Strict_mode | ||
| 18 | /Global_Objects/Iterator | 17 | /Global_Objects/Iterator |
| 19 | /Global_Objects/Number/toInteger | ||
| 20 | /Global_Objects/ParallelArray | ||
| 21 | /Global_Objects/Proxy | 18 | /Global_Objects/Proxy |
| 22 | /Global_Objects/uneval | ||
| 23 | /Reserved_Words | 19 | /Reserved_Words |
| 24 | /arrow_functions | 20 | /arrow_functions |
| 25 | /rest_parameters) | 21 | /rest_parameters) |
| 26 | 22 | ||
| 27 | options[:skip_patterns] = [/Intl/, /Collator/, /DateTimeFormat/, /NumberFormat/] | ||
| 28 | |||
| 29 | # Duplicates | 23 | # Duplicates |
| 30 | options[:skip].concat %w( | 24 | options[:skip].concat %w( |
| 31 | /Global_Objects | 25 | /Global_Objects |