History

Improve Ruby/RDoc scraper

Thibaut committed 12 years ago

Commit 7c1bd6b1 parent 49de7362 files · +36 −36Browse files

Unified · Split

2 files
  1. lib/docs/filters/rdoc/entries.rb +4 −2
  2. lib/docs/scrapers/rdoc/ruby.rb +32 −34
lib/docs/filters/rdoc/entries.rb+4−2
@@ -23,14 +23,16 @@ module Docs · 22 unmodified lines
23 return [] if root_page?23 return [] if root_page?
24 require 'cgi'24 require 'cgi'
25 25
26 css('.method-detail').map do |node|26 css('.method-detail').inject [] do |entries, node|
27 name = node['id'].dup27 name = node['id'].dup
28 name.sub! %r{\A\w+?\-.}, ''28 name.sub! %r{\A\w+?\-.}, ''
29 name.sub! %r{\A-(?!\d)}, ''29 name.sub! %r{\A-(?!\d)}, ''
30 name.gsub! '-', '%'30 name.gsub! '-', '%'
31 name = CGI.unescape(name)31 name = CGI.unescape(name)
32 name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')32 name.prepend self.name + (node['id'] =~ /\A\w+-c-/ ? '::' : '#')
33 [name, node['id']]33
34 entries << [name, node['id']] unless entries.any? { |entry| entry[0] == name }
35 entries
34 end36 end
35 end37 end
36 end38 end
lib/docs/scrapers/rdoc/ruby.rb+32−34
@@ -1,38 +1,24 @@
1module Docs1module Docs
2 class Ruby < Rdoc2 class Ruby < Rdoc
3 # Generated with:3 # Generated with:
4 # rdoc \4 # find \
5 # --format=darkfish \
6 # --no-line-numbers \
7 # --op=rdoc \
8 # --visibility=public \
9 # *.c \5 # *.c \
10 # lib/**/*.rb \6 # lib \
11 # lib/*.rb \7 # ext/bigdecimal \
12 # ext/bigdecimal/*.c \8 # ext/date \
13 # ext/bigdecimal/lib/*.rb \9 # ext/digest \
14 # ext/bigdecimal/lib/**/*.rb \10 # ext/json \
15 # ext/date/*.c \11 # ext/pathname \
16 # ext/date/lib/*.rb \12 # ext/psych \
17 # ext/date/lib/**/*.rb \13 # ext/readline \
18 # ext/digest/*.c \14 # ext/ripper \
19 # ext/digest/**/*.c \15 # ext/socket \
20 # ext/digest/**/*.rb \16 # ext/stringio \
21 # ext/json/lib/**/*.rb \17 # ext/zlib \
22 # ext/pathname/*.c \18 # \( -name '*.c' -or -name '*.rb' \) \
23 # ext/pathname/lib/*.rb \19 # -not -wholename '*sample/*' \
24 # ext/psych/*.c \20 # | xargs \
25 # ext/psych/lib/*.rb \21 # rdoc --format=darkfish --no-line-numbers --op=rdoc --visibility=public
26 # ext/psych/lib/**/*.rb \
27 # ext/readline/*.c \
28 # ext/ripper/*.c \
29 # ext/ripper/lib/*.rb \
30 # ext/ripper/lib/**/*.rb \
31 # ext/socket/*.c \
32 # ext/socket/lib/*.rb \
33 # ext/socket/lib/**/*.rb \
34 # ext/stringio/*.c \
35 # ext/zlib/*.c
36 22
37 self.version = '2.0.0'23 self.version = '2.0.0'
38 self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby'24 self.dir = '/Users/Thibaut/DevDocs/Docs/RDoc/Ruby'
@@ -44,36 +30,48 @@ module Docs · 5 unmodified lines
44 options[:skip] += %w(30 options[:skip] += %w(
45 fatal.html31 fatal.html
46 unknown.html32 unknown.html
33 CompositePublisher.html
47 Data.html34 Data.html
48 E2MM.html35 E2MM.html
49 English.html36 English.html
50 Exception2MessageMapper.html37 Exception2MessageMapper.html
38 EXCEPTION_TYPE.html
51 GServer.html39 GServer.html
40 Logging.html
52 MakeMakefile.html41 MakeMakefile.html
53 ParallelEach.html42 ParallelEach.html
54 Requirement.html43 Requirement.html
44 SshDirPublisher.html
45 SshFilePublisher.html
46 SshFreshDirPublisher.html
47 Sys.html
55 YAML/DBM.html)48 YAML/DBM.html)
56 49
57 options[:skip_patterns] = [50 options[:skip_patterns] = [
58 /\AComplex/,51 /\AComplex/,
52 /\AJSON\/Ext/,
59 /\AGem/,53 /\AGem/,
60 /\AHttpServer/,54 /\AHTTP/i,
61 /\AIRB/,55 /\AIRB/,
62 /\AMiniTest/i,56 /\AMiniTest/i,
57 /\ANet\/(?!HTTP)/,
63 /\ANQXML/,58 /\ANQXML/,
64 /\AOpenSSL/,59 /\AOpenSSL/,
60 /\AOptionParser\//,
65 /\APride/,61 /\APride/,
62 /\APsych\//,
66 /\ARacc/,63 /\ARacc/,
67 /\ARake/,64 /\ARake/,
68 /\ARbConfig/,65 /\ARbConfig/,
69 /\ARDoc/,66 /\ARDoc/,
70 /\AREXML/,67 /\AREXML/,
71 /\ARSS/,68 /\ARSS/,
69 /\AShell\//,
70 /\ASocket\//,
72 /\ATest/,71 /\ATest/,
73 /\AWEBrick/,72 /\AWEBrick/,
74 /\AXML/,73 /\AXML/,
75 /\AXMP/74 /\AXMP/]
76 ]
77 75
78 options[:attribution] = <<-HTML76 options[:attribution] = <<-HTML
79 Ruby Core &copy; 1993&ndash;2013 Yukihiro Matsumoto<br>77 Ruby Core &copy; 1993&ndash;2013 Yukihiro Matsumoto<br>