diff --git a/assets/images/docs.png b/assets/images/docs.png index d6acb42e..1f47bf6a 100644 Binary files a/assets/images/docs.png and b/assets/images/docs.png differ diff --git a/assets/images/docs@2x.png b/assets/images/docs@2x.png index e5122bd8..2bd7095b 100644 Binary files a/assets/images/docs@2x.png and b/assets/images/docs@2x.png differ diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 67476279..d9919bfd 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -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', diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 36469157..99b7d431 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -92,5 +92,6 @@ 'pages/underscore', 'pages/vagrant', 'pages/vue', + 'pages/webpack', 'pages/yard', 'pages/yii'; diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 879b43f2..da15c2b5 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -92,5 +92,6 @@ 'pages/underscore', 'pages/vagrant', 'pages/vue', + 'pages/webpack', 'pages/yard', 'pages/yii'; diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index c09dbab9..6e807c1e 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -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; } diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index 03087924..48279b8f 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -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; } diff --git a/assets/stylesheets/pages/_webpack.scss b/assets/stylesheets/pages/_webpack.scss new file mode 100644 index 00000000..487e0269 --- /dev/null +++ b/assets/stylesheets/pages/_webpack.scss @@ -0,0 +1,5 @@ +._webpack { + @extend %simple; + + blockquote.tip { @extend %note-blue; } +} diff --git a/lib/docs/filters/webpack/clean_html.rb b/lib/docs/filters/webpack/clean_html.rb index 05ed77d3..71e1c6de 100644 --- a/lib/docs/filters/webpack/clean_html.rb +++ b/lib/docs/filters/webpack/clean_html.rb @@ -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("

#{at_css("#wikititle").content.titleize}

") - - @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 diff --git a/lib/docs/filters/webpack/clean_html_old.rb b/lib/docs/filters/webpack/clean_html_old.rb new file mode 100644 index 00000000..424bbd05 --- /dev/null +++ b/lib/docs/filters/webpack/clean_html_old.rb @@ -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("

#{at_css("#wikititle").content.titleize}

") + + @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 diff --git a/lib/docs/filters/webpack/entries.rb b/lib/docs/filters/webpack/entries.rb index 4d139dbe..8d834aac 100644 --- a/lib/docs/filters/webpack/entries.rb +++ b/lib/docs/filters/webpack/entries.rb @@ -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 - #
  • - # TYPE - #
  • - # - # - # 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 diff --git a/lib/docs/filters/webpack/entries_old.rb b/lib/docs/filters/webpack/entries_old.rb new file mode 100644 index 00000000..705ca387 --- /dev/null +++ b/lib/docs/filters/webpack/entries_old.rb @@ -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 + #
  • + # TYPE + #
  • + # + # + # 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 + diff --git a/lib/docs/scrapers/webpack.rb b/lib/docs/scrapers/webpack.rb index e9da9c0a..174bceb0 100644 --- a/lib/docs/scrapers/webpack.rb +++ b/lib/docs/scrapers/webpack.rb @@ -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 - © 2012–2016 Tobias Koppers
    - Licensed under the MIT License. - HTML + options[:attribution] = <<-HTML + © 2012–2016 Tobias Koppers
    + 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 + © 2012–2016 Tobias Koppers
    + Licensed under the MIT License. + HTML + end end end diff --git a/public/icons/docs/webpack/16.png b/public/icons/docs/webpack/16.png index 7bbd5a95..e218017f 100644 Binary files a/public/icons/docs/webpack/16.png and b/public/icons/docs/webpack/16.png differ diff --git a/public/icons/docs/webpack/16@2x.png b/public/icons/docs/webpack/16@2x.png index c050a8c2..2944e117 100644 Binary files a/public/icons/docs/webpack/16@2x.png and b/public/icons/docs/webpack/16@2x.png differ diff --git a/public/icons/docs/webpack/SOURCE b/public/icons/docs/webpack/SOURCE new file mode 100644 index 00000000..bc76a9fd --- /dev/null +++ b/public/icons/docs/webpack/SOURCE @@ -0,0 +1 @@ +https://github.com/webpack/media