webri 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6217b650dbad69d9d6f446e5d7c5e615042ee5ca56d85fa98866d5c31fb332c6
4
- data.tar.gz: b0b4bd81d6f463d1a5df7d39b30b21c6cedd2d082e8a14239ee1d6c54dcdf91b
3
+ metadata.gz: 6c3d0d85a57c242ce0e81aa73823aef986a893a1f48e1d675d6b4d5a268cbb45
4
+ data.tar.gz: '050383f4ecf292a67ab9445f7fbbf5b1523be63062a642b4d74eaf9f20b766e8'
5
5
  SHA512:
6
- metadata.gz: e66e895a9eea4695324e69ebf425b193e0e3774cb0390f8e4bfc2953af824eee9e68ad4b3cd8a5361dea6898a3cd81a9bdc2dc70012bd43429de8dc01b9d59fb
7
- data.tar.gz: b5eec14697ef1d868d6285b8004969d3a770da7a3c807030c91a57ffe3b13277801b859f2e7eb1843f552f50f36d55c783d6c43abc200d6c8c844ce90994bf6d
6
+ metadata.gz: f859eb825ce282a5198e7e50ee3114f71ecd39098b6416fa2538c79507cacf942366aa8c2c46e7c14b6d06e66b90f908fa8b756ce61d9c055920ba354fd60295
7
+ data.tar.gz: 8c31cc2229776e28c6f47320c7a2cdc8eb1d61157d3c10c10492e0dc7b682394c414a87bff694b25d21d3fad60ee2c82c2fe8ccc89dde7c69838177428bddc89
data/CHANGELOG.md CHANGED
@@ -7,3 +7,7 @@
7
7
  ## [1.0.2] - 2025-06-14
8
8
 
9
9
  - Clarify concept: Ruby page (not Ruby file).
10
+
11
+ ## [1.0.3] - 2025-06-16
12
+
13
+ - Add support for Reline.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # WebRI
1
+ # WebRI - Quick Access to Ruby Online Documentation
2
2
 
3
3
  WebRI has a command-line utility, `webri`, for displaying Ruby online documentation.
4
4
 
@@ -335,6 +335,7 @@ Opening web page https://docs.ruby-lang.org/en/3.4/regexp/unicode_properties_rdo
335
335
  To display the WebRI help text, use the special name `@help`:
336
336
 
337
337
  ```
338
+ $ ruby bin/webri
338
339
  webri> @help
339
340
  Showing help.
340
341
  webri is a console application for displaying Ruby online HTML documentation.
@@ -347,6 +348,7 @@ For more information, see https://github.com/BurdetteLamar/webri/blob/main/READM
347
348
  Options:
348
349
  -i, --info Prints information about webri.
349
350
  -r, --release=RELEASE Sets the Ruby release to document.
351
+ --noreline Does not use Reline (helps testing).
350
352
  -n, --noop Does not actually open web pages.
351
353
  -h, --help Prints this help.
352
354
  -v, --version Prints the version of webri.
@@ -359,6 +361,14 @@ webri> @readme
359
361
  Opening web page https://github.com/BurdetteLamar/webri/blob/main/README.md.
360
362
  ```
361
363
 
364
+ ### Reline
365
+
366
+ `webri` uses [Reline](https://ruby.github.io/reline/Reline.html)
367
+ (on Linux, but not on other OS platforms).
368
+
369
+ Reline enables editing of text at the `webri` prompt (use left- and right-arrows),
370
+ and gives access to history (use up-arrow).
371
+
362
372
  ### Options
363
373
 
364
374
  Option `--info` prints information about WebRI,
@@ -422,6 +432,8 @@ Opening web page https://docs.ruby-lang.org/en/3.4/Array.html.
422
432
  Command: 'start https://docs.ruby-lang.org/en/3.4/Array.html'
423
433
  ```
424
434
 
435
+ Option `--noreline` blocks Reline behavior; see [Reline][6].
436
+
425
437
  Option `--help` prints the WebRI help text.
426
438
 
427
439
  Option `--version` prints the WebRI version.
@@ -454,3 +466,4 @@ to follow the [code of conduct](https://github.com/BurdetteLamar/webri/blob/mast
454
466
  [3]: rdoc-ref:README.md@Instance+Method
455
467
  [4]: rdoc-ref:README.md@Ruby+Page
456
468
  [5]: rdoc-ref:README.md@Special+Names
469
+ [6]: rdoc-ref:README.md@Reline
data/bin/webri CHANGED
@@ -28,6 +28,9 @@ end
28
28
  parser.on('-r=RELEASE', '--release=RELEASE', 'Sets the Ruby release to document.') do |value|
29
29
  options[:release] = value
30
30
  end
31
+ parser.on('--noreline', 'Does not use Reline (helps testing).') do |value|
32
+ options[:noreline] = true
33
+ end
31
34
  parser.on('-n', '--noop', 'Does not actually open web pages.') do |value|
32
35
  options[:noop] = true
33
36
  end
data/lib/webri/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class WebRI
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
data/lib/webri.rb CHANGED
@@ -4,6 +4,7 @@ require 'rbconfig'
4
4
  require 'open-uri'
5
5
  require 'rexml'
6
6
  require 'cgi'
7
+ require 'reline'
7
8
 
8
9
  # TODO: Use reline.
9
10
  #
@@ -37,6 +38,15 @@ class WebRI
37
38
  get_toc_html
38
39
  build_indexes
39
40
  print_info if @info
41
+ print @noreline
42
+ if os_type == :linux && !@noreline
43
+ repl_reline
44
+ else
45
+ repl_plain
46
+ end
47
+ end
48
+
49
+ def repl_plain # Read-evaluate-print loop, without Reline.
40
50
  while true
41
51
  $stdout.write('webri> ')
42
52
  $stdout.flush
@@ -51,6 +61,46 @@ class WebRI
51
61
  end
52
62
  end
53
63
 
64
+ def repl_reline # Read-evaluate-print loop, with Reline.
65
+ begin
66
+ stty_save = `stty -g`.chomp
67
+ rescue
68
+ end
69
+
70
+ begin
71
+ completion_words= []
72
+ @index_for_type.each_pair do |type, index|
73
+ if type == :page
74
+ completion_words += index.keys.map {|name| 'ruby:' + name }
75
+ else
76
+ completion_words += index.keys
77
+ end
78
+ end
79
+ Reline.completion_proc = proc { |word|
80
+ completion_words
81
+ }
82
+ while line = Reline.readline("webri> ", true)
83
+ case line.chomp
84
+ when 'exit'
85
+ exit 0
86
+ when ''
87
+ # NOOP
88
+ else
89
+ if line.split(' ').size > 1
90
+ puts "One name at a time, please."
91
+ next
92
+ end
93
+ show(line)
94
+ end
95
+ end
96
+ rescue Interrupt
97
+ puts '^C'
98
+ `stty #{stty_save}` if stty_save
99
+ exit 0
100
+ end
101
+ puts
102
+ end
103
+
54
104
  def set_doc_release
55
105
  supported_releases = []
56
106
  unsupported_releases = []
@@ -176,6 +226,7 @@ class WebRI
176
226
  def capture_options(options)
177
227
  @noop = options[:noop]
178
228
  @info = options[:info]
229
+ @noreline = options[:noreline]
179
230
  @doc_release = options[:release]
180
231
  end
181
232
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - BurdetteLamar
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-14 00:00:00.000000000 Z
10
+ date: 2025-06-16 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: Command-line utility for displaying Ruby online documentation
13
13
  email: