Improve JavaScript scraper

pull/185/head
Thibaut 10 years ago
parent 0812ee0be0
commit c5ace7effd

@ -8,14 +8,14 @@ module Docs
def get_name
if slug.start_with? 'Global_Objects/'
name, method = *slug.sub('Global_Objects/', '').split('/')
name, method, *rest = *slug.sub('Global_Objects/', '').split('/')
name.prepend 'Intl.' if INTL_OBJECTS.include?(name)
if method
unless method == method.upcase || method == 'NaN'
method = method[0].downcase + method[1..-1] # e.g. Trim => trim
end
name << ".#{method}"
name << ".#{([method] + rest).join('.')}"
end
name

@ -20,7 +20,7 @@ module Docs
node.before(node.children).remove
end
css('h2[style]', 'pre[style]').remove_attr('style')
css('h2[style]', 'pre[style]', 'th[style]', 'div[style*="line-height"]').remove_attr('style')
doc
end

@ -35,6 +35,8 @@ module Docs
/Operators
/Statements)
options[:skip_patterns] = [/additional_examples/i, /noSuchMethod/i]
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/JavaScript/Reference', Javascript.base_url

Loading…
Cancel
Save