mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Add Puppeteer documentation
This commit is contained in:
parent
39aeffdd80
commit
a6b7bd53c2
7 changed files with 87 additions and 0 deletions
|
@ -560,6 +560,11 @@ credits = [
|
|||
'1996-2018 The PostgreSQL Global Development Group<br>© 1994 The Regents of the University of California',
|
||||
'PostgreSQL',
|
||||
'https://www.postgresql.org/about/licence/'
|
||||
], [
|
||||
'Puppeteer',
|
||||
'2017 Google Inc',
|
||||
'Apache',
|
||||
'https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/LICENSE'
|
||||
], [
|
||||
'Pygame',
|
||||
'Pygame Developpers',
|
||||
|
|
22
lib/docs/filters/puppeteer/clean_html.rb
Normal file
22
lib/docs/filters/puppeteer/clean_html.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
module Docs
|
||||
class Puppeteer
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
# None of the elements to remove have classes, so the order of the remove calls is trivial
|
||||
|
||||
# Remove links to previous versions of the reference
|
||||
at_css('h5').remove
|
||||
|
||||
# Remove table of contents
|
||||
at_css('h5').remove
|
||||
at_css('ul').remove
|
||||
|
||||
# Make headers bigger by transforming them into a bigger variant
|
||||
css('h3').each {|node| node.name = 'h2'}
|
||||
css('h4').each {|node| node.name = 'h3'}
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
41
lib/docs/filters/puppeteer/entries.rb
Normal file
41
lib/docs/filters/puppeteer/entries.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
module Docs
|
||||
class Puppeteer
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
# The entire reference is one big page, so get_name and get_type are not necessary
|
||||
|
||||
def additional_entries
|
||||
entries = []
|
||||
|
||||
css('h3').each do |node|
|
||||
name = node.content.split(': ').last
|
||||
|
||||
# Find all sub-items (all h4's between the current h3 and the next)
|
||||
current = node.next
|
||||
while !current.nil? && current.name != 'h3'
|
||||
if current.name == 'h4'
|
||||
current_name = current.content
|
||||
|
||||
# Prepend events with the class name
|
||||
if current_name.start_with?('event: ')
|
||||
current_name = "#{name} event: '#{current_name[/'(.*)'/, 1]}'"
|
||||
end
|
||||
|
||||
# Remove arguments from functions
|
||||
if current_name.include?('(')
|
||||
current_name = current_name.split('(')[0] + '()'
|
||||
end
|
||||
|
||||
entries << [current_name, current['id'], name]
|
||||
end
|
||||
|
||||
current = current.next
|
||||
end
|
||||
|
||||
entries << [name, node['id'], name]
|
||||
end
|
||||
|
||||
entries
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
18
lib/docs/scrapers/puppeteer.rb
Normal file
18
lib/docs/scrapers/puppeteer.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Docs
|
||||
class Puppeteer < Github
|
||||
self.release = '1.6.2'
|
||||
self.base_url = 'https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/docs/api.md'
|
||||
self.links = {
|
||||
code: 'https://github.com/GoogleChrome/puppeteer'
|
||||
}
|
||||
|
||||
html_filters.push 'puppeteer/entries', 'puppeteer/clean_html'
|
||||
|
||||
options[:container] = '.markdown-body'
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2017 Google Inc<br>
|
||||
Licensed under the Apache License 2.0.
|
||||
HTML
|
||||
end
|
||||
end
|
BIN
public/icons/docs/puppeteer/16.png
Normal file
BIN
public/icons/docs/puppeteer/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 661 B |
BIN
public/icons/docs/puppeteer/16@2x.png
Normal file
BIN
public/icons/docs/puppeteer/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
1
public/icons/docs/puppeteer/SOURCE
Normal file
1
public/icons/docs/puppeteer/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://github.com/GoogleChromeLabs/pptr.dev/tree/master/src/favicons
|
Loading…
Reference in a new issue