Explorar el Código

Finish scikit-image scraper

Thibaut Courouble hace 9 años
padre
commit
50f583246d

BIN
assets/images/docs.png


BIN
assets/images/docs@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2016-09-05",
-    "New documentations: <a href=\"/fish/\">Fish</a> and <a href=\"/bottle/\">Bottle</a>"
+    "New documentations: <a href=\"/fish/\">Fish</a>, <a href=\"/bottle/\">Bottle</a> and <a href=\"/scikit_image/\">scikit-image</a>"
   ], [
     "2016-08-07",
     "New documentation: <a href=\"/docker/\">Docker</a>"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -494,6 +494,11 @@ credits = [
     '2006-2016 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
     'MIT',
     'https://raw.githubusercontent.com/sass/sass/stable/MIT-LICENSE'
+  ], [
+    'scikit-image',
+    '2011 the scikit-image team',
+    'BSD',
+    'http://scikit-image.org/docs/dev/license.html'
   ], [
     'Sinon',
     '2010-2016 Christian Johansen',

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -117,6 +117,7 @@
 ._icon-modernizr:before     { background-position: -3rem -6rem; }
 ._icon-bower:before         { background-position: -4rem -6rem; }
 ._icon-fish:before          { background-position: -5rem -6rem; @extend %darkIconFix !optional; }
+._icon-scikit_image:before  { background-position: -6rem -6rem; }
 ._icon-bottle:before        { background-position: 0 -7rem; }
 ._icon-docker:before        { background-position: -1rem -7rem; }
 ._icon-cakephp:before       { background-position: -2rem -7rem; }

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

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

+ 19 - 4
lib/docs/filters/scikit_image/entries.rb

@@ -4,17 +4,27 @@ module Docs
       def get_name
         name = at_css('h1').content.strip
         name.remove! "\u{00b6}"
-        name.remove! 'Module: '
-        name.remove! %r{ \(.*\)}
-        name.downcase!
+
+        if slug.start_with?('api')
+          name.remove! 'Module: '
+          name.remove! %r{ \(.*\)}
+          name.downcase!
+        end
+
         name
       end
 
       def get_type
-        name.split('.').first
+        if slug.start_with?('api')
+          name.split('.').first
+        else
+          'Guide'
+        end
       end
 
       def additional_entries
+        return [] unless slug.start_with?('api')
+
         entries = []
 
         css('.class > dt[id]', '.exception > dt[id]', '.attribute > dt[id]').each do |node|
@@ -30,8 +40,13 @@ module Docs
         css('.function > dt[id]', '.method > dt[id]', '.classmethod > dt[id]').each do |node|
           entries << [node['id'].remove('skimage.') + '()', node['id']]
         end
+
         entries
       end
+
+      def include_default_entry?
+        slug != 'api/api'
+      end
     end
   end
 end

+ 1 - 1
lib/docs/filters/sphinx/clean_html.rb

@@ -9,7 +9,7 @@ module Docs
           node.remove
         end
 
-        css('em.xref', 'tt').each do |node|
+        css('em.xref', 'tt', 'cite').each do |node|
           node.name = 'code'
         end
 

+ 7 - 7
lib/docs/scrapers/scikit_image.rb

@@ -3,22 +3,22 @@ module Docs
     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.release = '0.12.3'
+    self.base_url = 'http://scikit-image.org/docs/0.12.x/'
     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'
+    html_filters.push 'scikit_image/entries', 'sphinx/clean_html'
 
     options[:container] = '.span9'
+    options[:skip] = %w(api_changes.html)
+    options[:only_patterns] = [/\Aapi/, /\Auser_guide/]
 
     options[:attribution] = <<-HTML
-      &copy; 2011 the scikit-image development team<br>
-      Licensed under the scikit-image License.
+      &copy; 2011 the scikit-image team<br>
+      Licensed under the BSD 3-clause License.
     HTML
   end
 end

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


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