From eb82f6024cf25e8c468b5198404b75f7015fe457 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Wed, 14 Aug 2019 02:28:43 +0200 Subject: [PATCH] pony: finish scraper and filters --- .../templates/pages/about_tmpl.coffee | 6 ++++ lib/docs/filters/pony/clean_html.rb | 15 ++++++++++ lib/docs/filters/pony/container.rb | 9 ------ lib/docs/filters/pony/entries.rb | 26 ++++++++++++++++-- lib/docs/scrapers/pony.rb | 19 +++++++++---- public/icons/docs/pony/16.png | Bin 1979 -> 1360 bytes 6 files changed, 59 insertions(+), 16 deletions(-) create mode 100644 lib/docs/filters/pony/clean_html.rb delete mode 100644 lib/docs/filters/pony/container.rb diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 07c92ad8..ac86b701 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -568,6 +568,12 @@ credits = [ 'CC BY', 'https://creativecommons.org/licenses/by/3.0/' ], [ + 'Pony', + '2016-2018, The Pony Developers & 2014-2015, Causality Ltd.', + 'BSD', + 'https://raw.githubusercontent.com/ponylang/ponyc/master/LICENSE' + ], + [ 'PostgreSQL', '1996-2018 The PostgreSQL Global Development Group
© 1994 The Regents of the University of California', 'PostgreSQL', diff --git a/lib/docs/filters/pony/clean_html.rb b/lib/docs/filters/pony/clean_html.rb new file mode 100644 index 00000000..665d1048 --- /dev/null +++ b/lib/docs/filters/pony/clean_html.rb @@ -0,0 +1,15 @@ +module Docs + class Pony + class CleanHtmlFilter < Filter + def call + css('.headerlink').remove + + css('pre').each do |node| + node.content = node.content + end + + doc + end + end + end +end diff --git a/lib/docs/filters/pony/container.rb b/lib/docs/filters/pony/container.rb deleted file mode 100644 index f29db7d4..00000000 --- a/lib/docs/filters/pony/container.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Docs - class Pony - class ContainerFilter < Filter - def call - css('article') - end - end - end -end diff --git a/lib/docs/filters/pony/entries.rb b/lib/docs/filters/pony/entries.rb index 0dbc81c8..296f2090 100644 --- a/lib/docs/filters/pony/entries.rb +++ b/lib/docs/filters/pony/entries.rb @@ -2,11 +2,33 @@ module Docs class Pony class EntriesFilter < Docs::EntriesFilter def get_name - context[:html_title].sub(/ - .*/, '') + title = context[:html_title].sub(/ - .*/, '').split(' ').last + title = "1. #{type}" if title == 'Package' + title end def get_type - subpath.split('-')[0][0..-1] + subpath.split(/-([^a-z])/)[0][0..-1].sub('-', '/') + end + + def additional_entries + return [] if root_page? || name.start_with?("1. ") + + entries = [] + + css('h3').each do |node| + member_name = node.content + + is_field = member_name.start_with?('let ') + member_name = member_name[4..-1] if is_field + + member_name = member_name.scan(/^([a-zA-Z0-9_]+)/)[0][0] + member_name += '()' unless is_field + + entries << ["#{name}.#{member_name}", node['id']] + end + + entries end end end diff --git a/lib/docs/scrapers/pony.rb b/lib/docs/scrapers/pony.rb index 5f1bbc04..24df881d 100644 --- a/lib/docs/scrapers/pony.rb +++ b/lib/docs/scrapers/pony.rb @@ -1,18 +1,27 @@ module Docs class Pony < UrlScraper - self.type = 'pony' - self.release = '0.25.0' + self.type = 'simple' + self.release = '0.30.0' self.base_url = 'https://stdlib.ponylang.io/' + self.links = { + home: 'https://www.ponylang.io/', + code: 'https://github.com/ponylang/ponyc' + } - html_filters.push 'pony/container', 'pony/entries' + html_filters.push 'pony/clean_html', 'pony/entries' options[:attribution] = <<-HTML © 2016-2018, The Pony Developers
© 2014-2015, Causality Ltd.
- Licensed under the BSD 2-Clause License + Licensed under the BSD 2-Clause License. HTML + options[:container] = 'article' options[:trailing_slash] = false - options[:skip_patterns] = [/src/] + options[:skip_patterns] = [/src/, /stdlib--index/] + + def get_latest_version(opts) + get_latest_github_release('ponylang', 'ponyc', opts) + end end end diff --git a/public/icons/docs/pony/16.png b/public/icons/docs/pony/16.png index daed6509fb0efbcee6aceaa42047dd39ed731f03..c5b30dade6843b0a39575e97a0fc6147f79346b6 100644 GIT binary patch literal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