diff --git a/assets/stylesheets/application-dark.css.scss b/assets/stylesheets/application-dark.css.scss index 1968dceb..403f5561 100644 --- a/assets/stylesheets/application-dark.css.scss +++ b/assets/stylesheets/application-dark.css.scss @@ -67,5 +67,6 @@ 'pages/socketio', 'pages/sphinx', 'pages/underscore', + 'pages/webpack', 'pages/yard', 'pages/yii'; diff --git a/assets/stylesheets/application.css.scss b/assets/stylesheets/application.css.scss index 4a8f307f..b11cfb52 100644 --- a/assets/stylesheets/application.css.scss +++ b/assets/stylesheets/application.css.scss @@ -68,4 +68,5 @@ 'pages/sphinx', 'pages/underscore', 'pages/yard', + 'pages/webpack', 'pages/yii'; diff --git a/assets/stylesheets/pages/_webpack.scss b/assets/stylesheets/pages/_webpack.scss new file mode 100644 index 00000000..75dc49fe --- /dev/null +++ b/assets/stylesheets/pages/_webpack.scss @@ -0,0 +1,55 @@ +._webpack { + > h2 { @extend %block-heading; } + > h3 { @extend %block-label, %label-blue; } + > h4 { font-size: 1em; } + + /* + Copied from the original webpack css + https://webpack.github.io/docs/css/doc.css + */ + code .comment { + color: #998; + font-style: italic + } + + code .keyword { + color: #333; + font-weight: 700 + } + + code .number { + color: #099 + } + + code .string { + color: #d14 + } + + code .tag { + color: navy; + font-weight: 400 + } + + code .attribute { + color: teal + } + + code .regexp { + color: #009926 + } + + code .preprocessor { + color: #999; + font-weight: 700 + } + + code .deletion { + background: #fdd; + display: block + } + + code .addition { + background: #dfd; + display: block + } +} diff --git a/lib/docs/filters/webpack/clean_html.rb b/lib/docs/filters/webpack/clean_html.rb new file mode 100644 index 00000000..ebb43264 --- /dev/null +++ b/lib/docs/filters/webpack/clean_html.rb @@ -0,0 +1,46 @@ +module Docs + class Webpack + class CleanHtmlFilter < 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) + + # Add a page header :) + page_header_node = Nokogiri::XML::Node.new "h1", @doc + page_header_node.content = "Webpack" + @doc.children.first.add_previous_sibling page_header_node + end + + + def other + # Re-create the header element + page_header = at_css("#wikititle").content.upcase + page_header_node = Nokogiri::XML::Node.new "h1", @doc + page_header_node.content = page_header + + # Change the scope of the page + @doc = at_css("#wiki") + + # Add the page header + @doc.children.first.add_previous_sibling page_header_node + + # Remove the sidebar links in each page + css(".contents").remove + + # Remove all anchors + css("a.anchor").remove + + end + end + end +end diff --git a/lib/docs/filters/webpack/entries.rb b/lib/docs/filters/webpack/entries.rb new file mode 100644 index 00000000..cdbf18ad --- /dev/null +++ b/lib/docs/filters/webpack/entries.rb @@ -0,0 +1,41 @@ +module Docs + class Webpack + class EntriesFilter < Docs::EntriesFilter + def get_name + entry_link.content.strip.titleize + 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 + + + def additional_entries + return [] unless root_page? + + css('.sidebar a').each_with_object [] do |link, entries| + name = link.content.strip + entries << [name, link['href']] + end + 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 new file mode 100644 index 00000000..ada1717c --- /dev/null +++ b/lib/docs/scrapers/webpack.rb @@ -0,0 +1,17 @@ +module Docs + class Webpack < UrlScraper + self.name = 'Webpack' + self.type = 'webpack' + self.version = '1.9' + self.base_url = 'https://webpack.github.io/docs/' + self.root_path = 'index.html' + + html_filters.push 'webpack/entries', 'webpack/clean_html' + + + options[:attribution] = <<-HTML + © 2012–2015 Tobias Koppers
    + Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/webpack/16.png b/public/icons/docs/webpack/16.png new file mode 100644 index 00000000..9104d1e9 Binary files /dev/null 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 new file mode 100644 index 00000000..5339992e Binary files /dev/null and b/public/icons/docs/webpack/16@2x.png differ