mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add Bluebird documentation (3.5.0)
The individual doc pages do not have any category hints in either their url or on the page, so get_type() has a fixed mapping of slug->type.
This commit is contained in:
parent
d1ad60e067
commit
b399a0ca6f
6 changed files with 99 additions and 0 deletions
11
lib/docs/filters/bluebird/clean_html.rb
Normal file
11
lib/docs/filters/bluebird/clean_html.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
module Docs
|
||||
class Bluebird
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
css('.post-content > p:first').remove
|
||||
css('pre').attr('data-language', 'javascript')
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
66
lib/docs/filters/bluebird/entries.rb
Normal file
66
lib/docs/filters/bluebird/entries.rb
Normal file
|
@ -0,0 +1,66 @@
|
|||
module Docs
|
||||
class Bluebird
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
TYPE_MAP = {
|
||||
Core: %w(new-promise then spread catch error finally bind promise.join
|
||||
promise.try promise.method promise.resolve promise.reject core
|
||||
promise.bind),
|
||||
'Synchronous inspection': %w(promiseinspection isfulfilled isrejected
|
||||
ispending iscancelled value reason),
|
||||
Collections: %w(promise.all promise.props promise.any promise.some
|
||||
promise.map promise.reduce promise.filter promise.each
|
||||
promise.mapseries promise.race all props any some map reduce filter
|
||||
each mapseries),
|
||||
'Resource management': %w(promise.using disposer),
|
||||
Promisification: %w(promise.promisify promise.promisifyall
|
||||
promise.fromcallback ascallback),
|
||||
Timers: %w(delay timeout promise.delay),
|
||||
Cancellation: %w(cancel),
|
||||
Generators: %w(promise.coroutine promise.coroutine.addyieldhandler),
|
||||
Utility: %w(tap tapcatch call get return throw catchreturn catchthrow
|
||||
reflect promise.getnewlibrarycopy promise.noconflict
|
||||
promise.setscheduler),
|
||||
'Built-in error types': %w(operationalerror timeouterror
|
||||
cancellationerror aggregateerror),
|
||||
Configuration: %w(global-rejection-events local-rejection-events
|
||||
done promise.config suppressunhandledrejections
|
||||
promise.onpossiblyunhandledrejection promise.bind
|
||||
promise.onunhandledrejectionhandled),
|
||||
'Progression migration': %(),
|
||||
'Deferred migration': %(),
|
||||
'Environment variables': %(),
|
||||
"Beginner's Guide": %w(),
|
||||
'Error management configuration': %w(),
|
||||
'Anti-patterns': %w(),
|
||||
'Deprecated APIs': %w()
|
||||
}
|
||||
|
||||
def get_name
|
||||
name = at_css('h1.post-title')
|
||||
if name.nil?
|
||||
name = at_css('.post-content h2')
|
||||
end
|
||||
name.text
|
||||
end
|
||||
|
||||
def get_type
|
||||
type = nil
|
||||
TYPE_MAP.each do |k,v|
|
||||
if k.to_s.casecmp(name.strip) == 0
|
||||
type = k
|
||||
break
|
||||
else
|
||||
slug_end = slug.sub(%r(^docs/api/), '')
|
||||
if v.include?(slug_end.downcase)
|
||||
type = k
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
type.to_s
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
21
lib/docs/scrapers/bluebird.rb
Normal file
21
lib/docs/scrapers/bluebird.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
module Docs
|
||||
class Bluebird < UrlScraper
|
||||
self.type = 'bluebird'
|
||||
self.base_url = 'http://bluebirdjs.com'
|
||||
self.root_path = '/docs/api-reference.html'
|
||||
self.release = '3.5.0'
|
||||
self.links = {
|
||||
home: 'http://bluebirdjs.com/',
|
||||
code: 'https://github.com/petkaantonov/bluebird/'
|
||||
}
|
||||
|
||||
html_filters.push 'bluebird/clean_html', 'bluebird/entries'
|
||||
|
||||
options[:container] = 'body .post'
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Petka Antonov<br/>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
end
|
||||
end
|
BIN
public/icons/docs/bluebird/16.png
Normal file
BIN
public/icons/docs/bluebird/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
public/icons/docs/bluebird/16@2x.png
Normal file
BIN
public/icons/docs/bluebird/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
1
public/icons/docs/bluebird/SOURCE
Normal file
1
public/icons/docs/bluebird/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://github.com/petkaantonov/bluebird/blob/master/docs/img/libbblog_v3.png
|
Loading…
Reference in a new issue