helpline 0.1.18 → 0.2.1
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.
- checksums.yaml +4 -4
- data/exe/helpline +20 -290
- data/lib/helpline/generate.rb +76 -0
- data/lib/helpline/helpline.rb +8 -0
- data/lib/helpline/run.rb +97 -0
- data/lib/helpline/update.rb +111 -0
- data/lib/helpline/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b1990a34e246aa29e6f04d43d72541dc2dea4a1a9051f96541ce4d1b161006b
|
4
|
+
data.tar.gz: c09e2c0ab0e5ad4d3848c7a4b1a6ab37913e8990f96bc0f260b2e8cfd719aac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58cdbfd97c3030da1ef9f496ccd85efc5429693b276d87e95a61059a7a0edbcabee793fd9b6ae0f278e4a8f36de707853e071c4846998d64b90199e1c5d92e1a
|
7
|
+
data.tar.gz: 04f66e3949c0d9aa0a9e96b83fc68da053825f1ad5ec25d3c177f8f8c180aa4fbcc059bda63350f70c5838111407f5b22cced14e1df1cbe1cd1b986cf747c6ba
|
data/exe/helpline
CHANGED
@@ -1,310 +1,40 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# -*- ruby -*-
|
3
3
|
|
4
|
-
require 'json'
|
5
4
|
require 'optparse'
|
6
5
|
|
7
|
-
|
8
|
-
require '
|
9
|
-
|
10
|
-
require '
|
11
|
-
require 'helpline/
|
12
|
-
|
13
|
-
puts
|
14
|
-
|
15
|
-
class HelpLine
|
16
|
-
LINES = 12
|
17
|
-
|
18
|
-
def datafile
|
19
|
-
File.expand_path("~/.helpline.json")
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize
|
23
|
-
# @pagedata = {}
|
24
|
-
# @project = Scrapbox::Project.new("HelpLine")
|
25
|
-
end
|
26
|
-
|
27
|
-
def update(sources) # sources = ['HelpLine', '~/ScrapboxData/masui.json', ...]
|
28
|
-
dumpdata = {}
|
29
|
-
dumpdata['codes'] = []
|
30
|
-
dumpdata['defs'] = []
|
31
|
-
dumpdata['pages'] = []
|
32
|
-
|
33
|
-
sources.each { |source|
|
34
|
-
pagedata = {}
|
35
|
-
source = File.expand_path(source)
|
36
|
-
if File.exist?(source)
|
37
|
-
puts "-----------------ページデータをJSONデータ(#{source})から取得"
|
38
|
-
data = JSON.parse(File.read(source))
|
39
|
-
data['pages'].each { |page|
|
40
|
-
title = page['title']
|
41
|
-
puts "...#{title}"
|
42
|
-
pagedata[title] = page['lines']
|
43
|
-
}
|
44
|
-
elsif source =~ /^[a-zA-Z\-]+$/ # たぶんHelpLineプロジェクト
|
45
|
-
puts "-----------------ページデータをScrapbox(#{source})から取得"
|
46
|
-
project = Scrapbox::Project.new(source)
|
47
|
-
project.pages.each { |title,page|
|
48
|
-
puts "...#{title}"
|
49
|
-
pagedata[title] = page.text.split(/\n/)
|
50
|
-
}
|
51
|
-
else
|
52
|
-
next
|
53
|
-
end
|
54
|
-
|
55
|
-
#
|
56
|
-
# 関数/定数を評価"
|
57
|
-
#
|
58
|
-
puts "-----------------関数/定数を取得"
|
59
|
-
src = nil
|
60
|
-
code = []
|
61
|
-
pagedata.each { |title,lines|
|
62
|
-
puts "...#{title}"
|
63
|
-
lines.each { |line|
|
64
|
-
if src && line =~ /^\s+/ then
|
65
|
-
code << line
|
66
|
-
elsif line =~ /^code:(.*\.rb)$/ then
|
67
|
-
if code.length > 0
|
68
|
-
dumpdata['codes'] << code.join("\n")
|
69
|
-
end
|
70
|
-
src = $1
|
71
|
-
code = []
|
72
|
-
elsif src then
|
73
|
-
dumpdata['codes'] << code.join("\n")
|
74
|
-
src = nil
|
75
|
-
code = []
|
76
|
-
else
|
77
|
-
end
|
78
|
-
}
|
79
|
-
if code.length > 0
|
80
|
-
dumpdata['codes'] << code.join("\n")
|
81
|
-
end
|
82
|
-
}
|
83
|
-
puts "-----------------HelpLineデータを検出"
|
84
|
-
pagedata.each { |title,pagedata|
|
85
|
-
puts "...#{title}"
|
86
|
-
dumpdata['pages'] << title
|
87
|
-
processing_defs = false
|
88
|
-
codeindent = nil
|
89
|
-
pagedata.each { |line|
|
90
|
-
if !codeindent
|
91
|
-
if line =~ /^code:/
|
92
|
-
codeindent = 0
|
93
|
-
next
|
94
|
-
end
|
95
|
-
else
|
96
|
-
line =~ /^(\s*)/
|
97
|
-
if $1.length < codeindent + 1
|
98
|
-
codeindent = nil
|
99
|
-
else
|
100
|
-
next
|
101
|
-
end
|
102
|
-
end
|
103
|
-
if line =~ /^[\$\%\?]/
|
104
|
-
if line =~ /^\%/ && !processing_defs
|
105
|
-
puts "'$'で始まる用例定義なしでコマンドを定義しようとしています"
|
106
|
-
exit
|
107
|
-
end
|
108
|
-
dumpdata['defs'] << "#{line} {#{dumpdata['pages'].length-1}}"
|
109
|
-
processing_defs = true
|
110
|
-
else
|
111
|
-
processing_defs = false
|
112
|
-
end
|
113
|
-
}
|
114
|
-
}
|
115
|
-
}
|
116
|
-
|
117
|
-
File.open(datafile,"w"){ |f|
|
118
|
-
f.puts dumpdata.to_json
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
|
-
def disp(list,sel)
|
123
|
-
Curses.move(0,0)
|
124
|
-
lines = list.length
|
125
|
-
lines = LINES if lines > LINES
|
126
|
-
(0...lines).each { |i|
|
127
|
-
Curses.move(i*2,0)
|
128
|
-
s = "#{list[i][0]}"
|
129
|
-
if i == sel
|
130
|
-
Curses.print_inverse s
|
131
|
-
else
|
132
|
-
Curses.print_bold s
|
133
|
-
end
|
134
|
-
Curses.move(i*2+1,0)
|
135
|
-
Curses.print " % " + list[i][1]
|
136
|
-
}
|
137
|
-
Curses.move(sel*2,0)
|
138
|
-
end
|
139
|
-
|
140
|
-
def helpline(sources,test=nil,debug=nil)
|
141
|
-
data = JSON.parse(File.read(datafile))
|
142
|
-
unless data['pages'] # データ型式変換があったので
|
143
|
-
update sources
|
144
|
-
data = JSON.parse(File.read(datafile))
|
145
|
-
end
|
146
|
-
|
147
|
-
#
|
148
|
-
# 関数定義などをeval
|
149
|
-
#
|
150
|
-
data['codes'].each { |code|
|
151
|
-
eval code
|
152
|
-
}
|
153
|
-
|
154
|
-
g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
155
|
-
|
156
|
-
#
|
157
|
-
# HelpLineエントリ
|
158
|
-
#
|
159
|
-
|
160
|
-
logfile = (debug ? "/tmp/helpline-defs" : "/dev/null")
|
161
|
-
File.open(logfile,"w"){ |f| # ログを残す場合
|
162
|
-
entries = []
|
163
|
-
data['defs'].each { |line|
|
164
|
-
if line =~ /^[\$\?]\s*(.*)$/ # $....
|
165
|
-
entries << $1
|
166
|
-
elsif line =~ /^\%\s*(.*)$/ # %....
|
167
|
-
cmd = $1
|
168
|
-
entries.each { |l|
|
169
|
-
desc = eval('"' + l + '"')
|
170
|
-
f.puts "desc: #{desc}"
|
171
|
-
g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
|
172
|
-
}
|
173
|
-
f.puts "cmd: #{cmd}"
|
174
|
-
entries = []
|
175
|
-
end
|
176
|
-
}
|
177
|
-
}
|
178
|
-
|
179
|
-
res = g.generate " #{ARGV.join(' ').sub(/\[/,'').sub(/\]/,'')} "
|
180
|
-
|
181
|
-
File.open("/tmp/helpline.cmd","w"){ |f|
|
182
|
-
f.puts ARGV.join(' ')
|
183
|
-
}
|
184
|
-
|
185
|
-
if res[0].length == 0
|
186
|
-
puts "ヘルプがみつかりません"
|
187
|
-
exit
|
188
|
-
end
|
189
|
-
|
190
|
-
git_repository = File.exist?(".git")
|
191
|
-
listed = {}
|
192
|
-
list = res[0].find_all { |a| # 0 ambig
|
193
|
-
# a = ["現在の状況を表示する {56}", "git status {56}"], etc.
|
194
|
-
if a[0] =~ /voidvoidvoid/
|
195
|
-
false
|
196
|
-
elsif a[0] =~ /^git:/ && !git_repository
|
197
|
-
false
|
198
|
-
else
|
199
|
-
if listed[a[1]]
|
200
|
-
false
|
201
|
-
else
|
202
|
-
listed[a[1]] = true
|
203
|
-
end
|
204
|
-
end
|
205
|
-
}
|
206
|
-
|
207
|
-
# if options['t'] || options['test'] then
|
208
|
-
if test
|
209
|
-
puts list
|
210
|
-
exit
|
211
|
-
end
|
212
|
-
|
213
|
-
#
|
214
|
-
# HelpLineメニュー表示し、カーソル移動で選択
|
215
|
-
#
|
216
|
-
help_number = {}
|
217
|
-
list.each_with_index { |entry,ind|
|
218
|
-
entry[0].sub!(/\s*{(\d*)}$/,'')
|
219
|
-
entry[1].sub!(/\s*{(\d*)}$/,'')
|
220
|
-
help_number[entry[0]] = $1.to_i
|
221
|
-
}
|
222
|
-
|
223
|
-
sel = 0
|
224
|
-
disp(list,sel)
|
225
|
-
|
226
|
-
lines = list.length
|
227
|
-
lines = LINES if lines > LINES
|
228
|
-
|
229
|
-
inputchars = ''
|
230
|
-
while true
|
231
|
-
c = STDIN.getch
|
232
|
-
inputchars += c
|
233
|
-
|
234
|
-
if inputchars == "\e"
|
235
|
-
# process ESC
|
236
|
-
elsif inputchars[0] == "\e" && inputchars.length == 2
|
237
|
-
# 何もしない
|
238
|
-
elsif inputchars == "\x06" || inputchars == "\e[C" || inputchars == "\eOC"
|
239
|
-
# Curses.right
|
240
|
-
inputchars = ''
|
241
|
-
elsif inputchars == "\x02" || inputchars == "\e[D" || inputchars == "\eOD"
|
242
|
-
# Curses.left
|
243
|
-
inputchars = ''
|
244
|
-
elsif inputchars == "\x0e" || inputchars == "\e[B" || inputchars == "\eOB"
|
245
|
-
Curses.down
|
246
|
-
sel = (sel + 1) if sel < lines-1
|
247
|
-
inputchars = ''
|
248
|
-
elsif inputchars == "\x10" || inputchars == "\e[A" || inputchars == "\eOA"
|
249
|
-
Curses.up
|
250
|
-
sel = sel - 1 if sel > 0
|
251
|
-
inputchars = ''
|
252
|
-
else
|
253
|
-
inputchars = ''
|
254
|
-
end
|
255
|
-
STDIN.flush
|
256
|
-
disp(list,sel)
|
257
|
-
|
258
|
-
exit if c== 'q' || c == "\x03"
|
259
|
-
|
260
|
-
if c == "\r" || c == "\n"
|
261
|
-
break
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
desc = list[sel.to_i][0]
|
266
|
-
cmd = list[sel][1]
|
267
|
-
|
268
|
-
Curses.move(lines*2,0)
|
269
|
-
Curses.tol
|
270
|
-
|
271
|
-
#Curses.move(0,0)
|
272
|
-
##Curses.down
|
273
|
-
|
274
|
-
# Curses.print_inverse("「#{desc}」を実行")
|
275
|
-
# puts " (ソース: http://scrapbox.io/HelpLine/#{data['pages'][help_number[desc]]})"
|
276
|
-
File.open("/tmp/helpline.cmd","w"){ |f|
|
277
|
-
f.puts cmd
|
278
|
-
}
|
279
|
-
end
|
280
|
-
end
|
6
|
+
$:.unshift "lib"
|
7
|
+
require 'helpline/helpline'
|
8
|
+
require 'helpline/update'
|
9
|
+
require 'helpline/generate'
|
10
|
+
require 'helpline/run'
|
281
11
|
|
282
12
|
# アップデート
|
283
13
|
# % helpline -u
|
284
14
|
# データを指定してアップデート
|
285
|
-
# % helpline -u
|
15
|
+
# % helpline -u HelpLine /Users/masui/ScrapboxData/masui-HelpLine.json
|
286
16
|
# テスト
|
287
|
-
# % helpline -t
|
17
|
+
# % helpline -t args
|
288
18
|
#
|
289
19
|
|
290
20
|
helpline = HelpLine.new
|
291
21
|
|
292
22
|
options = ARGV.getopts('utds:','update','test','source:','debug')
|
293
|
-
update = options['u'] || options['update']
|
294
|
-
test = options['t'] || options['test']
|
295
|
-
debug = options['d'] || options['debug']
|
296
|
-
sources = ['HelpLine']
|
297
|
-
if options['s'] || options['source']
|
298
|
-
sources = (options['s'] || options['source']).split(/,/)
|
299
|
-
end
|
300
23
|
|
301
|
-
|
302
|
-
|
24
|
+
#
|
25
|
+
# update
|
26
|
+
#
|
27
|
+
if options['u'] || options['update'] # ~/.helpline.json更新
|
28
|
+
sources = (ARGV.length > 0 ? ARGV : ['HelpLine'])
|
303
29
|
helpline.update sources
|
30
|
+
exit
|
304
31
|
end
|
305
32
|
|
306
|
-
if
|
307
|
-
helpline.
|
308
|
-
|
309
|
-
helpline.helpline sources, test, debug
|
33
|
+
if options['t'] || options['test'] # テスト
|
34
|
+
puts helpline.generate " #{ARGV.join(' ')} "
|
35
|
+
exit
|
310
36
|
end
|
37
|
+
|
38
|
+
debug = options['d'] || options['debug']
|
39
|
+
query = " #{ARGV.join(' ').sub(/\[/,'').sub(/\]/,'')} "
|
40
|
+
helpline.run query, debug
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# * datafileを読み、引数とマッチするものをリストする
|
4
|
+
# 引数はARGVに入っている
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'json'
|
8
|
+
require 're_expand'
|
9
|
+
|
10
|
+
class HelpLine
|
11
|
+
def generate(query,debug=nil)
|
12
|
+
data = JSON.parse(File.read(datafile))
|
13
|
+
|
14
|
+
#
|
15
|
+
# 関数定義などをeval
|
16
|
+
#
|
17
|
+
data['codes'].each { |code|
|
18
|
+
eval code
|
19
|
+
}
|
20
|
+
|
21
|
+
g = ExpandRuby::Generator.new # re_expandのジェネレータ
|
22
|
+
|
23
|
+
#
|
24
|
+
# HelpLineエントリ
|
25
|
+
#
|
26
|
+
|
27
|
+
logfile = (debug ? "/tmp/helpline-defs" : "/dev/null")
|
28
|
+
File.open(logfile,"w"){ |f| # ログを残す場合
|
29
|
+
entries = []
|
30
|
+
data['defs'].each { |line|
|
31
|
+
if line =~ /^[\$\?]\s*(.*)$/ # $....
|
32
|
+
entries << $1
|
33
|
+
elsif line =~ /^\%\s*(.*)$/ # %....
|
34
|
+
cmd = $1
|
35
|
+
entries.each { |l|
|
36
|
+
desc = eval('"' + l + '"')
|
37
|
+
f.puts "desc: #{desc}"
|
38
|
+
g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
|
39
|
+
}
|
40
|
+
f.puts "cmd: #{cmd}"
|
41
|
+
entries = []
|
42
|
+
end
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
res = g.generate query
|
47
|
+
|
48
|
+
File.open("/tmp/helpline.cmd","w"){ |f|
|
49
|
+
f.puts ARGV.join(' ')
|
50
|
+
}
|
51
|
+
|
52
|
+
if res[0].length == 0
|
53
|
+
puts "ヘルプがみつかりません"
|
54
|
+
exit
|
55
|
+
end
|
56
|
+
|
57
|
+
git_repository = File.exist?(".git")
|
58
|
+
listed = {}
|
59
|
+
list = res[0].find_all { |a| # 0 ambig
|
60
|
+
# a = ["現在の状況を表示する {56}", "git status {56}"], etc.
|
61
|
+
if a[0] =~ /voidvoidvoid/
|
62
|
+
false
|
63
|
+
elsif a[0] =~ /^git:/ && !git_repository
|
64
|
+
false
|
65
|
+
else
|
66
|
+
if listed[a[1]]
|
67
|
+
false
|
68
|
+
else
|
69
|
+
listed[a[1]] = true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
}
|
73
|
+
|
74
|
+
list
|
75
|
+
end
|
76
|
+
end
|
data/lib/helpline/run.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# * HelpLineのメインルーチン
|
4
|
+
# * datafileを読み、引数とマッチするものをリストする
|
5
|
+
# 引数はARGVに入っている
|
6
|
+
#
|
7
|
+
|
8
|
+
require 'io/console'
|
9
|
+
require 'helpline/curses'
|
10
|
+
|
11
|
+
class HelpLine
|
12
|
+
LINES = 12
|
13
|
+
|
14
|
+
def disp(list,sel)
|
15
|
+
Curses.move(0,0)
|
16
|
+
lines = list.length
|
17
|
+
lines = LINES if lines > LINES
|
18
|
+
(0...lines).each { |i|
|
19
|
+
Curses.move(i*2,0)
|
20
|
+
s = "#{list[i][0]}"
|
21
|
+
if i == sel
|
22
|
+
Curses.print_inverse s
|
23
|
+
else
|
24
|
+
Curses.print_bold s
|
25
|
+
end
|
26
|
+
Curses.move(i*2+1,0)
|
27
|
+
Curses.print " % " + list[i][1]
|
28
|
+
}
|
29
|
+
Curses.move(sel*2,0)
|
30
|
+
end
|
31
|
+
|
32
|
+
def run(query,debug=nil)
|
33
|
+
puts
|
34
|
+
|
35
|
+
list = generate(query,debug)
|
36
|
+
#
|
37
|
+
# HelpLineメニュー表示し、カーソル移動で選択
|
38
|
+
#
|
39
|
+
help_number = {}
|
40
|
+
list.each_with_index { |entry,ind|
|
41
|
+
entry[0].sub!(/\s*{(\d*)}$/,'')
|
42
|
+
entry[1].sub!(/\s*{(\d*)}$/,'')
|
43
|
+
help_number[entry[0]] = $1.to_i
|
44
|
+
}
|
45
|
+
|
46
|
+
sel = 0
|
47
|
+
disp(list,sel)
|
48
|
+
|
49
|
+
lines = list.length
|
50
|
+
lines = LINES if lines > LINES
|
51
|
+
|
52
|
+
inputchars = ''
|
53
|
+
while true
|
54
|
+
c = STDIN.getch
|
55
|
+
inputchars += c
|
56
|
+
|
57
|
+
if inputchars == "\e"
|
58
|
+
# process ESC
|
59
|
+
elsif inputchars[0] == "\e" && inputchars.length == 2
|
60
|
+
# 何もしない
|
61
|
+
elsif inputchars == "\x0e" || inputchars == "\e[B" || inputchars == "\eOB"
|
62
|
+
Curses.down
|
63
|
+
sel = (sel + 1) if sel < lines-1
|
64
|
+
inputchars = ''
|
65
|
+
elsif inputchars == "\x10" || inputchars == "\e[A" || inputchars == "\eOA"
|
66
|
+
Curses.up
|
67
|
+
sel = sel - 1 if sel > 0
|
68
|
+
inputchars = ''
|
69
|
+
else
|
70
|
+
inputchars = ''
|
71
|
+
end
|
72
|
+
STDIN.flush
|
73
|
+
disp(list,sel)
|
74
|
+
|
75
|
+
exit if c== 'q' || c == "\x03"
|
76
|
+
|
77
|
+
if c == "\r" || c == "\n"
|
78
|
+
break
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
desc = list[sel.to_i][0]
|
83
|
+
cmd = list[sel][1]
|
84
|
+
|
85
|
+
Curses.move(lines*2,0)
|
86
|
+
Curses.tol
|
87
|
+
|
88
|
+
#Curses.move(0,0)
|
89
|
+
##Curses.down
|
90
|
+
|
91
|
+
# Curses.print_inverse("「#{desc}」を実行")
|
92
|
+
# puts " (ソース: http://scrapbox.io/HelpLine/#{data['pages'][help_number[desc]]})"
|
93
|
+
File.open("/tmp/helpline.cmd","w"){ |f|
|
94
|
+
f.puts cmd
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#
|
3
|
+
# HelpLineデータを読み込んでdatafileにセーブする
|
4
|
+
#
|
5
|
+
|
6
|
+
require 'json'
|
7
|
+
require 'scrapbox'
|
8
|
+
|
9
|
+
class HelpLine
|
10
|
+
def update(sources) # sources = ['HelpLine', '~/ScrapboxData/masui.json', ...]
|
11
|
+
dumpdata = {}
|
12
|
+
dumpdata['codes'] = []
|
13
|
+
dumpdata['defs'] = []
|
14
|
+
dumpdata['pages'] = []
|
15
|
+
|
16
|
+
sources.each { |source|
|
17
|
+
pagedata = {}
|
18
|
+
if File.exist?(source)
|
19
|
+
puts "-----------------ページデータをJSONデータ(#{source})から取得"
|
20
|
+
data = JSON.parse(File.read(source))
|
21
|
+
data['pages'].each { |page|
|
22
|
+
title = page['title']
|
23
|
+
puts "...#{title}"
|
24
|
+
pagedata[title] = page['lines']
|
25
|
+
}
|
26
|
+
elsif source =~ /^[a-zA-Z\-]+$/ # たぶんHelpLineプロジェクト
|
27
|
+
puts "-----------------ページデータをScrapbox(#{source})から取得"
|
28
|
+
project = Scrapbox::Project.new(source)
|
29
|
+
project.pages.each { |title,page|
|
30
|
+
puts "...#{title}"
|
31
|
+
pagedata[title] = page.text.split(/\n/)
|
32
|
+
}
|
33
|
+
else
|
34
|
+
next
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# 関数/定数を評価"
|
39
|
+
#
|
40
|
+
puts "-----------------関数/定数を取得"
|
41
|
+
src = nil
|
42
|
+
code = []
|
43
|
+
pagedata.each { |title,lines|
|
44
|
+
# puts "...#{title}"
|
45
|
+
lines.each { |line|
|
46
|
+
if src && line =~ /^\s+/ then
|
47
|
+
code << line
|
48
|
+
elsif line =~ /^code:(.*\.rb)$/ then
|
49
|
+
if code.length > 0
|
50
|
+
puts "...#{title}"
|
51
|
+
puts code[0]
|
52
|
+
dumpdata['codes'] << code.join("\n")
|
53
|
+
end
|
54
|
+
src = $1
|
55
|
+
code = []
|
56
|
+
elsif src then
|
57
|
+
puts "...#{title}"
|
58
|
+
puts code[0]
|
59
|
+
dumpdata['codes'] << code.join("\n")
|
60
|
+
src = nil
|
61
|
+
code = []
|
62
|
+
else
|
63
|
+
end
|
64
|
+
}
|
65
|
+
if code.length > 0
|
66
|
+
puts "...#{title}"
|
67
|
+
puts code[0]
|
68
|
+
dumpdata['codes'] << code.join("\n")
|
69
|
+
src = nil
|
70
|
+
code = []
|
71
|
+
end
|
72
|
+
}
|
73
|
+
puts "-----------------HelpLineデータを検出"
|
74
|
+
pagedata.each { |title,pagedata|
|
75
|
+
# puts "...#{title}"
|
76
|
+
dumpdata['pages'] << title
|
77
|
+
processing_defs = false
|
78
|
+
codeindent = nil
|
79
|
+
pagedata.each { |line|
|
80
|
+
if !codeindent
|
81
|
+
if line =~ /^code:/
|
82
|
+
codeindent = 0
|
83
|
+
next
|
84
|
+
end
|
85
|
+
else
|
86
|
+
line =~ /^(\s*)/
|
87
|
+
if $1.length < codeindent + 1
|
88
|
+
codeindent = nil
|
89
|
+
else
|
90
|
+
next
|
91
|
+
end
|
92
|
+
end
|
93
|
+
if line =~ /^[\$\%\?]/
|
94
|
+
if line =~ /^\%/ && !processing_defs
|
95
|
+
puts "'$'で始まる用例定義なしでコマンドを定義しようとしています"
|
96
|
+
exit
|
97
|
+
end
|
98
|
+
dumpdata['defs'] << "#{line} {#{dumpdata['pages'].length-1}}"
|
99
|
+
processing_defs = true
|
100
|
+
else
|
101
|
+
processing_defs = false
|
102
|
+
end
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
File.open(datafile,"w"){ |f|
|
108
|
+
f.puts dumpdata.to_json
|
109
|
+
}
|
110
|
+
end
|
111
|
+
end
|
data/lib/helpline/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: helpline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toshiyuki Masui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -111,6 +111,10 @@ files:
|
|
111
111
|
- keydef.zsh
|
112
112
|
- lib/helpline.rb
|
113
113
|
- lib/helpline/curses.rb
|
114
|
+
- lib/helpline/generate.rb
|
115
|
+
- lib/helpline/helpline.rb
|
116
|
+
- lib/helpline/run.rb
|
117
|
+
- lib/helpline/update.rb
|
114
118
|
- lib/helpline/version.rb
|
115
119
|
- main.js
|
116
120
|
- package.json
|