소스 검색

Improve Ruby/RDoc scraper

Thibaut 12 년 전
부모
커밋
1eed7c7778
4개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 1
      assets/stylesheets/pages/_rdoc.scss
  2. 1 1
      lib/docs/filters/rdoc/clean_html.rb
  3. 9 2
      lib/docs/filters/rdoc/entries.rb
  4. 0 3
      lib/docs/scrapers/rdoc/ruby.rb

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

@@ -3,7 +3,7 @@
   > .description > h2, .section-header { @extend %block-heading; }
   > .description > h2, .section-header, .method-heading { margin-left: -1rem; }
   .description > h1 { font-size: 1rem; }
-  .method-description > h2, h3, h4 { font-size: 1em; }
+  .method-description > h2, h3, h4, h5, h6 { font-size: 1em; }
 
   .method-heading {
     font-weight: bold;

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

@@ -19,7 +19,7 @@ module Docs
         css('hr').remove
 
         # Remove paragraph/up links
-        css('h1 > span', 'h2 > span', 'h3 > span', 'h4 > span').remove
+        css('h1 > span', 'h2 > span', 'h3 > span', 'h4 > span', 'h5 > span', 'h6 > span').remove
 
         # Move id attributes to headings
         css('.method-detail').each do |node|

+ 9 - 2
lib/docs/filters/rdoc/entries.rb

@@ -19,6 +19,10 @@ module Docs
         type
       end
 
+      def include_default_entry?
+        at_css('#description p') || css('.documentation-section').any? { |node| node.content.present? }
+      end
+
       def additional_entries
         return [] if root_page?
         require 'cgi'
@@ -29,9 +33,12 @@ module Docs
           name.sub! %r{\A-(?!\d)}, ''
           name.gsub! '-', '%'
           name = CGI.unescape(name)
-          name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
 
-          entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
+          unless name.start_with? '_'
+            name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
+            entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
+          end
+
           entries
         end
       end

+ 0 - 3
lib/docs/scrapers/rdoc/ruby.rb

@@ -29,15 +29,12 @@ module Docs
 
     options[:skip] += %w(
       fatal.html
-      unknown.html
       CompositePublisher.html
       Data.html
       E2MM.html
       English.html
       Exception2MessageMapper.html
-      EXCEPTION_TYPE.html
       GServer.html
-      Logging.html
       MakeMakefile.html
       ParallelEach.html
       Requirement.html