Update JavaScript documentation

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

@ -1,15 +1,16 @@
module Docs module Docs
class Javascript class Javascript
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
TYPES = %w(Array ArrayBuffer Boolean DataView Date Function Intl JSON Map TYPES = %w(Array ArrayBuffer Atomics Boolean DataView Date Function
Math Number Object Promise RegExp Set SIMD String Symbol TypedArray Generator Intl JSON Map Math Number Object Promise Reflect RegExp
WeakMap WeakSet) Set SharedArrayBuffer SIMD String Symbol TypedArray WeakMap WeakSet)
INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat) INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat)
def get_name def get_name
if slug.start_with? 'Global_Objects/' if slug.start_with? 'Global_Objects/'
name, method, *rest = *slug.sub('Global_Objects/', '').split('/') name, method, *rest = *slug.sub('Global_Objects/', '').split('/')
name.prepend 'Intl.' if INTL_OBJECTS.include?(name) name.prepend 'Intl.' if INTL_OBJECTS.include?(name)
name.prepend 'SIMD.' if html.include?("SIMD.#{name}")
if method if method
unless method == method.upcase || method == 'NaN' unless method == method.upcase || method == 'NaN'
@ -18,6 +19,15 @@ module Docs
name << ".#{([method] + rest).join('.')}" name << ".#{([method] + rest).join('.')}"
end 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 name
else else
name = super name = super
@ -45,6 +55,8 @@ module Docs
'Errors' 'Errors'
elsif INTL_OBJECTS.include?(object) elsif INTL_OBJECTS.include?(object)
'Intl' 'Intl'
elsif name.start_with?('SIMD')
'SIMD'
elsif method || TYPES.include?(object) elsif method || TYPES.include?(object)
object object
else else

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

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

Loading…
Cancel
Save