History

Finish Bluebird scraper

Thibaut Courouble committed 8 years ago

Commit dac41921 parent b399a0c10 files · +47 −30Browse files

Unified · Split

10 files
  1. assets/images/docs-2.png +0 −0
  2. assets/images/docs-2@2x.png +0 −0
  3. assets/javascripts/news.json +3 −0
  4. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  5. assets/stylesheets/global/_icons.scss +1 −0
  6. lib/docs/filters/bluebird/clean_html.rb +27 −2
  7. lib/docs/filters/bluebird/entries.rb +8 −26
  8. lib/docs/scrapers/bluebird.rb +7 −6
  9. public/icons/docs/bluebird/16.png +0 −0
  10. public/icons/docs/bluebird/16@2x.png +0 −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+3−0
@@ -1,5 +1,8 @@
11 [
22 [
3+ "2017-11-26",
4+ "New documentation: <a href=\"/bluebird/\">Bluebird</a>"
5+ ], [
36 "2017-11-18",
47 "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>."
58 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -112,6 +112,11 @@ credits = [ · 111 unmodified lines
112112 '2010-2016 Jeremy Ashkenas, DocumentCloud',
113113 'MIT',
114114 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE'
115+ ], [
116+ 'Bluebird',
117+ '2013-2017 Petka Antonov',
118+ 'MIT',
119+ 'https://raw.githubusercontent.com/petkaantonov/bluebird/master/LICENSE'
115120 ], [
116121 'Bootstrap',
117122 '2011-2017 Twitter, Inc.<br>2011-2017 The Bootstrap Authors',
assets/stylesheets/global/_icons.scss+1−0
@@ -164,3 +164,4 @@ · 163 unmodified lines
164164 ._icon-nim:before { background-position: -5rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
165165 ._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
166166 ._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }
167+._icon-bluebird:before { background-position: -8rem -2rem; @extend %doc-icon-2; }
lib/docs/filters/bluebird/clean_html.rb+27−2
@@ -2,8 +2,33 @@ module Docs · 1 unmodified line
22 class Bluebird
33 class CleanHtmlFilter < Filter
44 def call
5− css('.post-content > p:first').remove
6− css('pre').attr('data-language', 'javascript')
5+ @doc = at_css('.post')
6+
7+ css('hr').remove
8+
9+ css('.api-code-section').each do |node|
10+ node.previous_element.remove
11+ end
12+
13+ css('.post-header', '.post-content', '.api-reference-menu', '.api-code-section', 'markdown', '.highlight', 'code code').each do |node|
14+ node.before(node.children).remove
15+ end
16+
17+ at_css('> h2:first-child').name = 'h1' unless at_css('h1')
18+
19+ css('.header-anchor[name]').each do |node|
20+ node.parent['id'] = node['name']
21+ end
22+
23+ css('pre').each do |node|
24+ node.content = node.content
25+ node['data-language'] = 'javascript'
26+ end
27+
28+ css('.info-box').each do |node|
29+ node.name = 'blockquote'
30+ end
31+
732 doc
833 end
934 end
lib/docs/filters/bluebird/entries.rb+8−26
@@ -26,41 +26,23 @@ module Docs · 25 unmodified lines
2626 done promise.config suppressunhandledrejections
2727 promise.onpossiblyunhandledrejection promise.bind
2828 promise.onunhandledrejectionhandled),
29− 'Progression migration': %(),
30− 'Deferred migration': %(),
31− 'Environment variables': %(),
32− "Beginner's Guide": %w(),
33− 'Error management configuration': %w(),
34− 'Anti-patterns': %w(),
35− 'Deprecated APIs': %w()
3629 }
3730
3831 def get_name
39− name = at_css('h1.post-title')
40− if name.nil?
41− name = at_css('.post-content h2')
42− end
43− name.text
32+ name = at_css('h1').content.strip
33+ name << '()' if doc.to_html.include?("#{name}(")
34+ name
4435 end
4536
4637 def get_type
47− type = nil
48− TYPE_MAP.each do |k,v|
49− if k.to_s.casecmp(name.strip) == 0
50− type = k
51− break
52− else
53− slug_end = slug.sub(%r(^docs/api/), '')
54− if v.include?(slug_end.downcase)
55− type = k
56− break
57− end
38+ if slug.start_with?('api')
39+ TYPE_MAP.each do |key, value|
40+ return key.to_s if value.include?(slug.remove('api/'))
5841 end
42+ else
43+ 'Guides'
5944 end
60−
61− type.to_s
6245 end
63−
6446 end
6547 end
6648 end
lib/docs/scrapers/bluebird.rb+7−6
@@ -1,9 +1,10 @@
11 module Docs
22 class Bluebird < UrlScraper
3− self.type = 'bluebird'
4− self.base_url = 'http://bluebirdjs.com'
5− self.root_path = '/docs/api-reference.html'
6− self.release = '3.5.0'
3+ self.type = 'simple'
4+ self.release = '3.5.1'
5+ self.base_url = 'http://bluebirdjs.com/docs/'
6+ self.root_path = 'api-reference.html'
7+ self.force_gzip = true
78 self.links = {
89 home: 'http://bluebirdjs.com/',
910 code: 'https://github.com/petkaantonov/bluebird/'
@@ -11,10 +12,10 @@ module Docs · 1 unmodified line
1112
1213 html_filters.push 'bluebird/clean_html', 'bluebird/entries'
1314
14− options[:container] = 'body .post'
15+ options[:skip] = %w(support.html download-api-reference.html contribute.html)
1516
1617 options[:attribution] = <<-HTML
17− &copy; Petka Antonov<br/>
18+ &copy; 2013&ndash;2017 Petka Antonov<br>
1819 Licensed under the MIT License.
1920 HTML
2021 end
public/icons/docs/bluebird/16.png+0−0

Binary file not shown.

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

Binary file not shown.