bri 0.4.3 → 0.4.4
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 +10 -0
- data/README.rdoc +8 -1
- data/bin/bri +4 -3
- data/lib/bri.rb +9 -2
- data/lib/bri/renderer.rb +38 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74b87ae62d01b5be9164734271754be0cc3a1ef68ad3b35bd78b633d829a529a
|
4
|
+
data.tar.gz: 27fdfe717c1cea3b49525ff5e9c59b462757d1d86db440bd4dc1fd9719f47c70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0d96c3ae752ec0b5b3fb59ad58da596869fd91665282eeb588ba8c03041b3f26040f331189b9db84a6d55aaf5e5540430dddbd07c925a7dde198ed6939bc7f0
|
7
|
+
data.tar.gz: 4f3cc64561cb91cc53caf689611c32f6daf8d0482eb2bee3407358fad32fd808e0b70ce613c979b57917c0c2afe4b135f48f46e19de8888a167591d205aadecc
|
data/Changelog
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
0.4.4
|
2
|
+
- No longer display all found class/module documentation found. If core
|
3
|
+
documentation is available, output only that, otherwise falls back to gem
|
4
|
+
documentation. To show all found documentation use the --all command line
|
5
|
+
paramter.
|
6
|
+
- Remove blank lines between list items. While these make lists with
|
7
|
+
multi row items more readable, they waste a lot of space for lists
|
8
|
+
containing only single row items. The blank line will be reintroduced for
|
9
|
+
lists containing multi row elements later on.
|
10
|
+
|
1
11
|
0.4.3
|
2
12
|
- If multiple documentations are found that are all class documentations,
|
3
13
|
display all of these. This is useful in cases that gems extend core
|
data/README.rdoc
CHANGED
@@ -24,7 +24,14 @@ Bri is a Beautiful RI formatter.
|
|
24
24
|
|
25
25
|
= Usage
|
26
26
|
|
27
|
-
bri Array # looks up the class description of Array in the ri documentation
|
27
|
+
bri Array # looks up the class description of Array in the ri documentation.
|
28
|
+
# As of 0.4.4 this form will only output core documentation if
|
29
|
+
# available, falling back to gem documentation if no core
|
30
|
+
# documentation is found. This way you can look at the documentation
|
31
|
+
# of core classes that gems love to money patch without having
|
32
|
+
# to scroll back through your terminal.
|
33
|
+
# If you really want to see everything there is, use --all:
|
34
|
+
bri --all Array
|
28
35
|
|
29
36
|
bri Array.class_method # looks up the class method of the given class
|
30
37
|
|
data/bin/bri
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'bri'
|
3
3
|
require 'optparse'
|
4
|
-
require 'byebug'
|
5
4
|
|
6
5
|
@options = {
|
7
6
|
:list_classes => false,
|
8
7
|
:list_methods => false,
|
9
|
-
:list_names => false
|
8
|
+
:list_names => false,
|
9
|
+
:show_all => false
|
10
10
|
}
|
11
11
|
|
12
12
|
def parse_options
|
@@ -24,6 +24,7 @@ def parse_options
|
|
24
24
|
opts.on( nil, "--methods", "List known methods" ) { |v| @options[:list_methods] = true }
|
25
25
|
opts.on( "-l", "--list-names", "List known namespaces/methods" ) { |v| @options[:list_names] = true }
|
26
26
|
opts.on( "-w", "--width [COLUMNS]", "Set the output width", Integer ) { |v| Bri.width = v.to_i - 8 }
|
27
|
+
opts.on( "-a", "--all", "Output all documentation for the term. Prefers core documents otherwise") { |v| @options[:show_all] = true }
|
27
28
|
opts.on_tail( "-h", "--help", "This help text" ) { puts opts; exit }
|
28
29
|
end
|
29
30
|
parser.parse!( ARGV )
|
@@ -44,5 +45,5 @@ elsif @options[:list_methods]
|
|
44
45
|
elsif @options[:list_names]
|
45
46
|
puts Bri.list_names
|
46
47
|
else
|
47
|
-
puts Bri.ri( ARGV[0] )
|
48
|
+
puts Bri.ri( ARGV[0], show_all: @options[:show_all] )
|
48
49
|
end
|
data/lib/bri.rb
CHANGED
@@ -11,7 +11,7 @@ require_relative 'bri/match'
|
|
11
11
|
module Bri
|
12
12
|
DEFAULT_WIDTH = 72
|
13
13
|
|
14
|
-
def self.ri( query )
|
14
|
+
def self.ri( query, show_all: false )
|
15
15
|
results = Bri::Matcher.new( query ).find
|
16
16
|
|
17
17
|
if results.size == 0
|
@@ -19,7 +19,14 @@ module Bri
|
|
19
19
|
elsif results.size == 1
|
20
20
|
results.first.to_s
|
21
21
|
elsif results.all? { |r| r.is_a?(Bri::Match::Class) }
|
22
|
-
|
22
|
+
if show_all
|
23
|
+
results.map(&:to_s)
|
24
|
+
else
|
25
|
+
gem_docs, core_docs = results.partition { |r| r.origin =~ %r{gem\b} }
|
26
|
+
|
27
|
+
docs_to_output = core_docs.empty? ? gem_docs : core_docs
|
28
|
+
docs_to_output.map(&:to_s)
|
29
|
+
end
|
23
30
|
else
|
24
31
|
qualified_methods = results.map(&:full_name).sort
|
25
32
|
ERB.new( Bri::Templates::MULTIPLE_CHOICES, nil, '<>' ).result( binding )
|
data/lib/bri/renderer.rb
CHANGED
@@ -50,7 +50,7 @@ module Bri
|
|
50
50
|
rendered_items.map! { |item| item.gsub( /\n/, "\n#{INDENT}" ) }
|
51
51
|
end
|
52
52
|
|
53
|
-
"#{rendered_items.join( "\n
|
53
|
+
"#{rendered_items.join( "\n" )}\n"
|
54
54
|
|
55
55
|
else
|
56
56
|
text = extract_text( element, width, alignment_width )
|
@@ -66,44 +66,43 @@ module Bri
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def self.extract_text( element, width, label_alignment_width = 0, conserve_newlines = false )
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
text << "\n"
|
69
|
+
case element
|
70
|
+
when RDoc::Markup::Paragraph
|
71
|
+
join_char = conserve_newlines ? "\n" : " "
|
72
|
+
element.parts.map(&:strip).join( join_char ) + "\n"
|
73
|
+
|
74
|
+
when RDoc::Markup::BlankLine
|
75
|
+
"\n"
|
76
|
+
|
77
|
+
when RDoc::Markup::Rule
|
78
|
+
"-" * width + "\n"
|
79
|
+
|
80
|
+
when RDoc::Markup::Verbatim
|
81
|
+
element.parts.map { |part| part.prepend( " " ) }.join + "\n"
|
82
|
+
|
83
|
+
when RDoc::Markup::Heading
|
84
|
+
"<h>#{element.text}</h>\n"
|
85
|
+
|
86
|
+
when RDoc::Markup::ListItem
|
87
|
+
parts = element.parts.map { |part| extract_text( part, width, 0, true ) }.join
|
88
|
+
|
89
|
+
if element.label
|
90
|
+
labels = element.label.map { |l| "#{l}:" }.join("\n")
|
91
|
+
sprintf( "%*s %s", -label_alignment_width, labels, parts )
|
92
|
+
else
|
93
|
+
parts
|
94
|
+
end
|
95
|
+
|
96
|
+
when RDoc::Markup::List
|
97
|
+
render( element, width - INDENT_WIDTH ) + "\n"
|
98
|
+
|
99
|
+
when RDoc::Markup::Document
|
100
|
+
element.parts.
|
101
|
+
map { |part| extract_text( part, width, label_alignment_width, conserve_newlines ) }.
|
102
|
+
join + "\n"
|
103
|
+
else
|
104
|
+
raise "Don't know how to handle type #{element.class}: #{element.inspect}"
|
105
|
+
end
|
107
106
|
end
|
108
107
|
|
109
108
|
def self.replace_markup( text )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Riedel
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
rubygems_version: 3.0.
|
140
|
+
rubygems_version: 3.0.4
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: Beautified RI in the spirit of fastri/qri. Unlike fastri, bri builds on top
|