From 1eed7c77785ce810e3fe359a404d38e8d05ad752 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 18 Nov 2013 23:21:03 +0100 Subject: [PATCH] Improve Ruby/RDoc scraper --- assets/stylesheets/pages/_rdoc.scss | 2 +- lib/docs/filters/rdoc/clean_html.rb | 2 +- lib/docs/filters/rdoc/entries.rb | 11 +++++++++-- lib/docs/scrapers/rdoc/ruby.rb | 3 --- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/assets/stylesheets/pages/_rdoc.scss b/assets/stylesheets/pages/_rdoc.scss index 572a28dc..8f9ebde4 100644 --- a/assets/stylesheets/pages/_rdoc.scss +++ b/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; diff --git a/lib/docs/filters/rdoc/clean_html.rb b/lib/docs/filters/rdoc/clean_html.rb index 9928d31b..f5d15f64 100644 --- a/lib/docs/filters/rdoc/clean_html.rb +++ b/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| diff --git a/lib/docs/filters/rdoc/entries.rb b/lib/docs/filters/rdoc/entries.rb index e9a1bcb7..0f8231c0 100644 --- a/lib/docs/filters/rdoc/entries.rb +++ b/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 diff --git a/lib/docs/scrapers/rdoc/ruby.rb b/lib/docs/scrapers/rdoc/ruby.rb index 9a04d62b..6397df6b 100644 --- a/lib/docs/scrapers/rdoc/ruby.rb +++ b/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