From a6b7bd53c2f1f6594850d28c342128e785152802 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Thu, 2 Aug 2018 23:33:15 +0200 Subject: [PATCH] Add Puppeteer documentation --- .../templates/pages/about_tmpl.coffee | 5 +++ lib/docs/filters/puppeteer/clean_html.rb | 22 ++++++++++ lib/docs/filters/puppeteer/entries.rb | 41 ++++++++++++++++++ lib/docs/scrapers/puppeteer.rb | 18 ++++++++ public/icons/docs/puppeteer/16.png | Bin 0 -> 661 bytes public/icons/docs/puppeteer/16@2x.png | Bin 0 -> 1034 bytes public/icons/docs/puppeteer/SOURCE | 1 + 7 files changed, 87 insertions(+) create mode 100644 lib/docs/filters/puppeteer/clean_html.rb create mode 100644 lib/docs/filters/puppeteer/entries.rb create mode 100644 lib/docs/scrapers/puppeteer.rb create mode 100644 public/icons/docs/puppeteer/16.png create mode 100644 public/icons/docs/puppeteer/16@2x.png create mode 100644 public/icons/docs/puppeteer/SOURCE diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 629682fb..753c0058 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -560,6 +560,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/lib/docs/filters/puppeteer/clean_html.rb b/lib/docs/filters/puppeteer/clean_html.rb new file mode 100644 index 00000000..dac3b5ef --- /dev/null +++ b/lib/docs/filters/puppeteer/clean_html.rb @@ -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 diff --git a/lib/docs/filters/puppeteer/entries.rb b/lib/docs/filters/puppeteer/entries.rb new file mode 100644 index 00000000..db80d25d --- /dev/null +++ b/lib/docs/filters/puppeteer/entries.rb @@ -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 diff --git a/lib/docs/scrapers/puppeteer.rb b/lib/docs/scrapers/puppeteer.rb new file mode 100644 index 00000000..210f6dd3 --- /dev/null +++ b/lib/docs/scrapers/puppeteer.rb @@ -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
+ 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 0000000000000000000000000000000000000000..558e83c2823b42628f3e90795b2fc3e397f30cc6 GIT binary patch literal 661 zcmV;G0&4wPx#+fYnYMNDaN-QC>)C>#KTVE`o=0CrbhU0qdGRUaWB zgoA_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