Explorar o código

Finish Homebrew scraper

Thibaut Courouble %!s(int64=8) %!d(string=hai) anos
pai
achega
b8c8a42f86

BIN=BIN
assets/images/docs-2.png


BIN=BIN
assets/images/docs-2@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2017-11-26",
-    "New documentations: <a href=\"/bluebird/\">Bluebird</a> and <a href=\"/eslint/\">ESLint</a>"
+    "New documentations: <a href=\"/bluebird/\">Bluebird</a>, <a href=\"/eslint/\">ESLint</a> and <a href=\"/homebrew/\">Homebrew</a>"
   ], [
     "2017-11-18",
     "Added print & PDF stylesheet.\nFeedback welcome on <a href=\"https://twitter.com/DevDocs\" target=\"_blank\" rel=\"noopener\">Twitter</a> and <a href=\"https://github.com/Thibaut/devdocs\" target=\"_blank\" rel=\"noopener\">GitHub</a>."

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -302,6 +302,11 @@ credits = [
     '2005-2016 Haxe Foundation',
     'MIT',
     'http://haxe.org/foundation/open-source.html'
+  ], [
+    'Homebrew',
+    '2009-present Homebrew contributors',
+    'BSD',
+    'https://raw.githubusercontent.com/Homebrew/brew/master/LICENSE.txt'
   ], [
     'Immutable.js',
     '2014-2016 Facebook, Inc.',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -166,3 +166,4 @@
 ._icon-d:before             { background-position: -7rem -2rem; @extend %doc-icon-2; }
 ._icon-bluebird:before      { background-position: -8rem -2rem; @extend %doc-icon-2; }
 ._icon-eslint:before        { background-position: -9rem -2rem; @extend %doc-icon-2; }
+._icon-homebrew:before      { background-position: 0 -3rem; @extend %doc-icon-2; }

+ 0 - 9
lib/docs/filters/brew/clean_html.rb

@@ -1,9 +0,0 @@
-module Docs
-  class Brew
-    class CleanHtmlFilter < Filter
-      def call
-        doc
-      end
-    end
-  end
-end

+ 0 - 14
lib/docs/filters/brew/entries.rb

@@ -1,14 +0,0 @@
-module Docs
-  class Brew
-    class EntriesFilter < Docs::EntriesFilter
-      def get_name
-        at_css('h1').content
-      end
-
-      def get_type
-        name
-      end
-
-    end
-  end
-end

+ 19 - 0
lib/docs/filters/homebrew/clean_html.rb

@@ -0,0 +1,19 @@
+module Docs
+  class Homebrew
+    class CleanHtmlFilter < Filter
+      def call
+        css('hr')
+
+        css('div.highlighter-rouge').each do |node|
+          lang = node['class'][/language-(\w+)/, 1]
+          node['data-language'] = lang if lang
+          node.content = node.content.strip
+          node.name = 'pre'
+          node.remove_attribute('class')
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 32 - 0
lib/docs/filters/homebrew/entries.rb

@@ -0,0 +1,32 @@
+module Docs
+  class Homebrew
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content.strip
+        name.remove! %r{\(.*}
+        name
+      end
+
+      CONTRIBUTOR_SLUGS = %w(
+        How-To-Open-a-Homebrew-Pull-Request
+        Formula-Cookbook
+        Acceptable-Formulae
+        Versions
+        Node-for-Formula-Authors
+        Python-for-Formula-Authors
+        Migrating-A-Formula-To-A-Tap
+        Rename-A-Formula
+        How-to-Create-and-Maintain-a-Tap
+        Brew-Test-Bot
+        Prose-Style-Guidelines)
+
+      def get_type
+        if CONTRIBUTOR_SLUGS.include?(slug)
+          'Contributors'
+        else
+          'Users'
+        end
+      end
+    end
+  end
+end

+ 0 - 22
lib/docs/scrapers/brew.rb

@@ -1,22 +0,0 @@
-module Docs
-  class Brew < UrlScraper
-    self.name = 'Homebrew'
-    self.type = 'brew'
-    self.release = '1.3.6'
-    self.base_url = 'https://docs.brew.sh'
-    self.root_path = '/'
-    self.links = {
-      home: 'https://brew.sh',
-      code: 'https://github.com/Homebrew/brew'
-    }
-
-    options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page' }    
-
-    html_filters.push 'brew/entries', 'brew/clean_html'
-
-    options[:attribution] = <<-HTML
-      Homebrew was created by Max Howell. <br>
-      Licensed under the BSD 2-Clause License.
-    HTML
-  end
-end

+ 24 - 0
lib/docs/scrapers/homebrew.rb

@@ -0,0 +1,24 @@
+module Docs
+  class Homebrew < UrlScraper
+    self.name = 'Homebrew'
+    self.type = 'simple'
+    self.release = '1.3.6'
+    self.base_url = 'https://docs.brew.sh/'
+    self.links = {
+      home: 'https://brew.sh',
+      code: 'https://github.com/Homebrew/brew'
+    }
+
+    html_filters.push 'homebrew/entries', 'homebrew/clean_html'
+
+    options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page' }
+
+    options[:skip_patterns] = [/maintainer/i, /core\-contributor/i]
+    options[:skip] = %w(Kickstarter-Supporters.html)
+
+    options[:attribution] = <<-HTML
+      &copy; 2009&ndash;present Homebrew contributors<br>
+      Licensed under the BSD 2-Clause License.
+    HTML
+  end
+end

BIN=BIN
public/icons/docs/brew/16.png


BIN=BIN
public/icons/docs/brew/16@2x.png


BIN=BIN
public/icons/docs/brew/SOURCE


BIN=BIN
public/icons/docs/homebrew/16.png


BIN=BIN
public/icons/docs/homebrew/16@2x.png


+ 1 - 0
public/icons/docs/homebrew/SOURCE

@@ -0,0 +1 @@
+https://github.com/Homebrew/brew/tree/master/docs/img