History

Improve Ruby/RDoc scraper

Thibaut committed 12 years ago

Commit 1eed7c71 parent 706270d4 files · +11 −7Browse files

Unified · Split

4 files
  1. assets/stylesheets/pages/_rdoc.scss +1 −1
  2. lib/docs/filters/rdoc/clean_html.rb +1 −1
  3. lib/docs/filters/rdoc/entries.rb +9 −2
  4. lib/docs/scrapers/rdoc/ruby.rb +0 −3
assets/stylesheets/pages/_rdoc.scss+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
3 > .description > h2, .section-header { @extend %block-heading; }3 > .description > h2, .section-header { @extend %block-heading; }
4 > .description > h2, .section-header, .method-heading { margin-left: -1rem; }4 > .description > h2, .section-header, .method-heading { margin-left: -1rem; }
5 .description > h1 { font-size: 1rem; }5 .description > h1 { font-size: 1rem; }
6 .method-description > h2, h3, h4 { font-size: 1em; }6 .method-description > h2, h3, h4, h5, h6 { font-size: 1em; }
7 7
8 .method-heading {8 .method-heading {
9 font-weight: bold;9 font-weight: bold;
lib/docs/filters/rdoc/clean_html.rb+1−1
@@ -19,7 +19,7 @@ module Docs · 18 unmodified lines
19 css('hr').remove19 css('hr').remove
20 20
21 # Remove paragraph/up links21 # Remove paragraph/up links
22 css('h1 > span', 'h2 > span', 'h3 > span', 'h4 > span').remove22 css('h1 > span', 'h2 > span', 'h3 > span', 'h4 > span', 'h5 > span', 'h6 > span').remove
23 23
24 # Move id attributes to headings24 # Move id attributes to headings
25 css('.method-detail').each do |node|25 css('.method-detail').each do |node|
lib/docs/filters/rdoc/entries.rb+9−2
@@ -19,6 +19,10 @@ module Docs · 18 unmodified lines
19 type19 type
20 end20 end
21 21
22 def include_default_entry?
23 at_css('#description p') || css('.documentation-section').any? { |node| node.content.present? }
24 end
25
22 def additional_entries26 def additional_entries
23 return [] if root_page?27 return [] if root_page?
24 require 'cgi'28 require 'cgi'
@@ -29,9 +33,12 @@ module Docs · 4 unmodified lines
29 name.sub! %r{\A-(?!\d)}, ''33 name.sub! %r{\A-(?!\d)}, ''
30 name.gsub! '-', '%'34 name.gsub! '-', '%'
31 name = CGI.unescape(name)35 name = CGI.unescape(name)
32 name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
33 36
34 entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }37 unless name.start_with? '_'
38 name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
39 entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
40 end
41
35 entries42 entries
36 end43 end
37 end44 end
lib/docs/scrapers/rdoc/ruby.rb+0−3
@@ -29,15 +29,12 @@ module Docs · 28 unmodified lines
29 29
30 options[:skip] += %w(30 options[:skip] += %w(
31 fatal.html31 fatal.html
32 unknown.html
33 CompositePublisher.html32 CompositePublisher.html
34 Data.html33 Data.html
35 E2MM.html34 E2MM.html
36 English.html35 English.html
37 Exception2MessageMapper.html36 Exception2MessageMapper.html
38 EXCEPTION_TYPE.html
39 GServer.html37 GServer.html
40 Logging.html
41 MakeMakefile.html38 MakeMakefile.html
42 ParallelEach.html39 ParallelEach.html
43 Requirement.html40 Requirement.html