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
590 'MIT',590 'MIT',
591 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'591 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
592 ], [592 ], [
593 'Webpack',593 'webpack',
594 '2012-2016 Tobias Koppers',594 '2012-2016 Tobias Koppers',
595 'MIT',595 'CC BY',
596 'https://raw.githubusercontent.com/webpack/webpack/master/LICENSE'596 'https://creativecommons.org/licenses/by/4.0/'
597 ], [597 ], [
598 'Yarn',598 'Yarn',
599 '2016-2017 Yarn Contributors',599 '2016-2017 Yarn Contributors',
assets/stylesheets/application-dark.css.scss+1−0
@@ -92,5 +92,6 @@ · 91 unmodified lines
92 'pages/underscore',92 'pages/underscore',
93 'pages/vagrant',93 'pages/vagrant',
94 'pages/vue',94 'pages/vue',
95 'pages/webpack',
95 'pages/yard',96 'pages/yard',
96 'pages/yii';97 'pages/yii';
assets/stylesheets/application.css.scss+1−0
@@ -92,5 +92,6 @@ · 91 unmodified lines
92 'pages/underscore',92 'pages/underscore',
93 'pages/vagrant',93 'pages/vagrant',
94 'pages/vue',94 'pages/vue',
95 'pages/webpack',
95 'pages/yard',96 'pages/yard',
96 'pages/yii';97 'pages/yii';
assets/stylesheets/global/_icons.scss+1−1
@@ -139,7 +139,7 @@ · 138 unmodified lines
139._icon-npm:before { background-position: -8rem -7rem; }139._icon-npm:before { background-position: -8rem -7rem; }
140._icon-apache_http_server:before { background-position: -9rem -7rem; }140._icon-apache_http_server:before { background-position: -9rem -7rem; }
141._icon-drupal:before { background-position: 0 -8rem; }141._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; }
143._icon-phaser:before { background-position: -2rem -8rem; }143._icon-phaser:before { background-position: -2rem -8rem; }
144._icon-vue:before { background-position: -3rem -8rem; }144._icon-vue:before { background-position: -3rem -8rem; }
145._icon-opentsdb:before { background-position: -4rem -8rem; }145._icon-opentsdb:before { background-position: -4rem -8rem; }
assets/stylesheets/pages/_simple.scss+1−2
@@ -12,7 +12,7 @@ · 11 unmodified lines
12 h1, h2, h3 { margin-left: 0; }12 h1, h2, h3 { margin-left: 0; }
13 }13 }
14 14
15 p > code, li > code, td > code { @extend %label; }15 p > code, li > code, td > code, blockquote > code { @extend %label; }
16 blockquote { @extend %note; }16 blockquote { @extend %note; }
17 blockquote > h4, blockquote > h5 { margin-top: .25rem; }17 blockquote > h4, blockquote > h5 { margin-top: .25rem; }
18}18}
@@ -37,7 +37,6 @@ · 18 unmodified lines
37._redux,37._redux,
38._sinon,38._sinon,
39._typescript,39._typescript,
40._webpack,
41._yarn {40._yarn {
42 @extend %simple;41 @extend %simple;
43}42}
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
2 class Webpack2 class Webpack
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 root_page? ? root : other5 @doc = at_css('.page__content')
6 doc
7 end
8 6
9 def root7 at_css('h1').content = 'webpack' if root_page?
10 @doc = at_css(".container > .row > .col-md-9")
11 8
12 # Remove all introdcution before the hr,9 css('h3').each do |node|
13 # The introduction about the documentation site which isn't relevant10 node.name = 'h2'
14 # in devdocs.11 end unless at_css('h2')
15 hr_index = doc.children.find_index { |node| node.name == "hr" }
16 doc.children[0..hr_index].each(&:remove)
17 end
18 12
19 13 css('.anchor[id]').each do |node|
20 def other14 node.parent['id'] = node['id']
21 css('h1, h2, h3, h4').each do |node|15 node.remove
22 node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
23 end16 end
24 17
25 # Re-create the header element18 css('hr', '.page__edit', 'hr + h3:contains("Contributors")', 'hr + h2:contains("Contributors")',
26 at_css("#wiki").child.before("<h1>#{at_css("#wikititle").content.titleize}</h1>")19 '.contributors', '.icon-link', '#maintainers.header', '#maintainers.header + table',
20 '#maintainer.header', '#maintainer.header + table').remove
27 21
28 @doc = at_css("#wiki")22 css('> div', '.tip-content', '.header span').each do |node|
23 node.before(node.children).remove
24 end
29 25
30 css('.contents', 'a.anchor', 'hr').remove26 css('> h1:first-child + h1').remove
31 27
32 css('pre').each do |node|28 css('.code-details-summary-span').each do |node|
33 node.content = node.content29 node.content = node.content.remove(' (click to show)')
34 node['data-language'] = 'javascript'
35 end30 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
36 end38 end
37 end39 end
38 end40 end
lib/docs/filters/webpack/clean_html_old.rb+39−0
@@ -0,0 +1,39 @@
1module 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
39end
lib/docs/filters/webpack/entries.rb+27−17
@@ -2,28 +2,38 @@ module Docs · 1 unmodified line
2 class Webpack2 class Webpack
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 entry_link.content5 name = at_css('h1').content
6 name.sub! ' - ', ': '
7 name
6 end8 end
7 9
8 def get_type10 TYPE_BY_DIRECTORY = {
9 link_li = entry_link.parent11 'get-started' => 'Getting Started',
10 type_links_list = link_li.parent12 'concepts' => 'Concepts',
11 current_type = type_links_list.parent13 'guides' => 'Guides',
14 'api' => 'API',
15 'configuration' => 'Configuration',
16 'loaders' => 'Loaders',
17 'plugins' => 'Plugins'
18 }
12 19
13 # current type is a20 def get_type
14 # <li>21 TYPE_BY_DIRECTORY[slug.split('/').first]
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 end22 end
22 23
23 private24 def additional_entries
24 25 if slug.start_with?('configuration')
25 def entry_link26 css('h2[id] code').map do |node|
26 at_css("a[href='#{self.path}']")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
27 end37 end
28 end38 end
29 end39 end
lib/docs/filters/webpack/entries_old.rb+31−0
@@ -0,0 +1,31 @@
1module 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
30end
31
lib/docs/scrapers/webpack.rb+63−14
@@ -2,23 +2,72 @@ module Docs · 1 unmodified line
2 class Webpack < UrlScraper2 class Webpack < UrlScraper
3 self.name = 'webpack'3 self.name = 'webpack'
4 self.type = 'webpack'4 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 }
11 5
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 }
13 22
14 options[:title] = false23 html_filters.push 'webpack/clean_html', 'webpack/entries'
15 options[:root_title] = 'webpack'
16 24
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 ]
18 36
19 options[:attribution] = <<-HTML37 options[:attribution] = <<-HTML
20 &copy; 2012&ndash;2016 Tobias Koppers<br>38 &copy; 2012&ndash;2016 Tobias Koppers<br>
21 Licensed under the MIT License.39 Licensed under the Creative Commons Attribution License 4.0.
22 HTML40 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
23 end72 end
24end73end
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 @@
1https://github.com/webpack/media