History

Update JavaScript documentation

Closes #332.

Thibaut Courouble committed 10 years ago

Commit 35df0411 parent 28e693d3 files · +22 −6Browse files

Unified · Split

3 files
  1. lib/docs/filters/javascript/entries.rb +15 −3
  2. lib/docs/filters/mdn/clean_html.rb +2 −1
  3. lib/docs/scrapers/mdn/javascript.rb +5 −2
lib/docs/filters/javascript/entries.rb+15−3
@@ -1,15 +1,16 @@
11 module Docs
22 class Javascript
33 class EntriesFilter < Docs::EntriesFilter
4− TYPES = %w(Array ArrayBuffer Boolean DataView Date Function Intl JSON Map
5− Math Number Object Promise RegExp Set SIMD String Symbol TypedArray
6− WeakMap WeakSet)
4+ TYPES = %w(Array ArrayBuffer Atomics Boolean DataView Date Function
5+ Generator Intl JSON Map Math Number Object Promise Reflect RegExp
6+ Set SharedArrayBuffer SIMD String Symbol TypedArray WeakMap WeakSet)
77 INTL_OBJECTS = %w(Collator DateTimeFormat NumberFormat)
88
99 def get_name
1010 if slug.start_with? 'Global_Objects/'
1111 name, method, *rest = *slug.sub('Global_Objects/', '').split('/')
1212 name.prepend 'Intl.' if INTL_OBJECTS.include?(name)
13+ name.prepend 'SIMD.' if html.include?("SIMD.#{name}")
1314
1415 if method
1516 unless method == method.upcase || method == 'NaN'
@@ -18,6 +19,15 @@ module Docs · 2 unmodified lines
1819 name << ".#{([method] + rest).join('.')}"
1920 end
2021
22+ if name.exclude?('.prototype')
23+ path = name.split('.')
24+ if ((node = at_css('.syntaxbox') || at_css('code')) && node.content =~ /(?:\s|\A)[a-z\_][a-zA-Z\_]+\.#{path.last}/) ||
25+ ((node = at_css('.standard-table')) && node.content =~ /\.prototype[\[\.]#{path.last}/)
26+ path[-2] = path[-2][0].downcase + path[-2][1..-1]
27+ name = path.join('.')
28+ end
29+ end
30+
2131 name
2232 else
2333 name = super
@@ -45,6 +55,8 @@ module Docs · 21 unmodified lines
4555 'Errors'
4656 elsif INTL_OBJECTS.include?(object)
4757 'Intl'
58+ elsif name.start_with?('SIMD')
59+ 'SIMD'
4860 elsif method || TYPES.include?(object)
4961 object
5062 else
lib/docs/filters/mdn/clean_html.rb+2−1
@@ -7,7 +7,8 @@ module Docs · 6 unmodified lines
77 '.breadcrumbs', # (e.g. CSS/animation)
88 '.Quick_links', # (e.g. CSS/animation)
99 '.todo',
10− '.draftHeader']
10+ '.draftHeader',
11+ '.hidden']
1112
1213 def call
1314 css(*REMOVE_NODES).remove
lib/docs/scrapers/mdn/javascript.rb+5−2
@@ -12,7 +12,6 @@ module Docs · 11 unmodified lines
1212 /About
1313 /Code_comments
1414 /Deprecated_Features
15− /Deprecated_and_obsolete_features
1615 /Functions_and_function_scope
1716 /Global_Objects/Iterator
1817 /Global_Objects/Proxy
@@ -35,7 +34,11 @@ module Docs · 16 unmodified lines
3534 /Operators
3635 /Statements)
3736
38− options[:skip_patterns] = [/additional_examples/i, /noSuchMethod/i]
37+ options[:skip_patterns] = [
38+ /additional_examples/i,
39+ /noSuchMethod/i,
40+ /Deprecated_and_obsolete_features/
41+ ]
3942
4043 options[:fix_urls] = ->(url) do
4144 url.sub! 'https://developer.mozilla.org/en-US/docs/JavaScript/Reference', Javascript.base_url