|
|
@@ -1,40 +1,28 @@
|
|
|
module Docs
|
|
|
class Babel
|
|
|
class EntriesFilter < Docs::EntriesFilter
|
|
|
+
|
|
|
+ ENTRIES = {
|
|
|
+ 'Usage' => ['Options', 'Config Files', '@babel/cli', '@babel/polyfill',
|
|
|
+ '@babel/plugin-transform-runtime', '@babel/register'],
|
|
|
+
|
|
|
+ 'Presets' => ['@babel/preset-env', '@babel/preset-flow', '@babel/preset-react', '@babel/preset-typescript'],
|
|
|
+
|
|
|
+ 'Tooling' => ['@babel/parser', '@babel/core', '@babel/generator', '@babel/code-frame',
|
|
|
+ '@babel/helpers', '@babel/runtime', '@babel/template', '@babel/traverse', '@babel/types']
|
|
|
+ }
|
|
|
+
|
|
|
def get_name
|
|
|
at_css('h1').content
|
|
|
end
|
|
|
|
|
|
def get_type
|
|
|
- if subpath.start_with?('plugins/preset')
|
|
|
- 'Presets'
|
|
|
- elsif subpath.start_with?('plugins/transform')
|
|
|
- 'Transform Plugins'
|
|
|
- elsif subpath.start_with?('plugins/minify')
|
|
|
- 'Minification'
|
|
|
- elsif subpath.start_with?('plugins/syntax')
|
|
|
- 'Syntax Plugins'
|
|
|
- elsif subpath.start_with?('plugins')
|
|
|
- 'Plugins'
|
|
|
- elsif subpath.start_with?('usage/')
|
|
|
- 'Usage'
|
|
|
- elsif subpath.start_with?('core-packages/')
|
|
|
- 'Core Packages'
|
|
|
- else
|
|
|
- 'Miscellaneous'
|
|
|
+ ENTRIES.each do |key, value|
|
|
|
+ return key if value.include?(name)
|
|
|
+ return 'Other Plugins' if subpath.include?('babel-plugin')
|
|
|
end
|
|
|
end
|
|
|
|
|
|
- def additional_entries
|
|
|
- return [] unless slug.include?('api')
|
|
|
-
|
|
|
- css('h2').each_with_object [] do |node, entries|
|
|
|
- name = node.content.strip
|
|
|
- next unless name.start_with?('babel.')
|
|
|
- name.sub! %r{\(.*}, '()'
|
|
|
- entries << [name, node['id']]
|
|
|
- end
|
|
|
- end
|
|
|
end
|
|
|
end
|
|
|
end
|