bri 0.4.1 → 0.4.2
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/Changelog +9 -0
- data/README.rdoc +20 -4
- data/TODO +2 -0
- data/lib/bri.rb +7 -30
- data/lib/bri/mall.rb +6 -6
- data/lib/bri/match.rb +3 -3
- data/lib/bri/renderer.rb +22 -17
- data/lib/bri/search.rb +5 -5
- data/lib/bri/templates.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a207a768943836bb63dea1964e177e4eef7dbfa7e07c26b76fa3cf254c1db86
|
4
|
+
data.tar.gz: 6bb5e69bdb8bd7050e179cf51d49084facd31b8a900b06ddcacc030503718fee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4388dd1a1a040b7f51d49ddc67131d3f0865e39a3120e9816373490bddb408aa26b40b32a946b3246dacdb98113503165a9cdee368d248d07602dccd6bb685cc
|
7
|
+
data.tar.gz: 68b5edcf218e9c63545e253ce697851d0653f9c50104656962552566e8674ffe9848eff6c42e4dfbfe55b6b2ab6d9aa53323a48d43d8ba29a948fefce2cb7abf
|
data/Changelog
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.4.2
|
2
|
+
- Fix broken --list-names option
|
3
|
+
- Fix broken multiple choice display
|
4
|
+
- Remove comma separators from method lists in order to ease copy and paste
|
5
|
+
actions
|
6
|
+
- List multiple choices one per line for easier visual searching
|
7
|
+
- More internal cleanups
|
8
|
+
- Add caveat to the readme
|
9
|
+
|
1
10
|
0.4.1
|
2
11
|
- Modernize and refactor code
|
3
12
|
- Show extends of classes in rendered documentation
|
data/README.rdoc
CHANGED
@@ -1,11 +1,21 @@
|
|
1
1
|
= What is this ?
|
2
|
-
During the days of Ruby 1.8, the ri command was slow. I mean really slow.
|
2
|
+
During the days of Ruby 1.8, the ri command was slow. I mean really slow.
|
3
|
+
Glacially. Starting a web browser and looking up a class or method description
|
4
|
+
on ruby-doc.org often felt faster.
|
3
5
|
|
4
|
-
Then Mauricio Fernandez produced fastri and qri that produced results a whole
|
6
|
+
Then Mauricio Fernandez produced fastri and qri that produced results a whole
|
7
|
+
lot faster than the native ri tool. Unfortunately, Mauricio seems to have lost
|
8
|
+
interest and didn't port fastri to ruby 1.9. There are patches porting fastri
|
9
|
+
to 1.9.1, but they are iffy and don't work well with 1.9.2 and the new rdoc
|
10
|
+
cache format.
|
5
11
|
|
6
|
-
|
12
|
+
With ruby 1.9 and rdoc 2.x/3.x ri became very responsive. However the output
|
13
|
+
format looks like darkfish without the HTML and uses up a lot of space.
|
7
14
|
|
8
|
-
|
15
|
+
And subjectively, it's ugly.
|
16
|
+
|
17
|
+
This is where bri comes in: it tries to emulate fastri/qris output format and
|
18
|
+
lookup patterns while using the more current rdoc infrastructure.
|
9
19
|
|
10
20
|
To compare, do 'ri Array' and 'bri Array' and see which appeals more to you.
|
11
21
|
|
@@ -29,6 +39,12 @@ Bri is a Beautiful RI formatter.
|
|
29
39
|
# the given search term, and finally looking for the term
|
30
40
|
# anywhere in the method name
|
31
41
|
|
42
|
+
= Caveats
|
43
|
+
I'm reviving this project that has been left rotting for nearly 8 years.
|
44
|
+
Due to bitrot, changes in rdoc internals and trying to understand my code
|
45
|
+
from back then, some unexpected hickups may arise. All bug reports with
|
46
|
+
references to problematic ri class or method docs are welcome.
|
47
|
+
|
32
48
|
= Requirements
|
33
49
|
* Ruby 2.6 or later
|
34
50
|
* rdoc 6.1 or later
|
data/TODO
CHANGED
data/lib/bri.rb
CHANGED
@@ -1,40 +1,16 @@
|
|
1
|
-
$: << File.dirname( __FILE__ )
|
2
1
|
require 'erb'
|
3
2
|
require 'term/ansicolor'
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
require 'bri/match'
|
4
|
+
require_relative 'bri/renderer'
|
5
|
+
require_relative 'bri/mall'
|
6
|
+
require_relative 'bri/matcher'
|
7
|
+
require_relative 'bri/templates'
|
8
|
+
require_relative 'bri/search'
|
9
|
+
require_relative 'bri/match'
|
12
10
|
|
13
11
|
module Bri
|
14
12
|
DEFAULT_WIDTH = 72
|
15
13
|
|
16
|
-
def self.format_elements( array )
|
17
|
-
rows = []
|
18
|
-
row = []
|
19
|
-
row_length = 0
|
20
|
-
|
21
|
-
array.each do |element|
|
22
|
-
element_length_with_separator = element.length + 2
|
23
|
-
|
24
|
-
if row_length + element_length_with_separator >= Bri.width
|
25
|
-
rows << row
|
26
|
-
row = []
|
27
|
-
row_length = 0
|
28
|
-
end
|
29
|
-
|
30
|
-
row << element
|
31
|
-
row_length += element_length_with_separator
|
32
|
-
end
|
33
|
-
|
34
|
-
rows << row
|
35
|
-
rows
|
36
|
-
end
|
37
|
-
|
38
14
|
def self.ri( query )
|
39
15
|
results = Bri::Matcher.new( query ).find
|
40
16
|
|
@@ -43,6 +19,7 @@ module Bri
|
|
43
19
|
elsif results.size == 1
|
44
20
|
results.first.to_s
|
45
21
|
else
|
22
|
+
qualified_methods = results.map(&:full_name).sort
|
46
23
|
ERB.new( Bri::Templates::MULTIPLE_CHOICES, nil, '<>' ).result( binding )
|
47
24
|
end
|
48
25
|
end
|
data/lib/bri/mall.rb
CHANGED
@@ -13,17 +13,17 @@ module Bri
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def class_methods
|
16
|
-
stores.
|
17
|
-
store.class_methods.
|
18
|
-
methods.
|
16
|
+
stores.each_with_object( [] ) do |store, result|
|
17
|
+
store.class_methods.each do |klass, methods|
|
18
|
+
methods.each { |method| result << "#{klass}.#{method}" }
|
19
19
|
end
|
20
20
|
end.uniq
|
21
21
|
end
|
22
22
|
|
23
23
|
def instance_methods
|
24
|
-
stores.
|
25
|
-
store.instance_methods.
|
26
|
-
methods.
|
24
|
+
stores.each_with_object( [] ) do |store, result|
|
25
|
+
store.instance_methods.each do |klass, methods|
|
26
|
+
methods.each { |method| result << "#{klass}##{method}" }
|
27
27
|
end
|
28
28
|
end.uniq
|
29
29
|
end
|
data/lib/bri/match.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative 'match/base'
|
2
|
+
require_relative 'match/class'
|
3
|
+
require_relative 'match/method'
|
data/lib/bri/renderer.rb
CHANGED
@@ -2,6 +2,8 @@ require 'strscan'
|
|
2
2
|
|
3
3
|
module Bri
|
4
4
|
module Renderer
|
5
|
+
Color = ::Term::ANSIColor
|
6
|
+
|
5
7
|
INDENT = ' ' * 2
|
6
8
|
INDENT_WIDTH = 2
|
7
9
|
LOWER_ALPHABET = ('a'..'z').to_a.map { |char| "#{char}." }.freeze
|
@@ -100,41 +102,44 @@ module Bri
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def self.replace_markup( text )
|
103
|
-
text.gsub!( /(?<!\\)<(?:tt|code)>/,
|
104
|
-
text.gsub!( /(?<!\\)<\/(?:tt|code)>/,
|
105
|
+
text.gsub!( /(?<!\\)<(?:tt|code)>/, Color.cyan )
|
106
|
+
text.gsub!( /(?<!\\)<\/(?:tt|code)>/, Color.reset )
|
105
107
|
|
106
|
-
text.gsub!( /(?<!\\)<b>/,
|
107
|
-
text.gsub!( /(?<!\\)<\/b>/,
|
108
|
+
text.gsub!( /(?<!\\)<b>/, Color.bold )
|
109
|
+
text.gsub!( /(?<!\\)<\/b>/, Color.reset )
|
108
110
|
|
109
|
-
text.gsub!( /(?<!\\)<(?:em|i)>/,
|
110
|
-
text.gsub!( /(?<!\\)<\/(?:em|i)>/,
|
111
|
+
text.gsub!( /(?<!\\)<(?:em|i)>/, Color.yellow )
|
112
|
+
text.gsub!( /(?<!\\)<\/(?:em|i)>/, Color.reset )
|
111
113
|
|
112
|
-
text.gsub!( "<h>",
|
113
|
-
text.gsub!( "</h>",
|
114
|
+
text.gsub!( "<h>", Color.green )
|
115
|
+
text.gsub!( "</h>", Color.reset )
|
114
116
|
|
115
117
|
text.gsub!( "\\<", "<" )
|
116
118
|
|
119
|
+
text.gsub!( /(#\s*=>)(.*)/,
|
120
|
+
"#{Color.dark}\\1#{Color.reset}#{Color.bold}\\2#{Color.reset}" )
|
121
|
+
|
117
122
|
text.gsub!( /(^|\s)\*(.*?[a-zA-Z0-9]+.*?)\*/,
|
118
|
-
"\\1#{
|
123
|
+
"\\1#{Color.bold}\\2#{Color.reset}" )
|
119
124
|
text.gsub!( /(^|\s)\+(.*?[a-zA-Z0-9]+.*?)\+/,
|
120
|
-
"\\1#{
|
125
|
+
"\\1#{Color.cyan}\\2#{Color.reset}" )
|
121
126
|
text.gsub!( /(^|\s)_(.*?[a-zA-Z0-9]+.*?)_/,
|
122
|
-
"\\1#{
|
127
|
+
"\\1#{Color.yellow}\\2#{Color.reset}" )
|
123
128
|
|
124
129
|
text.gsub!( %r{\b((?:https?|ftp)://[-\w.?%&=/]+)\b},
|
125
|
-
"#{
|
130
|
+
"#{Color.underline}\\1#{Color.reset}" )
|
126
131
|
|
127
132
|
text.gsub!( %r{\b(mailto:[-\w.%]+@[-\w.]+)\b},
|
128
|
-
"#{
|
133
|
+
"#{Color.underline}\\1#{Color.reset}" )
|
129
134
|
|
130
135
|
text.gsub!( %r{\b((?<!:\/\/)www.[-\w.?%&=]+)\b},
|
131
|
-
"#{
|
136
|
+
"#{Color.underline}\\1#{Color.reset}" )
|
132
137
|
|
133
138
|
text.gsub!( %r{\blink:(.*?)(\s|$)},
|
134
|
-
"#{
|
139
|
+
"#{Color.underline}\\1#{Color.reset}\\2" )
|
135
140
|
|
136
141
|
text.gsub!( %r{\{(.*?)\}\[(.*?)\]}, "\\1 (\\2)" )
|
137
|
-
text.gsub!( %r{\[(#{Regexp.escape(
|
142
|
+
text.gsub!( %r{\[(#{Regexp.escape( Color.underline )}.*?#{Regexp.escape( Color.reset )})\]},
|
138
143
|
" (\\1)" )
|
139
144
|
text
|
140
145
|
end
|
@@ -144,7 +149,7 @@ module Bri
|
|
144
149
|
end
|
145
150
|
|
146
151
|
def self.wrap_list( array, width = Bri.width )
|
147
|
-
indent( wrap_to_width( array.join("
|
152
|
+
indent( wrap_to_width( array.join(" "), width ) )
|
148
153
|
end
|
149
154
|
|
150
155
|
def self.wrap_to_width( styled_text, width )
|
data/lib/bri/search.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
require_relative 'search/base'
|
2
|
+
require_relative 'search/class'
|
3
|
+
require_relative 'search/method'
|
4
|
+
require_relative 'search/class_method'
|
5
|
+
require_relative 'search/instance_method'
|
data/lib/bri/templates.rb
CHANGED