History

Finish Homebrew scraper

Thibaut Courouble committed 8 years ago

Commit b8c8a421 parent 438fa8e17 files · +76 −39Browse files

Unified · Split

17 files
  1. assets/images/docs-2.png +0 −0
  2. assets/images/docs-2@2x.png +0 −0
  3. assets/javascripts/news.json +1 −1
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/brew/clean_html.rb +0 −9
  7. lib/docs/filters/brew/entries.rb +0 −14
  8. lib/docs/filters/homebrew/clean_html.rb +19 −0
  9. lib/docs/filters/homebrew/entries.rb +32 −0
  10. lib/docs/scrapers/brew.rb +0 −22
  11. lib/docs/scrapers/homebrew.rb +24 −0
  12. public/icons/docs/brew/16.png +0 −0
  13. public/icons/docs/brew/16@2x.png +0 −0
  14. public/icons/docs/brew/SOURCE +0 −0
  15. public/icons/docs/homebrew/16.png +0 −0
  16. public/icons/docs/homebrew/16@2x.png +0 −0
  17. public/icons/docs/homebrew/SOURCE +1 −0
assets/images/docs-2.png+0−0

Binary file not shown.

assets/images/docs-2@2x.png+0−0

Binary file not shown.

assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
11 [
22 [
33 "2017-11-26",
4− "New documentations: <a href=\"/bluebird/\">Bluebird</a> and <a href=\"/eslint/\">ESLint</a>"
4+ "New documentations: <a href=\"/bluebird/\">Bluebird</a>, <a href=\"/eslint/\">ESLint</a> and <a href=\"/homebrew/\">Homebrew</a>"
55 ], [
66 "2017-11-18",
77 "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>."
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -302,6 +302,11 @@ credits = [ · 301 unmodified lines
302302 '2005-2016 Haxe Foundation',
303303 'MIT',
304304 'http://haxe.org/foundation/open-source.html'
305+ ], [
306+ 'Homebrew',
307+ '2009-present Homebrew contributors',
308+ 'BSD',
309+ 'https://raw.githubusercontent.com/Homebrew/brew/master/LICENSE.txt'
305310 ], [
306311 'Immutable.js',
307312 '2014-2016 Facebook, Inc.',
assets/stylesheets/global/_icons.scss+1−0
@@ -166,3 +166,4 @@ · 165 unmodified lines
166166 ._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }
167167 ._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }
168168 ._icon-eslint:before { background-position: -9rem -2rem; @extend %doc-icon-2; }
169+._icon-homebrew:before { background-position: 0 -3rem; @extend %doc-icon-2; }
lib/docs/filters/brew/clean_html.rb+0−9
@@ -1,9 +0,0 @@
1−module Docs
2− class Brew
3− class CleanHtmlFilter < Filter
4− def call
5− doc
6− end
7− end
8− end
9−end
lib/docs/filters/brew/entries.rb+0−14
@@ -1,14 +0,0 @@
1−module Docs
2− class Brew
3− class EntriesFilter < Docs::EntriesFilter
4− def get_name
5− at_css('h1').content
6− end
7−
8− def get_type
9− name
10− end
11−
12− end
13− end
14−end
lib/docs/filters/homebrew/clean_html.rb+19−0
@@ -0,0 +1,19 @@
1+module Docs
2+ class Homebrew
3+ class CleanHtmlFilter < Filter
4+ def call
5+ css('hr')
6+
7+ css('div.highlighter-rouge').each do |node|
8+ lang = node['class'][/language-(\w+)/, 1]
9+ node['data-language'] = lang if lang
10+ node.content = node.content.strip
11+ node.name = 'pre'
12+ node.remove_attribute('class')
13+ end
14+
15+ doc
16+ end
17+ end
18+ end
19+end
lib/docs/filters/homebrew/entries.rb+32−0
@@ -0,0 +1,32 @@
1+module Docs
2+ class Homebrew
3+ class EntriesFilter < Docs::EntriesFilter
4+ def get_name
5+ name = at_css('h1').content.strip
6+ name.remove! %r{\(.*}
7+ name
8+ end
9+
10+ CONTRIBUTOR_SLUGS = %w(
11+ How-To-Open-a-Homebrew-Pull-Request
12+ Formula-Cookbook
13+ Acceptable-Formulae
14+ Versions
15+ Node-for-Formula-Authors
16+ Python-for-Formula-Authors
17+ Migrating-A-Formula-To-A-Tap
18+ Rename-A-Formula
19+ How-to-Create-and-Maintain-a-Tap
20+ Brew-Test-Bot
21+ Prose-Style-Guidelines)
22+
23+ def get_type
24+ if CONTRIBUTOR_SLUGS.include?(slug)
25+ 'Contributors'
26+ else
27+ 'Users'
28+ end
29+ end
30+ end
31+ end
32+end
lib/docs/scrapers/brew.rb+0−22
@@ -1,22 +0,0 @@
1−module Docs
2− class Brew < UrlScraper
3− self.name = 'Homebrew'
4− self.type = 'brew'
5− self.release = '1.3.6'
6− self.base_url = 'https://docs.brew.sh'
7− self.root_path = '/'
8− self.links = {
9− home: 'https://brew.sh',
10− code: 'https://github.com/Homebrew/brew'
11− }
12−
13− options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page' }
14−
15− html_filters.push 'brew/entries', 'brew/clean_html'
16−
17− options[:attribution] = <<-HTML
18− Homebrew was created by Max Howell. <br>
19− Licensed under the BSD 2-Clause License.
20− HTML
21− end
22−end
lib/docs/scrapers/homebrew.rb+24−0
@@ -0,0 +1,24 @@
1+module Docs
2+ class Homebrew < UrlScraper
3+ self.name = 'Homebrew'
4+ self.type = 'simple'
5+ self.release = '1.3.6'
6+ self.base_url = 'https://docs.brew.sh/'
7+ self.links = {
8+ home: 'https://brew.sh',
9+ code: 'https://github.com/Homebrew/brew'
10+ }
11+
12+ html_filters.push 'homebrew/entries', 'homebrew/clean_html'
13+
14+ options[:container] = ->(filter) { filter.root_page? ? '#home' : '#page' }
15+
16+ options[:skip_patterns] = [/maintainer/i, /core\-contributor/i]
17+ options[:skip] = %w(Kickstarter-Supporters.html)
18+
19+ options[:attribution] = <<-HTML
20+ &copy; 2009&ndash;present Homebrew contributors<br>
21+ Licensed under the BSD 2-Clause License.
22+ HTML
23+ end
24+end
public/icons/docs/brew/16.png+0−0

Binary file not shown.

public/icons/docs/brew/16@2x.png+0−0

Binary file not shown.

public/icons/docs/brew/SOURCE+0−0

Binary file not shown.

public/icons/docs/homebrew/16.png+0−0

Binary file not shown.

public/icons/docs/homebrew/16@2x.png+0−0

Binary file not shown.

public/icons/docs/homebrew/SOURCE+1−0
@@ -0,0 +1 @@
1+https://github.com/Homebrew/brew/tree/master/docs/img