| @@ -1,15 +1,16 @@ |
| 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 ArrayBuffer Boolean DataView Date Function Intl JSON Map | 4 | TYPES = %w(Array ArrayBuffer Atomics Boolean DataView Date Function |
| 5 | Math Number Object Promise RegExp Set SIMD String Symbol TypedArray | 5 | Generator Intl JSON Map Math Number Object Promise Reflect RegExp |
| 6 | WeakMap WeakSet) | 6 | Set SharedArrayBuffer SIMD String Symbol TypedArray WeakMap WeakSet) |
| 7 | INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat) | 7 | INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat) |
| 8 | | 8 | |
| 9 | def get_name | 9 | def get_name |
| 10 | if slug.start_with? 'Global_Objects/' | 10 | if slug.start_with? 'Global_Objects/' |
| 11 | name, method, *rest = *slug.sub('Global_Objects/', '').split('/') | 11 | name, method, *rest = *slug.sub('Global_Objects/', '').split('/') |
| 12 | name.prepend 'Intl.' if INTL_OBJECTS.include?(name) | 12 | name.prepend 'Intl.' if INTL_OBJECTS.include?(name) |
| | 13 | name.prepend 'SIMD.' if html.include?("SIMD.#{name}") |
| 13 | | 14 | |
| 14 | if method | 15 | if method |
| 15 | unless method == method.upcase || method == 'NaN' | 16 | unless method == method.upcase || method == 'NaN' |
| @@ -18,6 +19,15 @@ module Docs · 2 unmodified lines |
| 18 | name << ".#{([method] + rest).join('.')}" | 19 | name << ".#{([method] + rest).join('.')}" |
| 19 | end | 20 | end |
| 20 | | 21 | |
| | 22 | if name.exclude?('.prototype') |
| | 23 | path = name.split('.') |
| | 24 | if ((node = at_css('.syntaxbox') || at_css('code')) && node.content =~ /(?:\s|\A)[a-z\_][a-zA-Z\_]+\.#{path.last}/) || |
| | 25 | ((node = at_css('.standard-table')) && node.content =~ /\.prototype[\[\.]#{path.last}/) |
| | 26 | path[-2] = path[-2][0].downcase + path[-2][1..-1] |
| | 27 | name = path.join('.') |
| | 28 | end |
| | 29 | end |
| | 30 | |
| 21 | name | 31 | name |
| 22 | else | 32 | else |
| 23 | name = super | 33 | name = super |
| @@ -45,6 +55,8 @@ module Docs · 21 unmodified lines |
| 45 | 'Errors' | 55 | 'Errors' |
| 46 | elsif INTL_OBJECTS.include?(object) | 56 | elsif INTL_OBJECTS.include?(object) |
| 47 | 'Intl' | 57 | 'Intl' |
| | 58 | elsif name.start_with?('SIMD') |
| | 59 | 'SIMD' |
| 48 | elsif method || TYPES.include?(object) | 60 | elsif method || TYPES.include?(object) |
| 49 | object | 61 | object |
| 50 | else | 62 | else |