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 @@
1[1[
2 [2 [
3 "2017-11-26",
4 "New documentation: <a href=\"/bluebird/\">Bluebird</a>"
5 ], [
3 "2017-11-18",6 "2017-11-18",
4 "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>."7 "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 ], [8 ], [
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -112,6 +112,11 @@ credits = [ · 111 unmodified lines
112 '2010-2016 Jeremy Ashkenas, DocumentCloud',112 '2010-2016 Jeremy Ashkenas, DocumentCloud',
113 'MIT',113 'MIT',
114 'https://raw.githubusercontent.com/jashkenas/backbone/master/LICENSE'114 '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'
115 ], [120 ], [
116 'Bootstrap',121 'Bootstrap',
117 '2011-2017 Twitter, Inc.<br>2011-2017 The Bootstrap Authors',122 '2011-2017 Twitter, Inc.<br>2011-2017 The Bootstrap Authors',
assets/stylesheets/global/_icons.scss+1−0
@@ -164,3 +164,4 @@ · 163 unmodified lines
164._icon-nim:before { background-position: -5rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }164._icon-nim:before { background-position: -5rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
165._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }165._icon-vulkan:before { background-position: -6rem -2rem; @extend %doc-icon-2; @extend %darkIconFix !optional; }
166._icon-d:before { background-position: -7rem -2rem; @extend %doc-icon-2; }166._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
2 class Bluebird2 class Bluebird
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 css('.post-content > p:first').remove5 @doc = at_css('.post')
6 css('pre').attr('data-language', 'javascript')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
7 doc32 doc
8 end33 end
9 end34 end
lib/docs/filters/bluebird/entries.rb+8−26
@@ -26,41 +26,23 @@ module Docs · 25 unmodified lines
26 done promise.config suppressunhandledrejections26 done promise.config suppressunhandledrejections
27 promise.onpossiblyunhandledrejection promise.bind27 promise.onpossiblyunhandledrejection promise.bind
28 promise.onunhandledrejectionhandled),28 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()
36 }29 }
37 30
38 def get_name31 def get_name
39 name = at_css('h1.post-title')32 name = at_css('h1').content.strip
40 if name.nil?33 name << '()' if doc.to_html.include?("#{name}(")
41 name = at_css('.post-content h2')34 name
42 end
43 name.text
44 end35 end
45 36
46 def get_type37 def get_type
47 type = nil38 if slug.start_with?('api')
48 TYPE_MAP.each do |k,v|39 TYPE_MAP.each do |key, value|
49 if k.to_s.casecmp(name.strip) == 040 return key.to_s if value.include?(slug.remove('api/'))
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
58 end41 end
42 else
43 'Guides'
59 end44 end
60
61 type.to_s
62 end45 end
63
64 end46 end
65 end47 end
66end48end
lib/docs/scrapers/bluebird.rb+7−6
@@ -1,9 +1,10 @@
1module Docs1module Docs
2 class Bluebird < UrlScraper2 class Bluebird < UrlScraper
3 self.type = 'bluebird'3 self.type = 'simple'
4 self.base_url = 'http://bluebirdjs.com'4 self.release = '3.5.1'
5 self.root_path = '/docs/api-reference.html'5 self.base_url = 'http://bluebirdjs.com/docs/'
6 self.release = '3.5.0'6 self.root_path = 'api-reference.html'
7 self.force_gzip = true
7 self.links = {8 self.links = {
8 home: 'http://bluebirdjs.com/',9 home: 'http://bluebirdjs.com/',
9 code: 'https://github.com/petkaantonov/bluebird/'10 code: 'https://github.com/petkaantonov/bluebird/'
@@ -11,10 +12,10 @@ module Docs · 1 unmodified line
11 12
12 html_filters.push 'bluebird/clean_html', 'bluebird/entries'13 html_filters.push 'bluebird/clean_html', 'bluebird/entries'
13 14
14 options[:container] = 'body .post'15 options[:skip] = %w(support.html download-api-reference.html contribute.html)
15 16
16 options[:attribution] = <<-HTML17 options[:attribution] = <<-HTML
17 &copy; Petka Antonov<br/>18 &copy; 2013&ndash;2017 Petka Antonov<br>
18 Licensed under the MIT License.19 Licensed under the MIT License.
19 HTML20 HTML
20 end21 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.