langhelp 0.9.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changes +2530 -0
- data/bin/mklanghelp +50 -0
- data/data/langhelp/config.sample +889 -0
- data/files +39 -0
- data/graphviz-dot.jpg +0 -0
- data/langhelp.en.html +409 -0
- data/langhelp.en.rd +390 -0
- data/langhelp.ja.html +524 -0
- data/langhelp.ja.rd +487 -0
- data/lib/el4r/emacsruby/autoload/50langhelp.rb +2 -0
- data/lib/el4r/emacsruby/langhelp.rb +864 -0
- data/lib/el4r/emacsruby/test-langhelp.rb +300 -0
- data/lib/langhelp/langhelp-base.rb +649 -0
- data/lib/langhelp/langhelp-sub.rb +1023 -0
- data/lib/langhelp/lh_lua.rb +25 -0
- data/lib/langhelp/lh_perl.rb +112 -0
- data/lib/langhelp/lh_php.rb +34 -0
- data/lib/langhelp/lh_python.rb +31 -0
- data/lib/langhelp/lh_ruby.rb +400 -0
- data/lib/langhelp/mklanghelp.rb +140 -0
- data/lib/langhelp/parse-info.rb +145 -0
- data/ri.jpg +0 -0
- data/setup.rb +1551 -0
- data/test/a_classes.lst +2 -0
- data/test/a_methods.lst +2 -0
- data/test/b_classes.lst +2 -0
- data/test/b_methods.lst +2 -0
- data/test/c_methods.lst +4 -0
- data/test/common.rb +15 -0
- data/test/d_methods.lst +4 -0
- data/test/langhelp.e +566 -0
- data/test/ruby.e +3 -0
- data/test/tagify01-before.html +11 -0
- data/test/tagify02-before.html +11 -0
- data/test/test-base.rb +538 -0
- data/test/test-command.rb +92 -0
- data/test/test-parse-info.rb +175 -0
- data/test/test-ruby.rb +242 -0
- data/test/testdoc.rd +6 -0
- metadata +84 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
#
|
2
|
+
# lh_lua.rb - Create langhelp index of Lua language
|
3
|
+
# Copyright (C) 2005 rubikitch <rubikitch@ruby-lang.org>
|
4
|
+
# Version: $Id: lh_lua.rb 1364 2006-09-04 01:31:11Z rubikitch $
|
5
|
+
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
require 'langhelp/langhelp-base'
|
19
|
+
class LuaHelp < AbstractIndex
|
20
|
+
def to_e(out)
|
21
|
+
`luahelp index`.split.sort.each do |idx|
|
22
|
+
out << format(%Q[# (lh-luahelp "%s")\n], idx)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
#
|
2
|
+
# lh_perl.rb - Create langhelp index of Perl language
|
3
|
+
# Copyright (C) 2005 rubikitch <rubikitch@ruby-lang.org>
|
4
|
+
# Version: $Id: lh_perl.rb 1190 2006-02-08 09:32:55Z rubikitch $
|
5
|
+
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
|
19
|
+
require 'langhelp/langhelp-base'
|
20
|
+
|
21
|
+
class PodSections < AbstractIndex
|
22
|
+
def init(x={})
|
23
|
+
@perl_pod = x[:perl_pod]
|
24
|
+
normalize_filename! @perl_pod
|
25
|
+
end
|
26
|
+
|
27
|
+
def process_pod(pod_source)
|
28
|
+
@sections = []
|
29
|
+
|
30
|
+
heads = {}
|
31
|
+
head_order = []
|
32
|
+
head = nil
|
33
|
+
pod_source.split(/\n/).each do |line|
|
34
|
+
case line
|
35
|
+
when /^=head\d (.+)$/
|
36
|
+
head = $1
|
37
|
+
heads[head] = []
|
38
|
+
head_order << head
|
39
|
+
when /^\s+(perl\w+)\t+(.+)$/
|
40
|
+
heads[head] << [$1, $2]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
head_order.each do |head|
|
45
|
+
heads[head].each do |pod, desc|
|
46
|
+
#printf "%-20s %s\n", pod, desc
|
47
|
+
@sections << [head, pod, desc]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_e(out)
|
53
|
+
process_pod(File.read(@perl_pod))
|
54
|
+
@sections.each do |head, pod, desc|
|
55
|
+
out << format("# %-15s : %s / %-40s#{SPACES}(lh-podsections %s)\n",
|
56
|
+
pod, head, desc, lisp_dump_string(pod))
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class PerlFunc < AbstractIndex
|
62
|
+
def init(x={})
|
63
|
+
@perlfunc_pod = x[:perlfunc_pod]
|
64
|
+
normalize_filename! @perlfunc_pod
|
65
|
+
end
|
66
|
+
|
67
|
+
FUNCLIST_BEGINS_FROM = /Alphabetical Listing of Perl Functions/
|
68
|
+
REJECT_REGEXP = /^\*$/
|
69
|
+
def extract_funcs(pod_source)
|
70
|
+
_, text = pod_source.split(FUNCLIST_BEGINS_FROM, 2)
|
71
|
+
@funcs = text.scan(/^=item (.+)$/).flatten.reject{|func| func =~ REJECT_REGEXP }.map {|usage|
|
72
|
+
name = usage.split(/[\s\(]/)[0]
|
73
|
+
name.sub!(/\/.+$/,'')
|
74
|
+
[ name, usage ]
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_e(out)
|
79
|
+
extract_funcs File.read(@perlfunc_pod)
|
80
|
+
@funcs.each do |name, usage|
|
81
|
+
out << format("# %-30s#{SPACES}(lh-perlfunc %s)\n", usage, lisp_dump_string(name))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
class PerlDoc < AbstractIndex
|
88
|
+
def init(x={})
|
89
|
+
@perl_path = x[:perl_path]
|
90
|
+
normalize_filename! *@perl_path
|
91
|
+
end
|
92
|
+
|
93
|
+
def collect_files
|
94
|
+
@modules = @perl_path.map {|dir|
|
95
|
+
modules = []
|
96
|
+
Dir.chdir(dir) do
|
97
|
+
[ Dir["**/*.pod"]+Dir["**/*.pm"]+Dir["**/*.pl"] ].flatten.each do |pod|
|
98
|
+
next if pod =~ /^pod\//
|
99
|
+
modules << pod.gsub(/\//, '::').gsub(/\.[^\.]+$/,'')
|
100
|
+
end
|
101
|
+
end
|
102
|
+
modules
|
103
|
+
}.flatten.sort.uniq
|
104
|
+
end
|
105
|
+
|
106
|
+
def to_e(out)
|
107
|
+
collect_files
|
108
|
+
@modules.each do |mod|
|
109
|
+
out << format("# %-30s#{SPACES}(lh-perldoc %s)\n", mod, lisp_dump_string(mod))
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# lh_php.rb - Create langhelp index of PHP language
|
3
|
+
# Copyright (C) 2005 rubikitch <rubikitch@ruby-lang.org>
|
4
|
+
# Version: $Id: lh_php.rb 1190 2006-02-08 09:32:55Z rubikitch $
|
5
|
+
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
|
18
|
+
class PHPManual < AbstractIndex
|
19
|
+
def init(x={})
|
20
|
+
@dir = arg1
|
21
|
+
@glob = x[:glob]
|
22
|
+
normalize_filename! @dir
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_e(out)
|
26
|
+
Dir[File.join(@dir, @glob)].each do |fullpath|
|
27
|
+
basename = File.basename fullpath
|
28
|
+
node = basename.sub(/\.html$/, '')
|
29
|
+
section, function = node.split(/\./,2)
|
30
|
+
function.gsub!(/-/, '_')
|
31
|
+
out << %Q!# #{function}#{SPACES}(lh-w3m "" #{lisp_dump_string(fullpath)})\n!
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# lh_python.rb - Create langhelp index of Python language
|
3
|
+
# Copyright (C) 2005 rubikitch <rubikitch@ruby-lang.org>
|
4
|
+
# Version: $Id: lh_python.rb 1190 2006-02-08 09:32:55Z rubikitch $
|
5
|
+
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
require 'langhelp/langhelp-base'
|
18
|
+
require 'langhelp/langhelp-sub'
|
19
|
+
|
20
|
+
class PythonLib < HTMLIndex
|
21
|
+
def untable_html(src=File.read(@index_page))
|
22
|
+
ut = UnTable.new
|
23
|
+
ut.untable(src)
|
24
|
+
end
|
25
|
+
|
26
|
+
def pre_process(src)
|
27
|
+
untable_html(src).gsub( %r!<dt><a href="(.+?)">(.+)</a>! ) {
|
28
|
+
%Q!<dt>#{$2}#{space}(lh-w3m nil "file://#{@dir}/#{$1}")\n!
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,400 @@
|
|
1
|
+
#
|
2
|
+
# lh_ruby.rb - Create langhelp index of Ruby language
|
3
|
+
# Copyright (C) 2005 rubikitch <rubikitch@ruby-lang.org>
|
4
|
+
# Version: $Id: lh_ruby.rb 1347 2006-08-20 15:26:37Z rubikitch $
|
5
|
+
|
6
|
+
# This program is free software; you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation; either version 2 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
# You should have received a copy of the GNU General Public License
|
15
|
+
# along with this program; if not, write to the Free Software
|
16
|
+
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
17
|
+
require 'kconv'
|
18
|
+
require 'langhelp/langhelp-base'
|
19
|
+
List = Struct.new(:source, :methods, :arg)
|
20
|
+
|
21
|
+
class << List
|
22
|
+
include LocalVariables
|
23
|
+
def methods_list_file(source, filename)
|
24
|
+
methods = File.read(filename).split(/\n/) rescue []
|
25
|
+
new(source, methods)
|
26
|
+
end
|
27
|
+
|
28
|
+
def methods_from_anchor(source, filename)
|
29
|
+
methods = File.read(filename).scan(/#{ANCHOR_BEGIN}(.+)#{ANCHOR_END}/).flatten
|
30
|
+
new(source, methods, filename)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
# Abstract class representing Index
|
36
|
+
class RubyIndex < AbstractIndex
|
37
|
+
|
38
|
+
# for debug purpose
|
39
|
+
def init(x={})
|
40
|
+
@x = x
|
41
|
+
end
|
42
|
+
|
43
|
+
# To adjust sort order.
|
44
|
+
# . -> \001, :: -> \002, # -> \003
|
45
|
+
def pack_method(name)
|
46
|
+
name.gsub(/\./){"\001"}.gsub(/::/){"\002"}.gsub(/#/){"\003"}
|
47
|
+
end
|
48
|
+
|
49
|
+
def unpack_method(name)
|
50
|
+
name.gsub(/\001/){"."}.gsub(/\002/){"::"}.gsub(/\003/){"#"}
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
def prepare
|
55
|
+
@lists = @x[:lists]
|
56
|
+
if @x[:sources]
|
57
|
+
@lists = @x[:sources].map{|source|
|
58
|
+
[ List.methods_list_file(source, "#{source}_methods.lst"),
|
59
|
+
List.methods_list_file(source, "#{source}_classes.lst"),
|
60
|
+
]
|
61
|
+
}.flatten
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Contents of Index by Array
|
66
|
+
def contents
|
67
|
+
prepare
|
68
|
+
_contents
|
69
|
+
end
|
70
|
+
|
71
|
+
def _contents
|
72
|
+
find_func = {}
|
73
|
+
args = {}
|
74
|
+
@lists.each do |list|
|
75
|
+
list.methods.each do |m|
|
76
|
+
m = pack_method(m) # To sort class_method -> instance_method order.
|
77
|
+
find_func[m]="lh-#{list.source}"
|
78
|
+
args[m] = list.arg
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
packed_methods = find_func.keys
|
83
|
+
packed_methods.sort.map{|packed|
|
84
|
+
m = unpack_method(packed)
|
85
|
+
# m = m.sub(/\./, '::') if find_func[packed] == 'lh-ri'
|
86
|
+
[find_func[packed], m, args[packed]].compact
|
87
|
+
}
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
# Output into e-script form
|
92
|
+
def to_e(out)
|
93
|
+
contents.each do |func, meth, arg|
|
94
|
+
out << format(%Q[# (%s "%s"], func, meth)
|
95
|
+
if arg
|
96
|
+
abbreviate_filename! arg
|
97
|
+
out << format(%Q[#{SPACES}"%s"], arg)
|
98
|
+
end
|
99
|
+
out << ")\n"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
module RefeCommon
|
105
|
+
def set_refe_root_dir(rootdir)
|
106
|
+
require 'refe/config'
|
107
|
+
if rootdir
|
108
|
+
@rootdir = rootdir
|
109
|
+
elsif ENV['REFE_DATA_DIR']
|
110
|
+
@rootdir = ENV['REFE_DATA_DIR']
|
111
|
+
elsif defined?(ReFe::REFE_DATA_DIR)
|
112
|
+
@rootdir = ReFe::REFE_DATA_DIR
|
113
|
+
else
|
114
|
+
raise ArgumentError, 'ReFe database directory not given'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
# Index by lh-refe
|
119
|
+
class Refe < RubyIndex
|
120
|
+
include RefeCommon
|
121
|
+
|
122
|
+
def init(x={})
|
123
|
+
@classes_lst = "refe_classes.lst"
|
124
|
+
@methods_lst = "refe_methods.lst"
|
125
|
+
set_refe_root_dir x[:root_dir]
|
126
|
+
normalize_filename! @rootdir
|
127
|
+
@class_document_comp = x[:class_document_comp] ||
|
128
|
+
"#{@rootdir}/class_document_comp"
|
129
|
+
@method_document_comp = x[:method_document_comp] ||
|
130
|
+
"#{@rootdir}/method_document_comp"
|
131
|
+
end
|
132
|
+
|
133
|
+
def prepare
|
134
|
+
generate_methods_and_classes
|
135
|
+
@lists = [
|
136
|
+
List.methods_list_file("refe", @classes_lst),
|
137
|
+
List.methods_list_file("refe", @methods_lst)
|
138
|
+
]
|
139
|
+
end
|
140
|
+
|
141
|
+
def generate_methods_and_classes(methods=@methods_lst, classes=@classes_lst, class_document_comp=@class_document_comp, method_document_comp=@method_document_comp)
|
142
|
+
File.readlines(method_document_comp).select{|line|
|
143
|
+
line !~ /^man.pack$|^man.sprintf$/ and line !~ /^@/
|
144
|
+
}.writef(methods)
|
145
|
+
|
146
|
+
File.readlines(class_document_comp).select{|line|
|
147
|
+
line !~ /^fatal$|^man$/
|
148
|
+
}.writef(classes)
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
class RefeC < AbstractIndex
|
155
|
+
include RefeCommon
|
156
|
+
def init(x={})
|
157
|
+
set_refe_root_dir x[:root_dir]
|
158
|
+
normalize_filename! @rootdir
|
159
|
+
@function_document_comp = "#{@rootdir}/function_document_comp"
|
160
|
+
end
|
161
|
+
|
162
|
+
def to_e(out)
|
163
|
+
File.read(@function_document_comp).split(/\n/).sort.each do |func|
|
164
|
+
out << format(%Q[# (lh-refec "%s")\n], func)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Index by lh-ri
|
170
|
+
require 'rdoc/ri/ri_paths'
|
171
|
+
class Ri < RubyIndex
|
172
|
+
def init(x={})
|
173
|
+
@ri_all = x[:ri_all] || "ri_all.lst"
|
174
|
+
@classes_lst = x[:classes_lst] || "ri_classes.lst"
|
175
|
+
@methods_lst = x[:methods_lst] || "ri_methods.lst"
|
176
|
+
@ri_path = x[:ri_path] || RI::Paths::PATH
|
177
|
+
normalize_filename! *@ri_path
|
178
|
+
end
|
179
|
+
|
180
|
+
def prepare
|
181
|
+
generate_ri_all
|
182
|
+
generate_methods_and_classes
|
183
|
+
@lists = [
|
184
|
+
List.methods_list_file("ri", @classes_lst),
|
185
|
+
List.methods_list_file("ri", @methods_lst)
|
186
|
+
]
|
187
|
+
end
|
188
|
+
|
189
|
+
def generate_ri_all(filename=@ri_all)
|
190
|
+
files = @ri_path.map{|dir| Dir["#{dir}/**/*"]}.flatten.select{|f|
|
191
|
+
File.file?(f)
|
192
|
+
}
|
193
|
+
methods = files.collect!{|f|
|
194
|
+
File.read(f).grep(/^full_name:/).map{|line|
|
195
|
+
pack_method(line.split(/:/,2)[1].to_s[1..-1].gsub(/\"/,""))
|
196
|
+
}
|
197
|
+
}
|
198
|
+
methods.flatten!
|
199
|
+
methods.compact!
|
200
|
+
methods.sort!
|
201
|
+
methods.uniq!
|
202
|
+
methods.collect!{|m| convert_colons2dot(unpack_method(m))}
|
203
|
+
methods.writef(filename)
|
204
|
+
end
|
205
|
+
|
206
|
+
=begin
|
207
|
+
FNAME : OPERATION
|
208
|
+
| `|' | `^' | `&' | `<=>' | `==' | `===' | `=~'
|
209
|
+
| `>' | `>=' | `<' | `<='
|
210
|
+
| `+' | `-' | `*' | `/' | `%' | `**'
|
211
|
+
| `<<' | `>>' | `~' | ``'
|
212
|
+
| `+@' | `-@' | `[]' | `[]='
|
213
|
+
=end
|
214
|
+
METHOD_NAME_FIRST_CHARS = 'a-z|^&<=>+*/%*~`\\-\\[\\]_'
|
215
|
+
def convert_colons2dot(method_name)
|
216
|
+
method_name.sub(/::([#{METHOD_NAME_FIRST_CHARS}][^:#]+)$/,'.\1')
|
217
|
+
end
|
218
|
+
|
219
|
+
|
220
|
+
def generate_methods_and_classes(methods=@methods_lst, classes=@classes_lst, ri_all=@ri_all)
|
221
|
+
open(methods, "w") do |meth|
|
222
|
+
open(classes, "w") do |klass|
|
223
|
+
File.read(ri_all).each do |line|
|
224
|
+
case line
|
225
|
+
when /[\.#]/
|
226
|
+
meth.puts line
|
227
|
+
else
|
228
|
+
klass.puts line
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
235
|
+
|
236
|
+
class AnchorIndex < RubyIndex
|
237
|
+
def init(x={})
|
238
|
+
init_converter # initialize by subclass
|
239
|
+
input_filename = arg1.dup
|
240
|
+
@body_e = x[:body] || generate_output_filename(input_filename)
|
241
|
+
normalize_filename! arg1, @body_e
|
242
|
+
end
|
243
|
+
|
244
|
+
def generate_output_filename(input_filename)
|
245
|
+
input_filename.sub(/~\//,'').gsub(/[\/\\\.]/,'_')+".txt"
|
246
|
+
end
|
247
|
+
|
248
|
+
def prepare
|
249
|
+
@conv = @Converter.new(File.read(arg1))
|
250
|
+
@conv.conf = conf
|
251
|
+
@conv.to_e(@body_e)
|
252
|
+
@lists = [List.methods_from_anchor("anchor", @body_e)]
|
253
|
+
end
|
254
|
+
|
255
|
+
def contents
|
256
|
+
prepare
|
257
|
+
|
258
|
+
list = @lists[0]
|
259
|
+
find_func = "lh-#{list.source}"
|
260
|
+
list.methods.map do |m|
|
261
|
+
[find_func, m, list.arg].compact
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
|
268
|
+
class MoonWolfRubyDoc < AnchorIndex
|
269
|
+
def init_converter() @Converter = MoonWolfRubyDocConverter end
|
270
|
+
end
|
271
|
+
|
272
|
+
# class RD < AnchorIndex
|
273
|
+
# def init_converter() @Converter = RDConverter end
|
274
|
+
# end
|
275
|
+
|
276
|
+
class RD < Grep
|
277
|
+
def init(x={})
|
278
|
+
@regexp = /^(=+|\s*:|\s*---)/
|
279
|
+
@src = arg1
|
280
|
+
@exclude = ["=begin", "=end"] + mkarray(x[:exclude])
|
281
|
+
normalize_filename! @src
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
|
286
|
+
class MoonWolfRubyDocConverter
|
287
|
+
def initialize(htmlsrc)
|
288
|
+
@input = htmlsrc.toeuc
|
289
|
+
end
|
290
|
+
attr_accessor :conf
|
291
|
+
|
292
|
+
def create_anchor
|
293
|
+
klass = nil
|
294
|
+
method_type = ""
|
295
|
+
output = ""
|
296
|
+
@input.each do |line|
|
297
|
+
case line
|
298
|
+
when /^#([A-Z].*)$/
|
299
|
+
klass = $1
|
300
|
+
line = "#" + "{{" + klass + "}}\n"
|
301
|
+
when /<h3>���饹��å�/
|
302
|
+
method_type = "."
|
303
|
+
when /<h3>��å�/
|
304
|
+
method_type = "#"
|
305
|
+
when /^(.*)(<dt[^>]*>)(self\[(.+)\]=(.+))$/ # self[]=
|
306
|
+
line = "#{$1}#{$2}{{#{klass}#{method_type}[]=}} #{$3}\n"
|
307
|
+
when /^(.*)(<dt[^>]*>)(self\[(.+)\])$/ # self[]
|
308
|
+
line = "#{$1}#{$2}{{#{klass}#{method_type}[]}} #{$3}\n"
|
309
|
+
when /^(.*)(<dt[^>]*>)(\w+)(.*)$/
|
310
|
+
line = "#{$1}#{$2}{{#{klass}#{method_type}#{$3}}}#{$4}\n"
|
311
|
+
end
|
312
|
+
output << line
|
313
|
+
end
|
314
|
+
output
|
315
|
+
end
|
316
|
+
|
317
|
+
include LocalVariables
|
318
|
+
include GeneratedMessage
|
319
|
+
def html2e(es_file)
|
320
|
+
IO.popen("#{conf[:HTML2TXT]} > #{es_file}", "w") do |w3m|
|
321
|
+
w3m.print self.create_anchor
|
322
|
+
end
|
323
|
+
essrc = File.read(es_file)
|
324
|
+
open(es_file, "w") do |es|
|
325
|
+
es << essrc.gsub(/\{\{/, ANCHOR_BEGIN).gsub(/\}\}/, ANCHOR_END)
|
326
|
+
insert_local_variables es
|
327
|
+
end
|
328
|
+
generated es_file
|
329
|
+
end
|
330
|
+
|
331
|
+
alias :to_e :html2e
|
332
|
+
end
|
333
|
+
|
334
|
+
|
335
|
+
class RDConverter
|
336
|
+
def initialize(rdsrc)
|
337
|
+
@input = rdsrc
|
338
|
+
end
|
339
|
+
attr_accessor :conf
|
340
|
+
|
341
|
+
def create_anchor
|
342
|
+
@input.gsub(/^(\-\-\- +)([\w\.:#]+)/) { $1+ANCHOR_BEGIN+$2+ANCHOR_END }
|
343
|
+
end
|
344
|
+
|
345
|
+
include LocalVariables
|
346
|
+
include GeneratedMessage
|
347
|
+
def to_e(es_file)
|
348
|
+
open(es_file, "w") do |es|
|
349
|
+
es << create_anchor
|
350
|
+
insert_local_variables es
|
351
|
+
end
|
352
|
+
generated es_file
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
# Ruby Reference Manual HTML version.
|
357
|
+
# (browse-url "http://elbereth-hp.hp.infoseek.co.jp/ruby.html")
|
358
|
+
class RubyRefm < HTMLIndex
|
359
|
+
def init_filename(x)
|
360
|
+
if File.directory?(dir = File.expand_path(arg1))
|
361
|
+
@dir = dir
|
362
|
+
index_file = File.read(File.join(dir, "index.html"))[ %r!<a href="(\S+?.html)">INDEX</a>!, 1 ]
|
363
|
+
@index_page = File.join(dir, index_file)
|
364
|
+
normalize_filename! @index_page
|
365
|
+
else
|
366
|
+
super
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
|
371
|
+
def pre_process(src)
|
372
|
+
src.gsub( %r!^<li><a href="(.+\.html)">(.+)</a>! ) {
|
373
|
+
%Q!<li>#{$2}#{space}(lh-w3m nil "file://#{@dir}/#{$1}" t)\n!
|
374
|
+
}
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
|
379
|
+
#### for backward compatibility
|
380
|
+
def ri_all(filename)
|
381
|
+
Ri.new.generate_ri_all(filename)
|
382
|
+
end
|
383
|
+
|
384
|
+
def ri_generate_methods_and_classes(methods="ri_methods.lst", classes="ri_classes.lst", ri_all="ri_all.lst")
|
385
|
+
Ri.new.generate_method_and_classes(methods, classes, ri_all)
|
386
|
+
end
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
def refe_generate_methods_and_classes(methods="refe_methods.lst", classes="refe_classes.lst", class_document_comp="/usr/local/share/refe/class_document_comp", method_document_comp="/usr/local/share/refe/method_document_comp")
|
391
|
+
Refe.new.generate_method_and_classes(methods, classes, class_document_comp, method_document_comp)
|
392
|
+
end
|
393
|
+
|
394
|
+
def make_rubyhelp(lists, output_file)
|
395
|
+
RubyHelp.new(lists).to_e(output_file)
|
396
|
+
end
|
397
|
+
|
398
|
+
# Local Variables:
|
399
|
+
# test-script: "../../test/test-ruby.rb"
|
400
|
+
# End:
|