From 7c1bd6b236f930c8c346bbad1b3ca5ee646b3141 Mon Sep 17 00:00:00 2001 From: Thibaut Date: Mon, 18 Nov 2013 12:49:56 +0100 Subject: [PATCH] Improve Ruby/RDoc scraper --- lib/docs/filters/rdoc/entries.rb | 6 ++- lib/docs/scrapers/rdoc/ruby.rb | 66 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/lib/docs/filters/rdoc/entries.rb b/lib/docs/filters/rdoc/entries.rb index 9ba187df..e9a1bcb7 100644 --- a/lib/docs/filters/rdoc/entries.rb +++ b/lib/docs/filters/rdoc/entries.rb @@ -23,14 +23,16 @@ module Docs return [] if root_page? require 'cgi' - css('.method-detail').map do |node| + css('.method-detail').inject [] do |entries, node| name = node['id'].dup name.sub! %r{\A\w+?\-.}, '' name.sub! %r{\A-(?!\d)}, '' name.gsub! '-', '%' name = CGI.unescape(name) name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#') - [name, node['id']] + + entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name } + entries end end end diff --git a/lib/docs/scrapers/rdoc/ruby.rb b/lib/docs/scrapers/rdoc/ruby.rb index 94cb1aad..9a04d62b 100644 --- a/lib/docs/scrapers/rdoc/ruby.rb +++ b/lib/docs/scrapers/rdoc/ruby.rb @@ -1,38 +1,24 @@ module Docs class Ruby < Rdoc # Generated with: - # rdoc \ - # --format=darkfish \ - # --no-line-numbers \ - # --op=rdoc \ - # --visibility=public \ + # find \ # *.c \ - # lib/**/*.rb \ - # lib/*.rb \ - # ext/bigdecimal/*.c \ - # ext/bigdecimal/lib/*.rb \ - # ext/bigdecimal/lib/**/*.rb \ - # ext/date/*.c \ - # ext/date/lib/*.rb \ - # ext/date/lib/**/*.rb \ - # ext/digest/*.c \ - # ext/digest/**/*.c \ - # ext/digest/**/*.rb \ - # ext/json/lib/**/*.rb \ - # ext/pathname/*.c \ - # ext/pathname/lib/*.rb \ - # ext/psych/*.c \ - # ext/psych/lib/*.rb \ - # ext/psych/lib/**/*.rb \ - # ext/readline/*.c \ - # ext/ripper/*.c \ - # ext/ripper/lib/*.rb \ - # ext/ripper/lib/**/*.rb \ - # ext/socket/*.c \ - # ext/socket/lib/*.rb \ - # ext/socket/lib/**/*.rb \ - # ext/stringio/*.c \ - # ext/zlib/*.c + # lib \ + # ext/bigdecimal \ + # ext/date \ + # ext/digest \ + # ext/json \ + # ext/pathname \ + # ext/psych \ + # ext/readline \ + # ext/ripper \ + # ext/socket \ + # ext/stringio \ + # ext/zlib \ + # \( -name '*.c' -or -name '*.rb' \) \ + # -not -wholename '*sample/*' \ + # | xargs \ + # rdoc --format=darkfish --no-line-numbers --op=rdoc --visibility=public self.version = '2.0.0' self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby' @@ -44,36 +30,48 @@ 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 + SshDirPublisher.html + SshFilePublisher.html + SshFreshDirPublisher.html + Sys.html YAML/DBM.html) options[:skip_patterns] = [ /\AComplex/, + /\AJSON\/Ext/, /\AGem/, - /\AHttpServer/, + /\AHTTP/i, /\AIRB/, /\AMiniTest/i, + /\ANet\/(?!HTTP)/, /\ANQXML/, /\AOpenSSL/, + /\AOptionParser\//, /\APride/, + /\APsych\//, /\ARacc/, /\ARake/, /\ARbConfig/, /\ARDoc/, /\AREXML/, /\ARSS/, + /\AShell\//, + /\ASocket\//, /\ATest/, /\AWEBrick/, /\AXML/, - /\AXMP/ - ] + /\AXMP/] options[:attribution] = <<-HTML Ruby Core © 1993–2013 Yukihiro Matsumoto