History

Merge pull request #1370 from simon04/webpack-5.6

Simon Legner committed 5 years ago

Commit 4d3bae42 parents 8581763 52910222 files · +46 −69Browse files

Unified · Split

2 files
  1. lib/docs/filters/webpack/clean_html.rb +10 −30
  2. lib/docs/scrapers/webpack.rb +36 −39
lib/docs/filters/webpack/clean_html.rb+10−30
@@ -2,48 +2,28 @@ module Docs · 1 unmodified line
22 class Webpack
33 class CleanHtmlFilter < Filter
44 def call
5− @doc = at_css('.page__content')
6−
75 at_css('h1').content = 'webpack' if root_page?
86
9− css('h3').each do |node|
10− node.name = 'h2'
11− end unless at_css('h2')
12−
13− css('.anchor[id]').each do |node|
14− node.parent['id'] = node['id']
15− node.remove
16− end
17−
187 css('hr', '.page__edit', 'hr + h3:contains("Contributors")', 'hr + h2:contains("Contributors")',
19− '.contributors', '.icon-link', '#maintainers.header', '#maintainers.header + table',
20− '#maintainer.header', '#maintainer.header + table', '.page-links__link', '.page-links__gap').remove
8+ 'td > .title', '.adjacent-links', '.contributors', '.icon-link',
9+ '#maintainers', '#maintainers + table',
10+ '#maintainer', '#maintainer + table',
11+ '.page-links__link', '.page-links__gap').remove
2112
2213 css('> div', '.tip-content', '.header span').each do |node|
2314 node.before(node.children).remove
2415 end
2516
26− css('> h1:first-child + h1').remove
27−
28− css('.code-details-summary-span').each do |node|
29− node.content = node.content.remove(' (click to show)')
30− end
31−
32− css('.table-wrap').each do |node|
33− css('.table-td-title').remove
34− css('.table-th').each { |n| n.name = 'th' }
35− css('.table-td').each { |n| n.name = 'td' }
36− css('.table-tr').each { |n| n.name = 'tr' }
37− css('.table-body').each { |n| n.name = 'tbody' }
38− css('.table-header').each { |n| n.name = 'thead' }
39− node.name = 'table'
40− end
41−
4217 css('pre > code').each do |node|
43− node.parent['data-language'] = node['class'][/lang-(\w+)/, 1].sub('jsx', 'js') if node['class']
18+ node.parent['data-language'] = 'js'
19+ node.parent['data-language'] = node['class'][/language-(\w+)/, 1].sub('jsx', 'js') if node['class'] && node['class'][/language-(\w+)/, 1]
4420 node.parent.content = node.parent.content
4521 end
4622
23+ # for webpack-contrib /loaders and /plugins
24+ shields = at_css('img[src*="shields.io"]')
25+ shields.ancestors('p')[0].remove if shields
26+
4727 doc
4828 end
4929 end
lib/docs/scrapers/webpack.rb+36−39
@@ -3,49 +3,46 @@ module Docs · 2 unmodified lines
33 self.name = 'webpack'
44 self.type = 'webpack'
55
6− version do
7− self.release = '4.16.5'
8− self.base_url = 'https://webpack.js.org/'
9− self.root_path = 'guides/'
10− self.initial_paths = %w(
11− concepts/
12− guides/
13− api/
14− configuration/
15− loaders/
16− plugins/
17− )
18− self.links = {
19− home: 'https://webpack.js.org/',
20− code: 'https://github.com/webpack/webpack'
21− }
6+ self.root_path = 'guides/'
7+ self.initial_paths = %w(
8+ concepts/
9+ guides/
10+ api/
11+ configuration/
12+ loaders/
13+ plugins/
14+ )
15+ self.links = {
16+ home: 'https://webpack.js.org/',
17+ code: 'https://github.com/webpack/webpack'
18+ }
2219
23− html_filters.push 'webpack/clean_html', 'webpack/entries'
20+ html_filters.push 'webpack/clean_html', 'webpack/entries'
2421
25− options[:container] = '.page'
26− options[:trailing_slash] = false
27− options[:only_patterns] = [
28− /\Aconcepts\//,
29− /\Aguides\//,
30− /\Aapi\//,
31− /\Aconfiguration\//,
32− /\Aloaders\//,
33− /\Aplugins\//
34− ]
22+ options[:container] = '.page'
23+ options[:trailing_slash] = false
24+ options[:only_patterns] = [
25+ /\Aconcepts\//,
26+ /\Aguides\//,
27+ /\Aapi\//,
28+ /\Aconfiguration\//,
29+ /\Aloaders\//,
30+ /\Aplugins\//
31+ ]
3532
36− options[:attribution] = <<-HTML
37− &copy; JS Foundation and other contributors<br>
38− Licensed under the Creative Commons Attribution License 4.0.
39− HTML
33+ options[:attribution] = <<-HTML
34+ &copy; JS Foundation and other contributors<br>
35+ Licensed under the Creative Commons Attribution License 4.0.
36+ HTML
37+
38+ version '5' do
39+ self.release = '5.6.0'
40+ self.base_url = 'https://webpack.js.org/'
41+ end
4042
41− ([self.root_path] + self.initial_paths).each do |path|
42− stub(path) do
43− capybara = load_capybara_selenium
44− capybara.app_host = self.base_url.origin
45− capybara.visit("#{self.base_url}#{path}")
46− capybara.execute_script('return document.body.innerHTML')
47− end
48− end
43+ version '4' do
44+ self.release = '4.44.2'
45+ self.base_url = 'https://v4.webpack.js.org/'
4946 end
5047
5148 version '1' do