Update MDN docs

Fixes #376.
pull/382/head
Thibaut Courouble 9 years ago
parent 06ee30f70a
commit a5ed27165a

@ -10,6 +10,7 @@ module Docs
'CSS_Lists_and_Counters' => 'Lists & Counters', 'CSS_Lists_and_Counters' => 'Lists & Counters',
'CSS_Transforms' => 'Transforms', 'CSS_Transforms' => 'Transforms',
'Media_Queries' => 'Media Queries', 'Media_Queries' => 'Media Queries',
'@media' => 'Media Queries',
'transform-function' => 'Transforms' 'transform-function' => 'Transforms'
} }
@ -50,6 +51,10 @@ module Docs
type type
elsif type = TYPE_BY_PATH[slug.split('/').first] elsif type = TYPE_BY_PATH[slug.split('/').first]
type type
elsif name.start_with?('::')
'Pseudo-Elements'
elsif name.start_with?(':')
'Selectors'
else else
'Miscellaneous' 'Miscellaneous'
end end

@ -2,6 +2,10 @@ module Docs
class Dom class Dom
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
TYPE_BY_SPEC = { TYPE_BY_SPEC = {
'ANGLE_' => 'WebGL',
'EXT_' => 'WebGL',
'OES_' => 'WebGL',
'WEBGL_' => 'WebGL',
'Battery Status' => 'Battery Status', 'Battery Status' => 'Battery Status',
'Canvas ' => 'Canvas', 'Canvas ' => 'Canvas',
'CSS Font Loading' => 'CSS', 'CSS Font Loading' => 'CSS',
@ -104,6 +108,7 @@ module Docs
'Speech' => 'Web Speech', 'Speech' => 'Web Speech',
'TextMetrics' => 'Canvas', 'TextMetrics' => 'Canvas',
'timing' => 'Web Performance', 'timing' => 'Web Performance',
'Timing' => 'Web Performance',
'udio' => 'Web Audio', 'udio' => 'Web Audio',
'WebSocket' => 'Web Sockets', 'WebSocket' => 'Web Sockets',
'WebGL' => 'WebGL', 'WebGL' => 'WebGL',
@ -127,7 +132,8 @@ module Docs
IndexedDB\ API. IndexedDB\ API.
MediaRecorder\ API. MediaRecorder\ API.
Tutorial. Tutorial.
XMLHttpRequest.) XMLHttpRequest.
ANGLE\ instanced\ arrays.)
def get_name def get_name
name = super name = super
@ -135,6 +141,7 @@ module Docs
name.sub! 'Input.', 'HTMLInputElement.' name.sub! 'Input.', 'HTMLInputElement.'
name.sub! 'window.navigator', 'navigator' name.sub! 'window.navigator', 'navigator'
name.sub! 'API.', 'API: ' name.sub! 'API.', 'API: '
name.sub! %r{\A(ANGLE|EXT|OES|WEBGL)[\w\ ]+\.}, 'ext.'
# Comment.Comment => Comment.constructor # Comment.Comment => Comment.constructor
name.sub! %r{\A(\w+)\.\1\z}, '\1.constructor' unless name == 'window.window' name.sub! %r{\A(\w+)\.\1\z}, '\1.constructor' unless name == 'window.window'
name.prepend 'XMLHttpRequest.' if slug.start_with?('XMLHttpRequest/') && !name.start_with?('XMLHttpRequest') name.prepend 'XMLHttpRequest.' if slug.start_with?('XMLHttpRequest/') && !name.start_with?('XMLHttpRequest')

@ -36,7 +36,7 @@ module Docs
if slug == 'Attributes' if slug == 'Attributes'
css('.standard-table td:first-child').map do |node| css('.standard-table td:first-child').map do |node|
name = node.content.strip name = "#{node.content.strip} (attribute)"
id = node.parent['id'] = name.parameterize id = node.parent['id'] = name.parameterize
[name, id, 'Attributes'] [name, id, 'Attributes']
end end

@ -36,6 +36,8 @@ module Docs
name.remove! 'Functions and function scope.' name.remove! 'Functions and function scope.'
name.remove! 'Operators.' name.remove! 'Operators.'
name.remove! 'Statements.' name.remove! 'Statements.'
name.sub! 'Errors.', 'Errors: '
name.sub! 'Strict mode.', 'Strict mode: '
name name
end end
end end
@ -47,7 +49,9 @@ module Docs
'Operators' 'Operators'
elsif slug.start_with? 'Classes' elsif slug.start_with? 'Classes'
'Classes' 'Classes'
elsif slug.start_with?('Functions_and_function_scope') || slug.start_with?('Functions') || slug.include?('GeneratorFunction') elsif slug.start_with? 'Errors'
'Errors'
elsif slug.start_with?('Functions') || slug.include?('GeneratorFunction')
'Function' 'Function'
elsif slug.start_with? 'Global_Objects' elsif slug.start_with? 'Global_Objects'
object, method = *slug.remove('Global_Objects/').split('/') object, method = *slug.remove('Global_Objects/').split('/')
@ -68,13 +72,14 @@ module Docs
end end
def include_default_entry? def include_default_entry?
node = doc.at_css '.overheadIndicator' node = doc.at_css '.overheadIndicator, .warning'
# Can't use :first-child because #doc is a DocumentFragment # Can't use :first-child because #doc is a DocumentFragment
return true unless node && node.parent == doc && !node.previous_element return true unless node && node.parent == doc && !node.previous_element
!node.content.include?('not on a standards track') && !node.content.include?('not on a standards track') &&
!node.content.include?('removed from the Web') && !node.content.include?('removed from the Web') &&
!node.content.include?('SpiderMonkey-specific feature, and will be removed') &&
!node.content.include?('could be removed at any time') !node.content.include?('could be removed at any time')
end end
end end

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

@ -8,35 +8,8 @@ module Docs
options[:root_title] = 'CSS' options[:root_title] = 'CSS'
options[:skip] = %w( options[:skip] = %w(/CSS3 /Media/Visual /paged_media)
/Syntax options[:skip] += %w(/mq-boolean /single-transition-timing-function) # bug
/At-rule
/Comments
/Specificity
/actual_value
/initial_value
/inheritance
/specified_value
/computed_value
/used_value actual_value
/box_model
/Replaced_element
/Value_definition_syntax
/Pseudo-elements
/Layout_mode
/Visual_formatting_model
/Shorthand_properties
/margin_collapsing
/CSS3
/Pseudo-classes
/CSS_values_syntax
/Media/Visual
/block_formatting_context
/image()
/paged_media)
options[:skip] += %w(/mq-boolean) # bug
options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/] options[:skip_patterns] = [/\-webkit/, /\-moz/, /Extensions/, /Tools/]
options[:replace_paths] = { options[:replace_paths] = {
@ -44,7 +17,7 @@ module Docs
} }
options[:fix_urls] = ->(url) do options[:fix_urls] = ->(url) do
url.sub! %r{https://developer\.mozilla\.org/en\-US/docs/CSS/([a-z@:])}, "#{Css.base_url}/\\1" url.sub! %r{https://developer\.mozilla\.org/en\-US/docs/CSS/([\w\-@:])}, "#{Css.base_url}/\\1"
url.sub! '%3A', ':' url.sub! '%3A', ':'
url.sub! '%40', '@' url.sub! '%40', '@'
url url

@ -23,6 +23,7 @@ module Docs
/DOMObject /DOMObject
/DOMStringList /DOMStringList
/Event/Comparison_of_Event_Targets /Event/Comparison_of_Event_Targets
/Format
/IDBDatabaseException /IDBDatabaseException
/IndexedDB_API/Using_JavaScript_Generators_in_Firefox /IndexedDB_API/Using_JavaScript_Generators_in_Firefox
/Notation /Notation
@ -69,6 +70,7 @@ module Docs
return if url.include?('_') || url.include?('?') return if url.include?('_') || url.include?('?')
url.sub! 'https://developer.mozilla.org/en-US/docs/DOM/', "#{Dom.base_url}/" url.sub! 'https://developer.mozilla.org/en-US/docs/DOM/', "#{Dom.base_url}/"
url.sub! 'https://developer.mozilla.org/en/DOM/', "#{Dom.base_url}/" url.sub! 'https://developer.mozilla.org/en/DOM/', "#{Dom.base_url}/"
url.sub! 'https://developer.mozilla.org/Web/API/', "#{Dom.base_url}/"
url.sub! "#{Dom.base_url}/Console", "#{Dom.base_url}/console" url.sub! "#{Dom.base_url}/Console", "#{Dom.base_url}/console"
url.sub! "#{Dom.base_url}/Document\/", "#{Dom.base_url}/document\/" url.sub! "#{Dom.base_url}/Document\/", "#{Dom.base_url}/document\/"
url.sub! "#{Dom.base_url}/Element", "#{Dom.base_url}/element" url.sub! "#{Dom.base_url}/Element", "#{Dom.base_url}/element"

@ -9,22 +9,8 @@ module Docs
# Don't want # Don't want
options[:skip] = %w( options[:skip] = %w(
/About
/Code_comments
/Deprecated_Features
/Functions_and_function_scope
/Global_Objects/Iterator
/Global_Objects/Proxy
/Reserved_Words
/Functions/arguments
/arrow_functions
/rest_parameters
/default_parameters
/Strict_mode
/Functions/rest_parameters
/Methods_Index /Methods_Index
/Properties_Index /Properties_Index
/Strict_mode/Transitioning_to_strict_mode
/Operators/Legacy_generator_function /Operators/Legacy_generator_function
/Statements/Legacy_generator_function) /Statements/Legacy_generator_function)
@ -40,6 +26,11 @@ module Docs
/Deprecated_and_obsolete_features/ /Deprecated_and_obsolete_features/
] ]
options[:replace_paths] = {
'/template_strings' => '/Template_literals',
'/Functions_and_function_scope/Strict_mode' => '/Strict_mode'
}
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
url.sub! 'https://developer.mozilla.org/en/JavaScript/Reference', Javascript.base_url url.sub! 'https://developer.mozilla.org/en/JavaScript/Reference', Javascript.base_url
@ -47,6 +38,7 @@ module Docs
url.sub! 'https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference', Javascript.base_url url.sub! 'https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference', Javascript.base_url
url.sub! '/Operators/Special/', '/Operators/' url.sub! '/Operators/Special/', '/Operators/'
url.sub! 'Destructing_assignment', 'Destructuring_assignment' url.sub! 'Destructing_assignment', 'Destructuring_assignment'
url.sub! '/Functions_and_function_scope', '/Functions'
url.sub! 'Array.prototype.values()', 'values' url.sub! 'Array.prototype.values()', 'values'
url.sub! '%2A', '*' url.sub! '%2A', '*'
url.sub! '%40', '@' url.sub! '%40', '@'

Loading…
Cancel
Save