Skip to content

Commit a6b7bd5

Browse files
jmerleThibaut
authored andcommitted
Add Puppeteer documentation
1 parent 39aeffd commit a6b7bd5

File tree

7 files changed

+87
-0
lines changed

7 files changed

+87
-0
lines changed

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,11 @@ credits = [
560560
'1996-2018 The PostgreSQL Global Development Group<br>&copy; 1994 The Regents of the University of California',
561561
'PostgreSQL',
562562
'https://www.postgresql.org/about/licence/'
563+
], [
564+
'Puppeteer',
565+
'2017 Google Inc',
566+
'Apache',
567+
'https://raw.githubusercontent.com/GoogleChrome/puppeteer/master/LICENSE'
563568
], [
564569
'Pygame',
565570
'Pygame Developpers',
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module Docs
2+
class Puppeteer
3+
class CleanHtmlFilter < Filter
4+
def call
5+
# None of the elements to remove have classes, so the order of the remove calls is trivial
6+
7+
# Remove links to previous versions of the reference
8+
at_css('h5').remove
9+
10+
# Remove table of contents
11+
at_css('h5').remove
12+
at_css('ul').remove
13+
14+
# Make headers bigger by transforming them into a bigger variant
15+
css('h3').each {|node| node.name = 'h2'}
16+
css('h4').each {|node| node.name = 'h3'}
17+
18+
doc
19+
end
20+
end
21+
end
22+
end

lib/docs/filters/puppeteer/entries.rb

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
module Docs
2+
class Puppeteer
3+
class EntriesFilter < Docs::EntriesFilter
4+
# The entire reference is one big page, so get_name and get_type are not necessary
5+
6+
def additional_entries
7+
entries = []
8+
9+
css('h3').each do |node|
10+
name = node.content.split(': ').last
11+
12+
# Find all sub-items (all h4's between the current h3 and the next)
13+
current = node.next
14+
while !current.nil? && current.name != 'h3'
15+
if current.name == 'h4'
16+
current_name = current.content
17+
18+
# Prepend events with the class name
19+
if current_name.start_with?('event: ')
20+
current_name = "#{name} event: '#{current_name[/'(.*)'/, 1]}'"
21+
end
22+
23+
# Remove arguments from functions
24+
if current_name.include?('(')
25+
current_name = current_name.split('(')[0] + '()'
26+
end
27+
28+
entries << [current_name, current['id'], name]
29+
end
30+
31+
current = current.next
32+
end
33+
34+
entries << [name, node['id'], name]
35+
end
36+
37+
entries
38+
end
39+
end
40+
end
41+
end

lib/docs/scrapers/puppeteer.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Docs
2+
class Puppeteer < Github
3+
self.release = '1.6.2'
4+
self.base_url = 'https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/docs/api.md'
5+
self.links = {
6+
code: 'https://github.com/GoogleChrome/puppeteer'
7+
}
8+
9+
html_filters.push 'puppeteer/entries', 'puppeteer/clean_html'
10+
11+
options[:container] = '.markdown-body'
12+
13+
options[:attribution] = <<-HTML
14+
&copy; 2017 Google Inc<br>
15+
Licensed under the Apache License 2.0.
16+
HTML
17+
end
18+
end

public/icons/docs/puppeteer/16.png

661 Bytes
Loading
1.01 KB
Loading

public/icons/docs/puppeteer/SOURCE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/GoogleChromeLabs/pptr.dev/tree/master/src/favicons

0 commit comments

Comments
 (0)