浏览代码

Webpack 1.9 documentation

Yosi Attias 10 年之前
父节点
当前提交
ba165ae8b4

+ 1 - 0
assets/stylesheets/application-dark.css.scss

@@ -67,5 +67,6 @@
         'pages/socketio',
         'pages/sphinx',
         'pages/underscore',
+        'pages/webpack',
         'pages/yard',
         'pages/yii';

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -68,4 +68,5 @@
         'pages/sphinx',
         'pages/underscore',
         'pages/yard',
+        'pages/webpack',
         'pages/yii';

+ 55 - 0
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
+  }
+}

+ 46 - 0
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

+ 41 - 0
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 
+        # <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
+
+      
+      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
+

+ 17 - 0
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
+      &copy; 2012&ndash;2015 Tobias Koppers<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

二进制
public/icons/docs/webpack/16.png


二进制
public/icons/docs/webpack/16@2x.png