浏览代码

Improve abstract rdoc scraper

Thibaut 11 年之前
父节点
当前提交
b58bc8bc58

+ 1 - 1
assets/stylesheets/pages/_rdoc.scss

@@ -1,6 +1,6 @@
 ._rdoc {
   > .description, > .documentation-section { padding-left: 1rem; }
-  > .description > h2, header > h3 { @extend %block-heading; }
+  > .description > h2, header > h3, > h2 { @extend %block-heading; }
   > .description > h2, header > h3, .method-heading { margin-left: -1rem; }
   .description > h1 { font-size: 1rem; }
   .method-description > h2, h3, h4, h5, h6 { font-size: 1em; }

+ 3 - 1
lib/docs/filters/rdoc/container.rb

@@ -19,7 +19,9 @@ module Docs
             meta << %(<dt>Included modules:</dt><dd class="meta-includes">#{includes.css('a').map(&:to_html).join(', ')}</dd>)
           end
 
-          container.at_css('h1').after(meta)
+          if parent || includes
+            container.at_css('h1').after(meta)
+          end
 
           container
         end

+ 3 - 1
lib/docs/filters/rdoc/entries.rb

@@ -2,7 +2,9 @@ module Docs
   class Rdoc
     class EntriesFilter < Docs::EntriesFilter
       def get_name
-        name = at_css('h1').content.strip
+        name = at_css('h1, h2').content.strip
+        name.remove! "\u{00B6}" # remove pilcrow sign
+        name.remove! "\u{2191}" # remove up arrow sign
         name.remove! 'class '
         name.remove! 'module '
         name

+ 1 - 1
lib/docs/scrapers/rdoc/rails.rb

@@ -57,7 +57,7 @@ module Docs
       ActiveSupport/Testing/Isolation/Subprocess.html
       Rails/API/Task.html)
 
-    options[:skip_patterns] = [
+    options[:skip_patterns] += [
       /\AActionController\/Caching(?!\/Fragments|\.)/,
       /\AActionController\/RequestForgeryProtection\/ProtectionMethods/,
       /\AActionController\/Testing/,

+ 6 - 1
lib/docs/scrapers/rdoc/rdoc.rb

@@ -5,9 +5,14 @@ module Docs
     self.root_path = 'table_of_contents.html'
 
     html_filters.replace 'container', 'rdoc/container'
-    html_filters.push 'rdoc/entries', 'rdoc/clean_html', 'title'
+    html_filters.push 'title', 'rdoc/entries', 'rdoc/clean_html'
 
     options[:title] = false
     options[:skip] = %w(index.html)
+    options[:skip_patterns] = [
+      /changelog/i,
+      /readme/i,
+      /news/i,
+      /license/i]
   end
 end