Update JavaScript documentation

Closes #332.
pull/343/merge
Thibaut Courouble 9 years ago
parent 28e693d665
commit 35df0414dc

@ -1,15 +1,16 @@
module Docs
class Javascript
class EntriesFilter < Docs::EntriesFilter
TYPES = %w(Array ArrayBuffer Boolean DataView Date Function Intl JSON Map
Math Number Object Promise RegExp Set SIMD String Symbol TypedArray
WeakMap WeakSet)
TYPES = %w(Array ArrayBuffer Atomics Boolean DataView Date Function
Generator Intl JSON Map Math Number Object Promise Reflect RegExp
Set SharedArrayBuffer SIMD String Symbol TypedArray WeakMap WeakSet)
INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat)
def get_name
if slug.start_with? 'Global_Objects/'
name, method, *rest = *slug.sub('Global_Objects/', '').split('/')
name.prepend 'Intl.' if INTL_OBJECTS.include?(name)
name.prepend 'SIMD.' if html.include?("SIMD.#{name}")
if method
unless method == method.upcase || method == 'NaN'
@ -18,6 +19,15 @@ module Docs
name << ".#{([method] + rest).join('.')}"
end
if name.exclude?('.prototype')
path = name.split('.')
if ((node = at_css('.syntaxbox') || at_css('code')) && node.content =~ /(?:\s|\A)[a-z\_][a-zA-Z\_]+\.#{path.last}/) ||
((node = at_css('.standard-table')) && node.content =~ /\.prototype[\[\.]#{path.last}/)
path[-2] = path[-2][0].downcase + path[-2][1..-1]
name = path.join('.')
end
end
name
else
name = super
@ -45,6 +55,8 @@ module Docs
'Errors'
elsif INTL_OBJECTS.include?(object)
'Intl'
elsif name.start_with?('SIMD')
'SIMD'
elsif method || TYPES.include?(object)
object
else

@ -7,7 +7,8 @@ module Docs
'.breadcrumbs', # (e.g. CSS/animation)
'.Quick_links', # (e.g. CSS/animation)
'.todo',
'.draftHeader']
'.draftHeader',
'.hidden']
def call
css(*REMOVE_NODES).remove

@ -12,7 +12,6 @@ module Docs
/About
/Code_comments
/Deprecated_Features
/Deprecated_and_obsolete_features
/Functions_and_function_scope
/Global_Objects/Iterator
/Global_Objects/Proxy
@ -35,7 +34,11 @@ module Docs
/Operators
/Statements)
options[:skip_patterns] = [/additional_examples/i, /noSuchMethod/i]
options[:skip_patterns] = [
/additional_examples/i,
/noSuchMethod/i,
/Deprecated_and_obsolete_features/
]
options[:fix_urls] = ->(url) do
url.sub! 'https://developer.mozilla.org/en-US/docs/JavaScript/Reference', Javascript.base_url

Loading…
Cancel
Save