diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 60ed00c2..2d1616e1 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -555,6 +555,11 @@ credits = [ '1996-2018 The PostgreSQL Global Development Group
© 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', diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index fe36579d..6e6b75e2 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -39,6 +39,7 @@ ._mocha, ._mongoose, ._nim, +._puppeteer, ._redux, ._requirejs, ._simple, diff --git a/lib/docs/filters/puppeteer/clean_html.rb b/lib/docs/filters/puppeteer/clean_html.rb new file mode 100644 index 00000000..2ec786bb --- /dev/null +++ b/lib/docs/filters/puppeteer/clean_html.rb @@ -0,0 +1,30 @@ +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'} + + css('pre').each do |node| + # Remove nested tags + node.content = node.content + + # Add syntax highlighting + node['data-language'] = 'js' + end + + doc + end + end + end +end diff --git a/lib/docs/filters/puppeteer/entries.rb b/lib/docs/filters/puppeteer/entries.rb new file mode 100644 index 00000000..9650a594 --- /dev/null +++ b/lib/docs/filters/puppeteer/entries.rb @@ -0,0 +1,47 @@ +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 + + # Set the id to the id of the link in the header + # Also remove the "user-content-" part of the id to fix internal links + node['id'] = node.at_css('a')['id'].sub('user-content-', '') + + # 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 + + current['id'] = current.at_css('a')['id'].sub('user-content-', '') + + entries << [current_name, current['id'], name] + end + + current = current.next + end + + entries << [name, node['id'], name] + end + + entries + end + end + end +end diff --git a/lib/docs/scrapers/puppeteer.rb b/lib/docs/scrapers/puppeteer.rb new file mode 100644 index 00000000..2e44c710 --- /dev/null +++ b/lib/docs/scrapers/puppeteer.rb @@ -0,0 +1,19 @@ +module Docs + class Puppeteer < UrlScraper + self.type = 'puppeteer' + 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
+ Licensed under the Apache License 2.0. + HTML + end +end diff --git a/public/icons/docs/puppeteer/16.png b/public/icons/docs/puppeteer/16.png new file mode 100644 index 00000000..558e83c2 Binary files /dev/null and b/public/icons/docs/puppeteer/16.png differ diff --git a/public/icons/docs/puppeteer/16@2x.png b/public/icons/docs/puppeteer/16@2x.png new file mode 100644 index 00000000..20581a2c Binary files /dev/null and b/public/icons/docs/puppeteer/16@2x.png differ diff --git a/public/icons/docs/puppeteer/SOURCE b/public/icons/docs/puppeteer/SOURCE new file mode 100644 index 00000000..73bf4c33 --- /dev/null +++ b/public/icons/docs/puppeteer/SOURCE @@ -0,0 +1 @@ +https://github.com/GoogleChromeLabs/pptr.dev/tree/master/src/favicons