yard-link_stdlib 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/yard/cli/link_stdlib.rb +61 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35b7b23700c4d77f2a017aa1881974617980d255
|
4
|
+
data.tar.gz: 475ee0d06dfc6d358398e59eb6a80bccc09b8e8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b2b26d8c1f3facd41e9b171d48138672a2cd8db0b166faf099ebafb3fffb2cae93150b9947f2a8660e195285b3d10e7fb86f062fc4a221fcf18ff51a5086809
|
7
|
+
data.tar.gz: ea374fb3df62ffcac1e5af88277bd7f96af1b0d8c9df342e801a84f67862a0895671f2e53f309c13f112a4944e3f9883f5a1f784afd4052ef0206bf36ded7fe5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/yard/cli/link_stdlib.rb
CHANGED
@@ -230,24 +230,58 @@ class LinkStdlib < Command
|
|
230
230
|
USAGE = "yard stdlib search [OPTIONS] TERMS..."
|
231
231
|
|
232
232
|
def run *args
|
233
|
+
# Default format is `:plain`
|
234
|
+
opts[ :format ] = :plain
|
235
|
+
|
233
236
|
OptionParser.new { |op|
|
234
237
|
add_header op, <<~END
|
235
238
|
Examples:
|
236
239
|
|
237
240
|
1. {Pathname} instance methods
|
238
241
|
|
239
|
-
|
242
|
+
$ yard stdlib search '^Pathname#'
|
240
243
|
|
241
|
-
2.
|
244
|
+
2. All `#to_s` methods
|
245
|
+
|
246
|
+
$ yard stdlib search '#to_s$'
|
247
|
+
|
248
|
+
3. Print results in serialized formats.
|
249
|
+
|
250
|
+
All `#to_s` instance methods in JSON:
|
251
|
+
|
252
|
+
$ yard stdlib search --format=json '#to_s$'
|
253
|
+
|
254
|
+
Supports a short `-f` flag and first-letter formats too.
|
242
255
|
|
243
|
-
|
256
|
+
Instance methods of {Array} in YAML:
|
257
|
+
|
258
|
+
$ yard stdlib search -f y '^Array#'
|
244
259
|
END
|
245
260
|
|
246
261
|
add_version_opt op
|
247
262
|
|
248
263
|
op.on( '-u', '--urls',
|
249
264
|
%(Print doc URLs along with names)
|
250
|
-
) { |urls| opts[ :urls ] = urls }
|
265
|
+
) { |urls| opts[ :urls ] = !!urls }
|
266
|
+
|
267
|
+
op.on( '-f FORMAT', '--format=FORMAT',
|
268
|
+
%(Specify print format: (p)lain, (j)son or (y)aml)
|
269
|
+
) { |format|
|
270
|
+
opts[ :format ] = \
|
271
|
+
case format.downcase
|
272
|
+
when 'p', 'plain'
|
273
|
+
:plain
|
274
|
+
when 'j', 'json'
|
275
|
+
:json
|
276
|
+
when 'y', 'yaml'
|
277
|
+
:yaml
|
278
|
+
else
|
279
|
+
log.fatal \
|
280
|
+
%(Unknown format - expected "plain", "json" or "yaml"; ) +
|
281
|
+
%(given #{ format.inspect })
|
282
|
+
exit false
|
283
|
+
end
|
284
|
+
}
|
251
285
|
|
252
286
|
}.parse! args
|
253
287
|
|
@@ -266,15 +300,31 @@ class LinkStdlib < Command
|
|
266
300
|
|
267
301
|
names = YARD::LinkStdlib.grep *terms
|
268
302
|
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
303
|
+
results = \
|
304
|
+
if opts[ :urls ]
|
305
|
+
names.each_with_object( {} ) { |name, hash|
|
306
|
+
hash[ name ] = YARD::LinkStdlib::ObjectMap.current.url_for name
|
307
|
+
}
|
308
|
+
else
|
309
|
+
names
|
310
|
+
end
|
311
|
+
|
312
|
+
case opts[ :format ]
|
313
|
+
when :plain
|
314
|
+
results.each do |entry|
|
315
|
+
if entry.is_a? ::Array
|
316
|
+
log.puts "#{ entry[0] } <#{ entry[ 1 ]}>"
|
273
317
|
else
|
274
|
-
|
318
|
+
log.puts entry
|
275
319
|
end
|
276
|
-
|
277
|
-
|
320
|
+
end
|
321
|
+
when :json
|
322
|
+
require 'json'
|
323
|
+
log.puts JSON.pretty_generate( results )
|
324
|
+
when :yaml
|
325
|
+
require 'yaml'
|
326
|
+
log.puts YAML.dump( results )
|
327
|
+
end
|
278
328
|
|
279
329
|
exit true
|
280
330
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard-link_stdlib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nrser
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-03-
|
11
|
+
date: 2019-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|