From b58bc8bc58d225c21ac98e793028f2739bea59ef Mon Sep 17 00:00:00 2001 From: Thibaut Date: Sun, 28 Dec 2014 18:26:36 -0500 Subject: [PATCH] Improve abstract rdoc scraper --- assets/stylesheets/pages/_rdoc.scss | 2 +- lib/docs/filters/rdoc/container.rb | 4 +++- lib/docs/filters/rdoc/entries.rb | 4 +++- lib/docs/scrapers/rdoc/rails.rb | 2 +- lib/docs/scrapers/rdoc/rdoc.rb | 7 ++++++- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/assets/stylesheets/pages/_rdoc.scss b/assets/stylesheets/pages/_rdoc.scss index 7fdf6b91..ae18b323 100644 --- a/assets/stylesheets/pages/_rdoc.scss +++ b/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; } diff --git a/lib/docs/filters/rdoc/container.rb b/lib/docs/filters/rdoc/container.rb index b8719803..fb6d3d2e 100644 --- a/lib/docs/filters/rdoc/container.rb +++ b/lib/docs/filters/rdoc/container.rb @@ -19,7 +19,9 @@ module Docs meta << %(
Included modules:
#{includes.css('a').map(&:to_html).join(', ')}
) end - container.at_css('h1').after(meta) + if parent || includes + container.at_css('h1').after(meta) + end container end diff --git a/lib/docs/filters/rdoc/entries.rb b/lib/docs/filters/rdoc/entries.rb index f20e21ea..c62754bf 100644 --- a/lib/docs/filters/rdoc/entries.rb +++ b/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 diff --git a/lib/docs/scrapers/rdoc/rails.rb b/lib/docs/scrapers/rdoc/rails.rb index 3ebb95a0..678a18aa 100644 --- a/lib/docs/scrapers/rdoc/rails.rb +++ b/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/, diff --git a/lib/docs/scrapers/rdoc/rdoc.rb b/lib/docs/scrapers/rdoc/rdoc.rb index 7dd82388..0110d513 100644 --- a/lib/docs/scrapers/rdoc/rdoc.rb +++ b/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