Quellcode durchsuchen

Added Scraper for Scikit-Image (sqashed)

+ Scraper definition sourcing from http://scikit-image.org/docs/0.12.x/api/
+ Entries filter

Added clean_html and scikit_image icons
Prashant Sinha vor 9 Jahren
Ursprung
Commit
7f06c9c76e

+ 11 - 0
lib/docs/filters/scikit_image/clean_html.rb

@@ -0,0 +1,11 @@
+module Docs
+  class ScikitImage
+    class CleanHtmlFilter < Filter
+      def call
+        css('h2').remove
+        css('h1 + table').remove
+        doc
+      end
+    end
+  end
+end

+ 37 - 0
lib/docs/filters/scikit_image/entries.rb

@@ -0,0 +1,37 @@
+module Docs
+  class ScikitImage
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content.strip
+        name.remove! "\u{00b6}"
+        name.remove! 'Module: '
+        name.remove! %r{ \(.*\)}
+        name.downcase!
+        name
+      end
+
+      def get_type
+        name.split('.').first
+      end
+
+      def additional_entries
+        entries = []
+
+        css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node|
+          entries << [node['id'].remove('skimage.'), node['id']]
+        end
+
+        css('.data > dt[id]').each do |node|
+          if node['id'].split('.').last.upcase!
+            entries << [node['id'].remove('skimage.'), node['id']]
+          end
+        end
+
+        css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node|
+          entries << [node['id'].remove('skimage.') + '()', node['id']]
+        end
+        entries
+      end
+    end
+  end
+end

+ 24 - 0
lib/docs/scrapers/scikit_image.rb

@@ -0,0 +1,24 @@
+module Docs
+  class ScikitImage < UrlScraper
+    self.name = 'scikit-image'
+    self.slug = 'scikit_image'
+    self.type = 'sphinx'
+    self.release = '0.12.2'
+    self.base_url = 'http://scikit-image.org/docs/0.12.x/api/'
+    self.root_path = 'api.html'
+
+    self.links = {
+      home: 'http://scikit-image.org/',
+      code: 'https://github.com/scikit-image/scikit-image'
+    }
+
+    html_filters.push 'scikit_image/entries', 'scikit_image/clean_html', 'sphinx/clean_html'
+
+    options[:container] = '.span9'
+
+    options[:attribution] = <<-HTML
+      &copy; 2011 the scikit-image development team<br>
+      Licensed under the scikit-image License.
+    HTML
+  end
+end

BIN
public/icons/docs/scikit_image/16.png


BIN
public/icons/docs/scikit_image/16@2x.png


+ 1 - 0
public/icons/docs/scikit_image/SOURCE

@@ -0,0 +1 @@
+https://github.com/scikit-image/scikit-image/blob/master/doc/source/themes/scikit-image/static/img/favicon.ico