Skip to content

Commit dac4192

Browse files
committed
Finish Bluebird scraper
1 parent b399a0c commit dac4192

10 files changed

Lines changed: 51 additions & 34 deletions

File tree

assets/images/docs-2.png

363 Bytes
Loading

assets/images/[email protected]

1.01 KB
Loading

assets/javascripts/news.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ credits = [
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,4 @@
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

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,33 @@ module Docs
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

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,23 @@ class EntriesFilter < Docs::EntriesFilter
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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
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/'
1011
}
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

-685 Bytes
Loading
-634 Bytes
Loading

0 commit comments

Comments
 (0)