History

Add webpack 2 documentation

Thibaut Courouble committed 9 years ago

Commit bfe83131 parent d4d1b3716 files · +193 −55Browse files

Unified · Split

16 files
  1. assets/images/docs.png +0 −0
  2. assets/images/docs@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +3 −3
  4. assets/stylesheets/application-dark.css.scss +1 −0
  5. assets/stylesheets/application.css.scss +1 −0
  6. assets/stylesheets/global/_icons.scss +1 −1
  7. assets/stylesheets/pages/_simple.scss +1 −2
  8. assets/stylesheets/pages/_webpack.scss +5 −0
  9. lib/docs/filters/webpack/clean_html.rb +24 −22
  10. lib/docs/filters/webpack/clean_html_old.rb +39 −0
  11. lib/docs/filters/webpack/entries.rb +27 −17
  12. lib/docs/filters/webpack/entries_old.rb +31 −0
  13. lib/docs/scrapers/webpack.rb +63 −14
  14. public/icons/docs/webpack/16.png +0 −0
  15. public/icons/docs/webpack/16@2x.png +0 −0
  16. public/icons/docs/webpack/SOURCE +1 −0
assets/images/docs.png+0−0

Binary file not shown.

assets/images/docs@2x.png+0−0

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+3−3
@@ -590,10 +590,10 @@ credits = [ · 589 unmodified lines
590590 'MIT',
591591 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
592592 ], [
593− 'Webpack',
593+ 'webpack',
594594 '2012-2016 Tobias Koppers',
595− 'MIT',
596− 'https://raw.githubusercontent.com/webpack/webpack/master/LICENSE'
595+ 'CC BY',
596+ 'https://creativecommons.org/licenses/by/4.0/'
597597 ], [
598598 'Yarn',
599599 '2016-2017 Yarn Contributors',
assets/stylesheets/application-dark.css.scss+1−0
@@ -92,5 +92,6 @@ · 91 unmodified lines
9292 'pages/underscore',
9393 'pages/vagrant',
9494 'pages/vue',
95+ 'pages/webpack',
9596 'pages/yard',
9697 'pages/yii';
assets/stylesheets/application.css.scss+1−0
@@ -92,5 +92,6 @@ · 91 unmodified lines
9292 'pages/underscore',
9393 'pages/vagrant',
9494 'pages/vue',
95+ 'pages/webpack',
9596 'pages/yard',
9697 'pages/yii';
assets/stylesheets/global/_icons.scss+1−1
@@ -139,7 +139,7 @@ · 138 unmodified lines
139139 ._icon-npm:before { background-position: -8rem -7rem; }
140140 ._icon-apache_http_server:before { background-position: -9rem -7rem; }
141141 ._icon-drupal:before { background-position: 0 -8rem; }
142−._icon-webpack:before { background-position: -1rem -8rem; @extend %darkIconFix !optional; }
142+._icon-webpack:before { background-position: -1rem -8rem; }
143143 ._icon-phaser:before { background-position: -2rem -8rem; }
144144 ._icon-vue:before { background-position: -3rem -8rem; }
145145 ._icon-opentsdb:before { background-position: -4rem -8rem; }
assets/stylesheets/pages/_simple.scss+1−2
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 h1, h2, h3 { margin-left: 0; }
1313 }
1414
15− p > code, li > code, td > code { @extend %label; }
15+ p > code, li > code, td > code, blockquote > code { @extend %label; }
1616 blockquote { @extend %note; }
1717 blockquote > h4, blockquote > h5 { margin-top: .25rem; }
1818 }
@@ -37,7 +37,6 @@ · 18 unmodified lines
3737 ._redux,
3838 ._sinon,
3939 ._typescript,
40−._webpack,
4140 ._yarn {
4241 @extend %simple;
4342 }
assets/stylesheets/pages/_webpack.scss+5−0
@@ -0,0 +1,5 @@
1+._webpack {
2+ @extend %simple;
3+
4+ blockquote.tip { @extend %note-blue; }
5+}
lib/docs/filters/webpack/clean_html.rb+24−22
@@ -2,37 +2,39 @@ module Docs · 1 unmodified line
22 class Webpack
33 class CleanHtmlFilter < Filter
44 def call
5− root_page? ? root : other
6− doc
7− end
5+ @doc = at_css('.page__content')
86
9− def root
10− @doc = at_css(".container > .row > .col-md-9")
7+ at_css('h1').content = 'webpack' if root_page?
118
12− # Remove all introdcution before the hr,
13− # The introduction about the documentation site which isn't relevant
14− # in devdocs.
15− hr_index = doc.children.find_index { |node| node.name == "hr" }
16− doc.children[0..hr_index].each(&:remove)
17− end
9+ css('h3').each do |node|
10+ node.name = 'h2'
11+ end unless at_css('h2')
1812
19−
20− def other
21− css('h1, h2, h3, h4').each do |node|
22− node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
13+ css('.anchor[id]').each do |node|
14+ node.parent['id'] = node['id']
15+ node.remove
2316 end
2417
25− # Re-create the header element
26− at_css("#wiki").child.before("<h1>#{at_css("#wikititle").content.titleize}</h1>")
18+ 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').remove
2721
28− @doc = at_css("#wiki")
22+ css('> div', '.tip-content', '.header span').each do |node|
23+ node.before(node.children).remove
24+ end
2925
30− css('.contents', 'a.anchor', 'hr').remove
26+ css('> h1:first-child + h1').remove
3127
32− css('pre').each do |node|
33− node.content = node.content
34− node['data-language'] = 'javascript'
28+ css('.code-details-summary-span').each do |node|
29+ node.content = node.content.remove(' (click to show)')
3530 end
31+
32+ css('pre > code').each do |node|
33+ node.parent['data-language'] = node['class'][/lang-(\w+)/, 1].sub('jsx', 'js') if node['class']
34+ node.parent.content = node.parent.content
35+ end
36+
37+ doc
3638 end
3739 end
3840 end
lib/docs/filters/webpack/clean_html_old.rb+39−0
@@ -0,0 +1,39 @@
1+module Docs
2+ class Webpack
3+ class CleanHtmlOldFilter < Filter
4+ def call
5+ root_page? ? root : other
6+ doc
7+ end
8+
9+ def root
10+ @doc = at_css(".container > .row > .col-md-9")
11+
12+ # Remove all introdcution before the hr,
13+ # The introduction about the documentation site which isn't relevant
14+ # in devdocs.
15+ hr_index = doc.children.find_index { |node| node.name == "hr" }
16+ doc.children[0..hr_index].each(&:remove)
17+ end
18+
19+
20+ def other
21+ css('h1, h2, h3, h4').each do |node|
22+ node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
23+ end
24+
25+ # Re-create the header element
26+ at_css("#wiki").child.before("<h1>#{at_css("#wikititle").content.titleize}</h1>")
27+
28+ @doc = at_css("#wiki")
29+
30+ css('.contents', 'a.anchor', 'hr').remove
31+
32+ css('pre').each do |node|
33+ node.content = node.content
34+ node['data-language'] = 'javascript'
35+ end
36+ end
37+ end
38+ end
39+end
lib/docs/filters/webpack/entries.rb+27−17
@@ -2,28 +2,38 @@ module Docs · 1 unmodified line
22 class Webpack
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
5− entry_link.content
5+ name = at_css('h1').content
6+ name.sub! ' - ', ': '
7+ name
68 end
79
8− def get_type
9− link_li = entry_link.parent
10− type_links_list = link_li.parent
11− current_type = type_links_list.parent
10+ TYPE_BY_DIRECTORY = {
11+ 'get-started' => 'Getting Started',
12+ 'concepts' => 'Concepts',
13+ 'guides' => 'Guides',
14+ 'api' => 'API',
15+ 'configuration' => 'Configuration',
16+ 'loaders' => 'Loaders',
17+ 'plugins' => 'Plugins'
18+ }
1219
13− # current type is a
14− # <li>
15− # TYPE
16− # <li> <ul> .. links .. </ul> </li>
17− # </li>
18− #
19− # Grab the first children (which is the text nodes whose contains the type)
20− current_type.children.first.content.strip.titleize
20+ def get_type
21+ TYPE_BY_DIRECTORY[slug.split('/').first]
2122 end
2223
23− private
24−
25− def entry_link
26− at_css("a[href='#{self.path}']")
24+ def additional_entries
25+ if slug.start_with?('configuration')
26+ css('h2[id] code').map do |node|
27+ [node.content, node.parent['id']]
28+ end
29+ elsif slug.start_with?('api')
30+ css('.header[id] code').each_with_object [] do |node, entries|
31+ next if node.previous.try(:content).present?
32+ entries << ["#{self.name}: #{node.content.sub(/\(.*\)/, '()')}", node.parent['id']]
33+ end
34+ else
35+ []
36+ end
2737 end
2838 end
2939 end
lib/docs/filters/webpack/entries_old.rb+31−0
@@ -0,0 +1,31 @@
1+module Docs
2+ class Webpack
3+ class EntriesOldFilter < Docs::EntriesFilter
4+ def get_name
5+ entry_link.content
6+ end
7+
8+ def get_type
9+ link_li = entry_link.parent
10+ type_links_list = link_li.parent
11+ current_type = type_links_list.parent
12+
13+ # current type is a
14+ # <li>
15+ # TYPE
16+ # <li> <ul> .. links .. </ul> </li>
17+ # </li>
18+ #
19+ # Grab the first children (which is the text nodes whose contains the type)
20+ current_type.children.first.content.strip.titleize
21+ end
22+
23+ private
24+
25+ def entry_link
26+ at_css("a[href='#{self.path}']")
27+ end
28+ end
29+ end
30+end
31+
lib/docs/scrapers/webpack.rb+63−14
@@ -2,23 +2,72 @@ module Docs · 1 unmodified line
22 class Webpack < UrlScraper
33 self.name = 'webpack'
44 self.type = 'webpack'
5− self.release = '1.13.2'
6− self.base_url = 'https://webpack.github.io/docs/'
7− self.links = {
8− home: 'https://webpack.github.io/',
9− code: 'https://github.com/webpack/webpack'
10− }
115
12− html_filters.push 'webpack/entries', 'webpack/clean_html', 'title'
6+ version '2' do
7+ self.release = '2.2.0'
8+ self.base_url = 'https://webpack.js.org/'
9+ self.root_path = 'get-started/'
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+ }
1322
14− options[:title] = false
15− options[:root_title] = 'webpack'
23+ html_filters.push 'webpack/clean_html', 'webpack/entries'
1624
17− options[:skip] = %w(list-of-tutorials.html examples.html changelog.html ideas.html roadmap.html)
25+ options[:container] = '.page'
26+ options[:trailing_slash] = true
27+ options[:only_patterns] = [
28+ /\Aget-started\//,
29+ /\Aconcepts\//,
30+ /\Aguides\//,
31+ /\Aapi\//,
32+ /\Aconfiguration\//,
33+ /\Aloaders\//,
34+ /\Aplugins\//
35+ ]
1836
19− options[:attribution] = <<-HTML
20− &copy; 2012&ndash;2016 Tobias Koppers<br>
21− Licensed under the MIT License.
22− HTML
37+ options[:attribution] = <<-HTML
38+ &copy; 2012&ndash;2016 Tobias Koppers<br>
39+ Licensed under the Creative Commons Attribution License 4.0.
40+ HTML
41+
42+ ([self.root_path] + self.initial_paths).each do |path|
43+ stub(path) do
44+ capybara = load_capybara_selenium
45+ capybara.app_host = self.base_url.origin
46+ capybara.visit("#{self.base_url}#{path}")
47+ capybara.execute_script('return document.body.innerHTML')
48+ end
49+ end
50+ end
51+
52+ version '1' do
53+ self.release = '1.13.2'
54+ self.base_url = 'https://webpack.github.io/docs/'
55+ self.links = {
56+ home: 'https://webpack.github.io/',
57+ code: 'https://github.com/webpack/webpack'
58+ }
59+
60+ html_filters.push 'webpack/entries_old', 'webpack/clean_html_old', 'title'
61+
62+ options[:title] = false
63+ options[:root_title] = 'webpack'
64+
65+ options[:skip] = %w(list-of-tutorials.html examples.html changelog.html ideas.html roadmap.html)
66+
67+ options[:attribution] = <<-HTML
68+ &copy; 2012&ndash;2016 Tobias Koppers<br>
69+ Licensed under the MIT License.
70+ HTML
71+ end
2372 end
2473 end
public/icons/docs/webpack/16.png+0−0

Binary file not shown.

public/icons/docs/webpack/16@2x.png+0−0

Binary file not shown.

public/icons/docs/webpack/SOURCE+1−0
@@ -0,0 +1 @@
1+https://github.com/webpack/media