소스 검색

Add Pony filters/scraper

Harm Aarts 7 년 전
부모
커밋
f948577584
4개의 변경된 파일45개의 추가작업 그리고 0개의 파일을 삭제
  1. 10 0
      lib/docs/filters/pony/clean_html.rb
  2. 9 0
      lib/docs/filters/pony/container.rb
  3. 14 0
      lib/docs/filters/pony/entries.rb
  4. 12 0
      lib/docs/scrapers/pony.rb

+ 10 - 0
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

+ 9 - 0
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

+ 14 - 0
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

+ 12 - 0
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