Add webpack 2 documentation

This commit is contained in:
Thibaut Courouble 2017-01-22 11:53:28 -05:00
parent d4d1b37626
commit bfe83138e3
16 changed files with 205 additions and 67 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

After

Width:  |  Height:  |  Size: 138 KiB

View file

@ -590,10 +590,10 @@ credits = [
'MIT',
'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
], [
'Webpack',
'webpack',
'2012-2016 Tobias Koppers',
'MIT',
'https://raw.githubusercontent.com/webpack/webpack/master/LICENSE'
'CC BY',
'https://creativecommons.org/licenses/by/4.0/'
], [
'Yarn',
'2016-2017 Yarn Contributors',

View file

@ -92,5 +92,6 @@
'pages/underscore',
'pages/vagrant',
'pages/vue',
'pages/webpack',
'pages/yard',
'pages/yii';

View file

@ -92,5 +92,6 @@
'pages/underscore',
'pages/vagrant',
'pages/vue',
'pages/webpack',
'pages/yard',
'pages/yii';

View file

@ -139,7 +139,7 @@
._icon-npm:before { background-position: -8rem -7rem; }
._icon-apache_http_server:before { background-position: -9rem -7rem; }
._icon-drupal:before { background-position: 0 -8rem; }
._icon-webpack:before { background-position: -1rem -8rem; @extend %darkIconFix !optional; }
._icon-webpack:before { background-position: -1rem -8rem; }
._icon-phaser:before { background-position: -2rem -8rem; }
._icon-vue:before { background-position: -3rem -8rem; }
._icon-opentsdb:before { background-position: -4rem -8rem; }

View file

@ -12,7 +12,7 @@
h1, h2, h3 { margin-left: 0; }
}
p > code, li > code, td > code { @extend %label; }
p > code, li > code, td > code, blockquote > code { @extend %label; }
blockquote { @extend %note; }
blockquote > h4, blockquote > h5 { margin-top: .25rem; }
}
@ -37,7 +37,6 @@
._redux,
._sinon,
._typescript,
._webpack,
._yarn {
@extend %simple;
}

View file

@ -0,0 +1,5 @@
._webpack {
@extend %simple;
blockquote.tip { @extend %note-blue; }
}

View file

@ -2,38 +2,40 @@ module Docs
class Webpack
class CleanHtmlFilter < Filter
def call
root_page? ? root : other
@doc = at_css('.page__content')
at_css('h1').content = 'webpack' if root_page?
css('h3').each do |node|
node.name = 'h2'
end unless at_css('h2')
css('.anchor[id]').each do |node|
node.parent['id'] = node['id']
node.remove
end
css('hr', '.page__edit', 'hr + h3:contains("Contributors")', 'hr + h2:contains("Contributors")',
'.contributors', '.icon-link', '#maintainers.header', '#maintainers.header + table',
'#maintainer.header', '#maintainer.header + table').remove
css('> div', '.tip-content', '.header span').each do |node|
node.before(node.children).remove
end
css('> h1:first-child + h1').remove
css('.code-details-summary-span').each do |node|
node.content = node.content.remove(' (click to show)')
end
css('pre > code').each do |node|
node.parent['data-language'] = node['class'][/lang-(\w+)/, 1].sub('jsx', 'js') if node['class']
node.parent.content = node.parent.content
end
doc
end
def root
@doc = at_css(".container > .row > .col-md-9")
# Remove all introdcution before the hr,
# The introduction about the documentation site which isn't relevant
# in devdocs.
hr_index = doc.children.find_index { |node| node.name == "hr" }
doc.children[0..hr_index].each(&:remove)
end
def other
css('h1, h2, h3, h4').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
# Re-create the header element
at_css("#wiki").child.before("<h1>#{at_css("#wikititle").content.titleize}</h1>")
@doc = at_css("#wiki")
css('.contents', 'a.anchor', 'hr').remove
css('pre').each do |node|
node.content = node.content
node['data-language'] = 'javascript'
end
end
end
end
end

View file

@ -0,0 +1,39 @@
module Docs
class Webpack
class CleanHtmlOldFilter < Filter
def call
root_page? ? root : other
doc
end
def root
@doc = at_css(".container > .row > .col-md-9")
# Remove all introdcution before the hr,
# The introduction about the documentation site which isn't relevant
# in devdocs.
hr_index = doc.children.find_index { |node| node.name == "hr" }
doc.children[0..hr_index].each(&:remove)
end
def other
css('h1, h2, h3, h4').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i + 1 }
end
# Re-create the header element
at_css("#wiki").child.before("<h1>#{at_css("#wikititle").content.titleize}</h1>")
@doc = at_css("#wiki")
css('.contents', 'a.anchor', 'hr').remove
css('pre').each do |node|
node.content = node.content
node['data-language'] = 'javascript'
end
end
end
end
end

View file

@ -2,28 +2,38 @@ module Docs
class Webpack
class EntriesFilter < Docs::EntriesFilter
def get_name
entry_link.content
name = at_css('h1').content
name.sub! ' - ', ': '
name
end
TYPE_BY_DIRECTORY = {
'get-started' => 'Getting Started',
'concepts' => 'Concepts',
'guides' => 'Guides',
'api' => 'API',
'configuration' => 'Configuration',
'loaders' => 'Loaders',
'plugins' => 'Plugins'
}
def get_type
link_li = entry_link.parent
type_links_list = link_li.parent
current_type = type_links_list.parent
# current type is a
# <li>
# TYPE
# <li> <ul> .. links .. </ul> </li>
# </li>
#
# Grab the first children (which is the text nodes whose contains the type)
current_type.children.first.content.strip.titleize
TYPE_BY_DIRECTORY[slug.split('/').first]
end
private
def entry_link
at_css("a[href='#{self.path}']")
def additional_entries
if slug.start_with?('configuration')
css('h2[id] code').map do |node|
[node.content, node.parent['id']]
end
elsif slug.start_with?('api')
css('.header[id] code').each_with_object [] do |node, entries|
next if node.previous.try(:content).present?
entries << ["#{self.name}: #{node.content.sub(/\(.*\)/, '()')}", node.parent['id']]
end
else
[]
end
end
end
end

View file

@ -0,0 +1,31 @@
module Docs
class Webpack
class EntriesOldFilter < Docs::EntriesFilter
def get_name
entry_link.content
end
def get_type
link_li = entry_link.parent
type_links_list = link_li.parent
current_type = type_links_list.parent
# current type is a
# <li>
# TYPE
# <li> <ul> .. links .. </ul> </li>
# </li>
#
# Grab the first children (which is the text nodes whose contains the type)
current_type.children.first.content.strip.titleize
end
private
def entry_link
at_css("a[href='#{self.path}']")
end
end
end
end

View file

@ -2,23 +2,72 @@ module Docs
class Webpack < UrlScraper
self.name = 'webpack'
self.type = 'webpack'
self.release = '1.13.2'
self.base_url = 'https://webpack.github.io/docs/'
self.links = {
home: 'https://webpack.github.io/',
code: 'https://github.com/webpack/webpack'
}
html_filters.push 'webpack/entries', 'webpack/clean_html', 'title'
version '2' do
self.release = '2.2.0'
self.base_url = 'https://webpack.js.org/'
self.root_path = 'get-started/'
self.initial_paths = %w(
concepts/
guides/
api/
configuration/
loaders/
plugins/
)
self.links = {
home: 'https://webpack.js.org/',
code: 'https://github.com/webpack/webpack'
}
options[:title] = false
options[:root_title] = 'webpack'
html_filters.push 'webpack/clean_html', 'webpack/entries'
options[:skip] = %w(list-of-tutorials.html examples.html changelog.html ideas.html roadmap.html)
options[:container] = '.page'
options[:trailing_slash] = true
options[:only_patterns] = [
/\Aget-started\//,
/\Aconcepts\//,
/\Aguides\//,
/\Aapi\//,
/\Aconfiguration\//,
/\Aloaders\//,
/\Aplugins\//
]
options[:attribution] = <<-HTML
&copy; 2012&ndash;2016 Tobias Koppers<br>
Licensed under the MIT License.
HTML
options[:attribution] = <<-HTML
&copy; 2012&ndash;2016 Tobias Koppers<br>
Licensed under the Creative Commons Attribution License 4.0.
HTML
([self.root_path] + self.initial_paths).each do |path|
stub(path) do
capybara = load_capybara_selenium
capybara.app_host = self.base_url.origin
capybara.visit("#{self.base_url}#{path}")
capybara.execute_script('return document.body.innerHTML')
end
end
end
version '1' do
self.release = '1.13.2'
self.base_url = 'https://webpack.github.io/docs/'
self.links = {
home: 'https://webpack.github.io/',
code: 'https://github.com/webpack/webpack'
}
html_filters.push 'webpack/entries_old', 'webpack/clean_html_old', 'title'
options[:title] = false
options[:root_title] = 'webpack'
options[:skip] = %w(list-of-tutorials.html examples.html changelog.html ideas.html roadmap.html)
options[:attribution] = <<-HTML
&copy; 2012&ndash;2016 Tobias Koppers<br>
Licensed under the MIT License.
HTML
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 579 B

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1 @@
https://github.com/webpack/media