History

Update babel to 7.12.6

MasterEnoc committed 5 years ago

Commit 4b213991 parent 79648743 files · +38 −57Browse files

Unified · Split

3 files
  1. lib/docs/filters/babel/clean_html.rb +7 −22
  2. lib/docs/filters/babel/entries.rb +14 −26
  3. lib/docs/scrapers/babel.rb +17 −9
lib/docs/filters/babel/clean_html.rb+7−22
@@ -2,36 +2,21 @@ module Docs · 1 unmodified line
22 class Babel
33 class CleanHtmlFilter < Filter
44 def call
5− if root_page?
6− doc.inner_html = '<h1>Babel</h1>'
7− return doc
8− end
95
10− header = at_css('.docs-header .col-md-12')
11− @doc = at_css('.docs-content')
12− doc.prepend_child(header)
6+ css('.fixedHeaderContainer').remove
137
14− css('.btn-clipboard', '.package-links').remove
8+ css('.toc').remove
159
16− css('.col-md-12', 'h1 a', 'h2 a', 'h3 a', 'h4 a', 'h5 a', 'h5 a').each do |node|
17− node.before(node.children).remove
18− end
10+ css('.toc-headings').remove
1911
20− css('div.highlighter-rouge').each do |node|
21− pre = node.at_css('pre')
12+ css('.postHeader > a').remove
2213
23− lang = node['class'][/language-(\w+)/, 1]
24− lang = 'bash' if lang == 'sh'
25− pre['data-language'] = lang
14+ css('.nav-footer').remove
2615
27− pre.remove_attribute('class')
28− pre.content = pre.content
29− node.replace(pre)
30− end
31−
32− css('code').remove_attr('class')
16+ css('.docs-prevnext').remove
3317
3418 doc
19+
3520 end
3621 end
3722 end
lib/docs/filters/babel/entries.rb+14−26
@@ -1,40 +1,28 @@
11 module Docs
22 class Babel
33 class EntriesFilter < Docs::EntriesFilter
4+
5+ ENTRIES = {
6+ 'Usage' => ['Options', 'Config Files', '@babel/cli', '@babel/polyfill',
7+ '@babel/plugin-transform-runtime', '@babel/register'],
8+
9+ 'Presets' => ['@babel/preset-env', '@babel/preset-flow', '@babel/preset-react', '@babel/preset-typescript'],
10+
11+ 'Tooling' => ['@babel/parser', '@babel/core', '@babel/generator', '@babel/code-frame',
12+ '@babel/helpers', '@babel/runtime', '@babel/template', '@babel/traverse', '@babel/types']
13+ }
14+
415 def get_name
516 at_css('h1').content
617 end
718
819 def get_type
9− if subpath.start_with?('plugins/preset')
10− 'Presets'
11− elsif subpath.start_with?('plugins/transform')
12− 'Transform Plugins'
13− elsif subpath.start_with?('plugins/minify')
14− 'Minification'
15− elsif subpath.start_with?('plugins/syntax')
16− 'Syntax Plugins'
17− elsif subpath.start_with?('plugins')
18− 'Plugins'
19− elsif subpath.start_with?('usage/')
20− 'Usage'
21− elsif subpath.start_with?('core-packages/')
22− 'Core Packages'
23− else
24− 'Miscellaneous'
20+ ENTRIES.each do |key, value|
21+ return key if value.include?(name)
22+ return 'Other Plugins' if subpath.include?('babel-plugin')
2523 end
2624 end
2725
28− def additional_entries
29− return [] unless slug.include?('api')
30−
31− css('h2').each_with_object [] do |node, entries|
32− name = node.content.strip
33− next unless name.start_with?('babel.')
34− name.sub! %r{\(.*}, '()'
35− entries << [name, node['id']]
36− end
37− end
3826 end
3927 end
4028 end
lib/docs/scrapers/babel.rb+17−9
@@ -1,9 +1,8 @@
11 module Docs
22 class Babel < UrlScraper
33 self.type = 'simple'
4− self.base_url = 'http://babeljs.io/docs/'
5− self.release = '6.26.1'
6− self.initial_paths = %w(core-packages/)
4+ self.base_url = 'https://babeljs.io/docs/en/'
5+ self.release = '7.12.6'
76 self.links = {
87 home: 'https://babeljs.io/',
98 code: 'https://github.com/babel/babel'
@@ -12,19 +11,28 @@ module Docs · 2 unmodified lines
1211 html_filters.push 'babel/clean_html', 'babel/entries'
1312
1413 options[:trailing_slash] = true
15− options[:skip] = %w{setup/ editors/ community/videos/}
14+
15+ options[:skip_patterns] = [
16+ /usage/,
17+ /configuration/,
18+ /learn/,
19+ /v7-migration/,
20+ /v7-migration-api/,
21+ /editors/,
22+ /presets/,
23+ /caveats/,
24+ /faq/,
25+ /roadmap/
26+ ]
1627
1728 options[:attribution] = <<-HTML
18− &copy; 2018 Sebastian McKenzie<br>
29+ &copy; 2020 Sebastian McKenzie<br>
1930 Licensed under the MIT License.
2031 HTML
2132
22− stub '' do
23− '<div></div>'
24− end
25−
2633 def get_latest_version(opts)
2734 get_latest_github_release('babel', 'babel', opts)
2835 end
36+
2937 end
3038 end