rdoc_osx_dictionary 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +13 -0
- data/README.txt +2 -0
- data/bin/rdoc_osx_dictionary +1 -1
- data/lib/rdoc_osx_dictionary.rb +99 -50
- metadata +4 -2
data/History.txt
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
=== 1.3.0 / 2010-02-09
|
2
|
+
|
3
|
+
* 4 minor enhancements:
|
4
|
+
|
5
|
+
* Improved hyperlinks in class definitions to point straight at methods.
|
6
|
+
* Improved method signature output (imajes)
|
7
|
+
* Made method signature a pre block to improve display of space formatted text.
|
8
|
+
* Refactored and improved class output to clearly define class extensions.
|
9
|
+
|
10
|
+
* 1 bug fix:
|
11
|
+
|
12
|
+
* Specify exactly which ruby to execute (hinegardner)
|
13
|
+
|
1
14
|
=== 1.2.0 / 2010-02-03
|
2
15
|
|
3
16
|
* 3 minor enhancements:
|
data/README.txt
CHANGED
@@ -7,6 +7,8 @@
|
|
7
7
|
rdoc via Apple's Dictionary.app. Automatically builds and installs an
|
8
8
|
Apple Dictionary with all rdoc nicely formatted.
|
9
9
|
|
10
|
+
Inspired by: http://priithaamer.com/blog/ruby-on-rails-dictionary-for-macosx
|
11
|
+
|
10
12
|
== FEATURES/PROBLEMS:
|
11
13
|
|
12
14
|
* Automatically builds and installs an Apple Dictionary with all rdoc
|
data/bin/rdoc_osx_dictionary
CHANGED
data/lib/rdoc_osx_dictionary.rb
CHANGED
@@ -3,20 +3,21 @@
|
|
3
3
|
require 'fileutils'
|
4
4
|
require 'rdoc/ri/driver'
|
5
5
|
|
6
|
+
$q ||= false
|
7
|
+
|
6
8
|
# Forces /bin/tr to ignore badly formatted "unicode". (no clue where from)
|
7
9
|
ENV['LANG'] = ""
|
8
10
|
ENV['LC_ALL'] = "C"
|
9
11
|
|
10
12
|
class RDoc::OSXDictionary
|
11
|
-
VERSION = '1.
|
12
|
-
|
13
|
-
exclude = %w[ StringScanner#pre_match
|
14
|
-
StringScanner#post_match
|
15
|
-
Gem::Package::TarInput
|
16
|
-
IRB::OutputMethod
|
17
|
-
]
|
13
|
+
VERSION = '1.3.0'
|
18
14
|
|
19
|
-
EXCLUDE =
|
15
|
+
EXCLUDE = {
|
16
|
+
"StringScanner#pre_match" => true,
|
17
|
+
"StringScanner#post_match" => true,
|
18
|
+
"Gem::Package::TarInput" => true,
|
19
|
+
"IRB::OutputMethod" => true,
|
20
|
+
}
|
20
21
|
|
21
22
|
NAME_MAP = {
|
22
23
|
'!' => 'bang',
|
@@ -55,75 +56,108 @@ class RDoc::OSXDictionary
|
|
55
56
|
}.reverse.join("|"))
|
56
57
|
|
57
58
|
|
59
|
+
def id *args
|
60
|
+
args.map { |s| s.gsub(/:/, ',') }.join(",").gsub(/#{NAME_MAP_RE}/) { |x|
|
61
|
+
",#{NAME_MAP[x]}"
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
58
65
|
def display_class_info definition
|
59
66
|
name = definition["name"]
|
60
67
|
fullname = definition["full_name"]
|
61
68
|
supername = definition["superclass"]
|
62
|
-
includes = (definition["includes"]||[]).join(", ")
|
63
|
-
classmeths = definition["class_methods"].map { |hash| hash["name"] }
|
64
|
-
instmeths = definition["instance_methods"].map { |hash| hash["name"] }
|
65
69
|
type = supername ? "class" : "module"
|
66
70
|
title = supername ? "class #{fullname} < #{supername}" : "module #{fullname}"
|
67
71
|
comment = Array(definition["comment"]).join("\n")
|
68
|
-
constants = Array(definition["constants"])
|
69
|
-
sources = definition["sources"].map { |path|
|
70
|
-
next if path =~ /^.System/
|
71
|
-
path.sub(%r%^.*?1\.[89]/doc/([^/]+).*%, '\1')
|
72
|
-
}.compact
|
73
72
|
|
74
|
-
|
73
|
+
definition["includes"].map! { |c| c["name"] }
|
74
|
+
definition["constants"].map! { |c| c["name"] }
|
75
75
|
|
76
|
-
|
76
|
+
return if $q and fullname !~ /^(String|Array|Bignum)/
|
77
|
+
|
78
|
+
comment = "Improperly formatted" if EXCLUDE[fullname]
|
77
79
|
|
78
80
|
result = []
|
79
81
|
|
80
82
|
shortname = "<d:index d:value=#{name.munge.inspect}/>" if name != fullname
|
81
83
|
|
82
84
|
result << <<-"EOD".gsub(/^ /, '')
|
83
|
-
<d:entry id="#{id}" d:title="#{fullname}">
|
85
|
+
<d:entry id="#{id type, fullname}" d:title="#{fullname}">
|
84
86
|
<d:index d:value="#{fullname.munge}"/>
|
85
87
|
#{shortname}
|
86
88
|
<h1>#{title.munge}</h1>
|
87
89
|
|
88
90
|
#{comment}
|
89
|
-
|
91
|
+
EOD
|
92
|
+
|
93
|
+
extensions = []
|
94
|
+
|
95
|
+
definition["sources"].shift # remove first one as the original source
|
96
|
+
definition["sources"].each do |path|
|
97
|
+
next if path =~ /^.System/
|
98
|
+
|
99
|
+
gemname = File.basename(path.sub(%r(/ri/\w+/cdesc-\w+.yaml), ''))
|
100
|
+
extension = YAML.load File.read(path).gsub(/- !.+/, '-')
|
101
|
+
|
102
|
+
extension["includes"].map! { |c| c["name"] }
|
103
|
+
extension["constants"].map! { |c| c["name"] }
|
90
104
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
[ext, sources, ext_type]].each do |n, s, t|
|
100
|
-
next if s.empty?
|
101
|
-
case t
|
102
|
-
when :str then
|
103
|
-
result << "<h3>#{n}:</h3><p>#{s}</p>"
|
104
|
-
when :list then
|
105
|
-
items = s.map { |o| "<li>#{o}</li>" }.join("\n")
|
106
|
-
result << "<h3>#{n}:</h3><ul>#{items}</ul>"
|
107
|
-
else
|
108
|
-
raise "unknown type #{t.inspect}"
|
105
|
+
detail = class_details(name, fullname, extension, 4)
|
106
|
+
|
107
|
+
next if detail.empty?
|
108
|
+
|
109
|
+
extensions << "<h3>#{gemname}:</h3>"
|
110
|
+
extensions << detail
|
111
|
+
%w(class_methods instance_methods includes constants).each do |k|
|
112
|
+
definition[k] -= extension[k]
|
109
113
|
end
|
110
114
|
end
|
111
115
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
end
|
116
|
+
result << class_details(name, fullname, definition)
|
117
|
+
result << "<h2>Extensions:</h2>" unless extensions.empty?
|
118
|
+
result << extensions
|
116
119
|
|
117
120
|
result << <<-"EOD".gsub(/^ /, '')
|
118
121
|
</d:entry>
|
119
|
-
|
122
|
+
EOD
|
120
123
|
result.join("\n")
|
121
124
|
end
|
122
125
|
|
126
|
+
def class_details name, fullname, definition, level = 2
|
127
|
+
h = "h#{level}"
|
128
|
+
result = []
|
129
|
+
includes = definition["includes"]
|
130
|
+
constants = definition["constants"]
|
131
|
+
|
132
|
+
classmeths = definition["class_methods"].map { |hash|
|
133
|
+
name = hash["name"]
|
134
|
+
"<a href=\"x-dictionary:r:#{id "defs", fullname, name}\">#{name}</a>"
|
135
|
+
}
|
136
|
+
|
137
|
+
instmeths = definition["instance_methods"].map { |hash|
|
138
|
+
name = hash["name"]
|
139
|
+
"<a href=\"x-dictionary:r:#{id "def", fullname, name}\">#{name.munge}</a>"
|
140
|
+
}
|
141
|
+
|
142
|
+
[["Includes", includes],
|
143
|
+
["Constants", constants],
|
144
|
+
["Class Methods", classmeths],
|
145
|
+
["Instance Methods", instmeths],
|
146
|
+
].each do |n, a|
|
147
|
+
next if a.empty?
|
148
|
+
|
149
|
+
result << "<#{h}>#{n}:</#{h}><p>#{a.join ", "}</p>"
|
150
|
+
end
|
151
|
+
|
152
|
+
result
|
153
|
+
end
|
154
|
+
|
123
155
|
def display_method_info definition
|
124
156
|
fullname = definition["full_name"]
|
157
|
+
klass = definition["class"]
|
125
158
|
name = definition["name"]
|
126
|
-
|
159
|
+
|
160
|
+
return if $q and klass !~ /^(String|Array|Bignum)/
|
127
161
|
|
128
162
|
return if name =~ /_reduce_\d+/
|
129
163
|
|
@@ -133,19 +167,32 @@ class RDoc::OSXDictionary
|
|
133
167
|
|
134
168
|
comment = "Improperly formatted" if EXCLUDE[fullname]
|
135
169
|
|
170
|
+
type = definition["is_singleton"] ? "defs" : "def"
|
171
|
+
|
172
|
+
# TODO: aliases don't have recv
|
173
|
+
# TODO: some regular methods don't have recv
|
174
|
+
|
136
175
|
result = <<-"EOD".gsub(/^ /, '')
|
137
|
-
<d:entry id="
|
176
|
+
<d:entry id="#{id type, klass, name}" d:title="#{fullname.munge}">
|
138
177
|
<d:index d:value="#{fullname.munge}"/>
|
139
178
|
<d:index d:value="#{name.munge}"/>
|
140
179
|
<h1>#{fullname.munge}</h1>
|
141
|
-
<
|
142
|
-
|
143
|
-
</
|
180
|
+
<pre class="signatures">
|
181
|
+
#{d_signatures(name, params)}
|
182
|
+
</pre>
|
144
183
|
#{comment}
|
145
184
|
</d:entry>
|
146
185
|
EOD
|
147
186
|
end
|
148
187
|
|
188
|
+
def d_signatures name, params
|
189
|
+
result = " "
|
190
|
+
if params.strip =~ /^\(/
|
191
|
+
result << "<b>#{name.munge}</b>"
|
192
|
+
end
|
193
|
+
result << "<b>#{params.munge.gsub(/\n/, "<br />")}</b>"
|
194
|
+
end
|
195
|
+
|
149
196
|
def d_header
|
150
197
|
result = <<-"EOD"
|
151
198
|
<?xml version="1.0" encoding="UTF-8"?>
|
@@ -225,6 +272,7 @@ class RDoc::OSXDictionary
|
|
225
272
|
result << d_entry(klass, dict[klass], true)
|
226
273
|
|
227
274
|
methods.each do |k,v|
|
275
|
+
v["class"] = klass
|
228
276
|
result << d_entry(k, v)
|
229
277
|
end
|
230
278
|
|
@@ -291,7 +339,8 @@ class RDoc::OSXDictionary
|
|
291
339
|
def self.install_gem_hooks
|
292
340
|
return if @hooked[:hook]
|
293
341
|
|
294
|
-
|
342
|
+
rdoc_osx_dictionary_path = File.expand_path File.join(__FILE__, "../../bin/rdoc_osx_dictionary")
|
343
|
+
cmd = "#{Gem.ruby} #{rdoc_osx_dictionary_path}"
|
295
344
|
|
296
345
|
# post_install isn't actually fully post-install... so I must
|
297
346
|
# force via at_exit :(
|
@@ -321,7 +370,7 @@ end
|
|
321
370
|
|
322
371
|
class String
|
323
372
|
def munge
|
324
|
-
self.gsub(/&/, '&').gsub(/>/, '>').gsub(/</, '<').gsub(/-/, '
|
373
|
+
self.gsub(/&/, '&').gsub(/>/, '>').gsub(/</, '<').gsub(/-/, '-')
|
325
374
|
end
|
326
375
|
end
|
327
376
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rdoc_osx_dictionary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-02-
|
12
|
+
date: 2010-02-09 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -65,6 +65,8 @@ dependencies:
|
|
65
65
|
description: |-
|
66
66
|
rdoc via Apple's Dictionary.app. Automatically builds and installs an
|
67
67
|
Apple Dictionary with all rdoc nicely formatted.
|
68
|
+
|
69
|
+
Inspired by: http://priithaamer.com/blog/ruby-on-rails-dictionary-for-macosx
|
68
70
|
email:
|
69
71
|
- ryand-ruby@zenspider.com
|
70
72
|
executables:
|