[devdocsgjs/main: 530/1867] Add Pony filters/scraper
- From: Andy Holmes <andyholmes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devdocsgjs/main: 530/1867] Add Pony filters/scraper
- Date: Fri, 19 Nov 2021 23:47:15 +0000 (UTC)
commit f948577584325299ad0b568f5f5312d6b1237a78
Author: Harm Aarts <harmaarts gmail com>
Date: Tue Dec 11 19:41:52 2018 +0100
Add Pony filters/scraper
lib/docs/filters/pony/clean_html.rb | 10 ++++++++++
lib/docs/filters/pony/container.rb | 9 +++++++++
lib/docs/filters/pony/entries.rb | 14 ++++++++++++++
lib/docs/scrapers/pony.rb | 12 ++++++++++++
4 files changed, 45 insertions(+)
---
diff --git a/lib/docs/filters/pony/clean_html.rb b/lib/docs/filters/pony/clean_html.rb
new file mode 100644
index 00000000..0aac0f7a
--- /dev/null
+++ b/lib/docs/filters/pony/clean_html.rb
@@ -0,0 +1,10 @@
+module Docs
+ class Pony
+ class CleanHtmlFilter < Filter
+ def call
+ css('.headerlink').remove
+ doc
+ end
+ end
+ end
+end
diff --git a/lib/docs/filters/pony/container.rb b/lib/docs/filters/pony/container.rb
new file mode 100644
index 00000000..f29db7d4
--- /dev/null
+++ b/lib/docs/filters/pony/container.rb
@@ -0,0 +1,9 @@
+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
new file mode 100644
index 00000000..09ffe595
--- /dev/null
+++ b/lib/docs/filters/pony/entries.rb
@@ -0,0 +1,14 @@
+module Docs
+ class Pony
+ class EntriesFilter < Docs::EntriesFilter
+ def get_name
+ binding.pry
+ context[:html_title].sub(/ - .*/, '')
+ end
+
+ def get_type
+ subpath.split('-')[0][1..-1]
+ end
+ end
+ end
+end
diff --git a/lib/docs/scrapers/pony.rb b/lib/docs/scrapers/pony.rb
new file mode 100644
index 00000000..9863ed76
--- /dev/null
+++ b/lib/docs/scrapers/pony.rb
@@ -0,0 +1,12 @@
+module Docs
+ class Pony < UrlScraper
+ self.type = 'pony'
+ self.release = '0.25.0'
+ self.base_url = 'http://localhost:2015'
+ #self.base_url = 'https://stdlib.ponylang.io/'
+
+ html_filters.push 'pony/container', 'pony/entries', 'pony/clean_html'
+ options[:attribution] = "Me"
+ options[:follow_links] = ->(filter) { filter.subpath !~ /src/ }
+ end
+end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]