Update JavaScript documentation

Fixes #9
pull/29/head
Thibaut 11 years ago
parent da165074a3
commit 33bf960846

@ -7,15 +7,12 @@ module Docs
end end
def root def root
css(*%w(#About_this_Reference+div #About_this_Reference css(*%w(#About_this_Reference+div #About_this_Reference #Comments~* #Comments)).remove
#Typed_array_constructors+ul #Typed_array_constructors
#Internationalization_constructors+ul #Internationalization_constructors
#Comments~* #Comments)).remove
# Move "Global Objects" lists to the same level as the other ones # Move "Global Objects" lists to the same level as the other ones
div = at_css '#Global_Objects + div' div = at_css '#Global_Objects + div'
div.css('h3').each { |node| node.name = 'h2' } div.css('h3').each { |node| node.name = 'h2' }
at_css('#Global_Objects').replace(div) at_css('#Global_Objects').replace(div.children)
# Remove heading links # Remove heading links
css('h2 > a').each do |node| css('h2 > a').each do |node|
@ -25,9 +22,15 @@ module Docs
end end
def other def other
# Remove "style" attribute
css('.inheritsbox', '.overheadIndicator').each do |node| css('.inheritsbox', '.overheadIndicator').each do |node|
node.remove_attribute 'style' node.remove_attribute 'style'
end end
# Remove <div> wrapping .overheadIndicator
css('div > .overheadIndicator:first-child:last-child').each do |node|
node.parent.replace(node)
end
end end
end end
end end

@ -1,28 +1,17 @@
module Docs module Docs
class Javascript class Javascript
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
TYPES = %w(Array Boolean Date Function JSON Math Number Object RegExp String) TYPES = %w(Array Boolean Date Function Intl JSON Math Number Object RegExp String)
INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat)
ADDITIONAL_ENTRIES = {
'operators/arithmetic_operators' => [
%w(++ .2B.2B_.28Increment.29),
%w(-- --_.28Decrement.29) ],
'operators/bitwise_operators' => [
%w(& .26_(Bitwise_AND)),
%w(| .7C_(Bitwise_OR)),
%w(^ .5E_(Bitwise_XOR)),
%w(~ .7E_(Bitwise_NOT)),
%w(<< <<_(Left_shift)),
%w(>> >>_(Sign-propagating_right_shift)),
%w(>>> >>>_(Zero-fill_right_shift)) ]}
def get_name def get_name
if slug.start_with? 'Global_Objects/' if slug.start_with? 'Global_Objects/'
name, method = *slug.sub('Global_Objects/', '').split('/') name, method = *slug.sub('Global_Objects/', '').split('/')
name.prepend 'Intl.' if INTL_OBJECTS.include?(name)
if method if method
unless method == method.upcase || method == 'NaN' unless method == method.upcase || method == 'NaN'
method = method[0].downcase + method[1..-1] # e.g. Constructor => constructor method = method[0].downcase + method[1..-1] # e.g. Trim => trim
end end
name << ".#{method}" name << ".#{method}"
end end
@ -48,16 +37,26 @@ module Docs
object, method = *slug.sub('Global_Objects/', '').split('/') object, method = *slug.sub('Global_Objects/', '').split('/')
if object.end_with? 'Error' if object.end_with? 'Error'
'Errors' 'Errors'
elsif INTL_OBJECTS.include?(object)
'Intl'
elsif method || TYPES.include?(object) elsif method || TYPES.include?(object)
object object
else else
'Global Objects' 'Global Objects'
end end
else
'Miscellaneous'
end end
end end
def additional_entries def include_default_entry?
ADDITIONAL_ENTRIES[slug] || [] node = doc.at_css '.overheadIndicator'
# Can't use :first-child because #doc is a DocumentFragment
return true unless node && node.parent == doc && !node.previous_element
!node.content.include?('not on a standards track') &&
!node.content.include?('removed from the Web')
end end
end end
end end

@ -14,18 +14,12 @@ module Docs
/Deprecated_Features /Deprecated_Features
/Deprecated_and_obsolete_features /Deprecated_and_obsolete_features
/Functions_and_function_scope /Functions_and_function_scope
/Functions_and_function_scope/Strict_mode
/Global_Objects/Iterator /Global_Objects/Iterator
/Global_Objects/Number/toInteger
/Global_Objects/ParallelArray
/Global_Objects/Proxy /Global_Objects/Proxy
/Global_Objects/uneval
/Reserved_Words /Reserved_Words
/arrow_functions /arrow_functions
/rest_parameters) /rest_parameters)
options[:skip_patterns] = [/Intl/, /Collator/, /DateTimeFormat/, /NumberFormat/]
# Duplicates # Duplicates
options[:skip].concat %w( options[:skip].concat %w(
/Global_Objects /Global_Objects

Loading…
Cancel
Save