Skip to content

Commit 4436675

Browse files
committed
Update README
1 parent 952003b commit 4436675

1 file changed

Lines changed: 31 additions & 4 deletions

File tree

README.md

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# ReplCompletion
22

3-
TODO: Delete this and the text below, and describe your gem
4-
5-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/repl_completion`. To experiment with that code, run `bin/console` for an interactive prompt.
3+
ReplCompletion is a type based completor for REPL.
4+
It uses RBS type information, performs static type analytics, uses dynamic runtime information from binding.
65

76
## Installation
87

@@ -18,7 +17,25 @@ If bundler is not being used to manage dependencies, install the gem by executin
1817

1918
## Usage
2019

21-
TODO: Write usage instructions here
20+
Require the library
21+
```ruby
22+
require 'repl_completion'
23+
```
24+
25+
Load RBS with one of these. It will load core library signatures, `./rbs_collection.yaml` and `./sig/**/*.rbs`.
26+
```ruby
27+
ReplCompletion.preload_rbs # Recommended. Preload using thread
28+
ReplCompletion.load_rbs # Could take a seconds in large projects
29+
```
30+
31+
Now you can get completion candidates.
32+
```ruby
33+
array = [1, 2, 3]
34+
class String; def upupup; end; end
35+
result = ReplCompletion.analyze('array.map do str = _1.chr; str.up', binding)
36+
result.completion_candidates #=> ["case", "case!", "to", "upup"]
37+
result.doc_namespace('case') #=> "String#upcase"
38+
```
2239

2340
## Development
2441

@@ -30,6 +47,16 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
3047

3148
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/repl_completion.
3249

50+
When something is wrong, these methods will provide some debug information.
51+
```ruby
52+
ReplCompletion.info
53+
ReplCompletion.rbs_load_started?
54+
ReplCompletion.rbs_loaded?
55+
ReplCompletion.rbs_load_error
56+
ReplCompletion.last_completion_error
57+
ReplCompletion.analyze(code_to_complete, binding)
58+
```
59+
3360
## License
3461

3562
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)