bri 0.4.3 → 0.5.0
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 +12 -0
- data/README.rdoc +8 -1
- data/bin/bri +5 -3
- data/lib/bri/mall.rb +5 -2
- data/lib/bri/match/base.rb +6 -1
- data/lib/bri/match/class.rb +2 -1
- data/lib/bri/match/method.rb +2 -1
- data/lib/bri/renderer.rb +38 -39
- data/lib/bri.rb +9 -2
- data/spec/lib/bri/match/method_spec.rb +6 -2
- data/spec/lib/bri/search/class_method_spec.rb +3 -2
- data/spec/lib/bri/search/instance_method_spec.rb +3 -2
- metadata +6 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a88edaf5dc38f84306db04f904d1fb32859536587b7fa5ce84f3be687c5d1638
|
4
|
+
data.tar.gz: 1d8ace29c2676219311960e6729bc8b0e453ae00fd5a88294f809be65955024f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e7eb14da6bd17fdff9e5db187fe086f9592dcb682c18e082248ab61ef37685fd81e16cbe49198fbf9446cf3eccb1ac5f163ba7da906ef1b67a38329cfdb3eb2
|
7
|
+
data.tar.gz: 91fef7322fd718245385929888a5dcf48616c07c247621d4e22f8369b625e77185969af70fff295bc1538c0bcb5b2651a716143d15b54ee8f830f71439bbe317
|
data/Changelog
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
0.5.0
|
2
|
+
- Update rdoc requirement to 6.13
|
3
|
+
0.4.4
|
4
|
+
- No longer display all found class/module documentation found. If core
|
5
|
+
documentation is available, output only that, otherwise falls back to gem
|
6
|
+
documentation. To show all found documentation use the --all command line
|
7
|
+
paramter.
|
8
|
+
- Remove blank lines between list items. While these make lists with
|
9
|
+
multi row items more readable, they waste a lot of space for lists
|
10
|
+
containing only single row items. The blank line will be reintroduced for
|
11
|
+
lists containing multi row elements later on.
|
12
|
+
|
1
13
|
0.4.3
|
2
14
|
- If multiple documentations are found that are all class documentations,
|
3
15
|
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,8 @@ 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 }
|
28
|
+
opts.on( "-v", "--version", "0.5.0.beta1")
|
27
29
|
opts.on_tail( "-h", "--help", "This help text" ) { puts opts; exit }
|
28
30
|
end
|
29
31
|
parser.parse!( ARGV )
|
@@ -44,5 +46,5 @@ elsif @options[:list_methods]
|
|
44
46
|
elsif @options[:list_names]
|
45
47
|
puts Bri.list_names
|
46
48
|
else
|
47
|
-
puts Bri.ri( ARGV[0] )
|
49
|
+
puts Bri.ri( ARGV[0], show_all: @options[:show_all] )
|
48
50
|
end
|
data/lib/bri/mall.rb
CHANGED
@@ -31,8 +31,11 @@ module Bri
|
|
31
31
|
private
|
32
32
|
def initialize
|
33
33
|
# We want: system, site, home and gem documentation
|
34
|
-
|
35
|
-
|
34
|
+
options = RDoc::Options.new
|
35
|
+
@stores = RDoc::RI::Paths.each( true, true, true, true ).
|
36
|
+
each_with_object( [] ) do |(path, type), stores|
|
37
|
+
stores << RDoc::Store.new( options, path: path, type: type ).
|
38
|
+
tap { |store| store.load_cache }
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
data/lib/bri/match/base.rb
CHANGED
@@ -2,11 +2,16 @@ module Bri
|
|
2
2
|
module Match
|
3
3
|
class Base
|
4
4
|
def to_s
|
5
|
-
ERB.new( self.class.const_get( :TEMPLATE ),
|
5
|
+
ERB.new( self.class.const_get( :TEMPLATE ), trim_mode: '<>' ).
|
6
6
|
result( binding )
|
7
7
|
end
|
8
8
|
|
9
9
|
private
|
10
|
+
def build_description_from_comment( comment )
|
11
|
+
document = comment.instance_variable_get( :@document )
|
12
|
+
build_description( document.parts )
|
13
|
+
end
|
14
|
+
|
10
15
|
def build_description( source )
|
11
16
|
source.map { |element| Bri::Renderer.render( element ) }.compact
|
12
17
|
end
|
data/lib/bri/match/class.rb
CHANGED
@@ -18,7 +18,8 @@ module Bri
|
|
18
18
|
@type = rdoc_result.type
|
19
19
|
@name = "#{rdoc_result.full_name}"
|
20
20
|
@name << " < #{rdoc_result.superclass}" if @type == "class" && rdoc_result.superclass
|
21
|
-
|
21
|
+
|
22
|
+
@description_paragraphs = build_description_from_comment( rdoc_result.comment )
|
22
23
|
@includes = rdoc_result.includes.map(&:full_name)
|
23
24
|
@extends = rdoc_result.extends.map(&:full_name)
|
24
25
|
@attributes = rdoc_result.attributes.map { |a| "#{a.name} (#{a.rw})" }
|
data/lib/bri/match/method.rb
CHANGED
@@ -11,7 +11,8 @@ module Bri
|
|
11
11
|
@call_syntaxes = rdoc_method.arglists.lines( chomp: true ).
|
12
12
|
map { |e| e.prepend( " " ) }.
|
13
13
|
join( "\n" ) + "\n" rescue ''
|
14
|
-
|
14
|
+
|
15
|
+
@description_paragraphs = build_description_from_comment( rdoc_method.comment )
|
15
16
|
@origin = store&.friendly_path
|
16
17
|
end
|
17
18
|
end
|
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 )
|
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 )
|
@@ -9,10 +9,14 @@ describe Bri::Match::Method do
|
|
9
9
|
double( RDoc::Markup::Document, :parts => [ fake_paragraph ] )
|
10
10
|
end
|
11
11
|
|
12
|
+
let( :fake_comment ) do
|
13
|
+
double( RDoc::Comment, :instance_variable_get => fake_description )
|
14
|
+
end
|
15
|
+
|
12
16
|
let( :rdoc_method ) do
|
13
17
|
double( RDoc::AnyMethod, :full_name => "This::IS::My.full_name",
|
14
|
-
|
15
|
-
|
18
|
+
:arglists => "First\nSecond\nThird",
|
19
|
+
:comment => fake_comment )
|
16
20
|
end
|
17
21
|
|
18
22
|
describe "#initialize" do
|
@@ -4,9 +4,10 @@ describe Bri::Search::ClassMethod do
|
|
4
4
|
context "the searches" do
|
5
5
|
let( :paragraph ) { RDoc::Markup::Paragraph.new( "Foo Description" ) }
|
6
6
|
let( :document ) { double( RDoc::Markup::Document, :parts => [ paragraph ] ) }
|
7
|
+
let( :comment ) { double( RDoc::Comment, :instance_variable_get => document ) }
|
7
8
|
let( :rdoc_method ) { double( RDoc::AnyMethod, :full_name => "Foo",
|
8
|
-
|
9
|
-
|
9
|
+
:arglists => "",
|
10
|
+
:comment => comment ) }
|
10
11
|
before( :each ) do
|
11
12
|
store_one = double( RDoc::RI::Store, :load_cache => true,
|
12
13
|
:load_class => true,
|
@@ -4,9 +4,10 @@ describe Bri::Search::InstanceMethod do
|
|
4
4
|
context "the searches" do
|
5
5
|
let( :paragraph ) { RDoc::Markup::Paragraph.new( "Foo Description" ) }
|
6
6
|
let( :document ) { double( RDoc::Markup::Document, :parts => [ paragraph ] ) }
|
7
|
+
let( :comment ) { double( RDoc::Comment, :instance_variable_get => document ) }
|
7
8
|
let( :rdoc_method ) { double( RDoc::AnyMethod, :full_name => "Foo",
|
8
|
-
|
9
|
-
|
9
|
+
:arglists => "",
|
10
|
+
:comment => comment ) }
|
10
11
|
before( :each ) do
|
11
12
|
store_one = double( RDoc::RI::Store, :load_cache => true,
|
12
13
|
:load_class => true,
|
metadata
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Riedel
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
10
|
date: 2011-05-20 00:00:00.000000000 Z
|
@@ -30,28 +29,28 @@ dependencies:
|
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: 6.
|
32
|
+
version: 6.13.0
|
34
33
|
type: :runtime
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: 6.
|
39
|
+
version: 6.13.0
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
41
|
name: rspec
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
46
|
+
version: 3.13.0
|
48
47
|
type: :development
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
53
|
+
version: 3.13.0
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: rspec-its
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
@@ -121,7 +120,6 @@ files:
|
|
121
120
|
homepage: http://github.com/sriedel/bri
|
122
121
|
licenses: []
|
123
122
|
metadata: {}
|
124
|
-
post_install_message:
|
125
123
|
rdoc_options:
|
126
124
|
- "--charset=UTF-8"
|
127
125
|
require_paths:
|
@@ -137,8 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
135
|
- !ruby/object:Gem::Version
|
138
136
|
version: '0'
|
139
137
|
requirements: []
|
140
|
-
rubygems_version: 3.
|
141
|
-
signing_key:
|
138
|
+
rubygems_version: 3.6.5
|
142
139
|
specification_version: 4
|
143
140
|
summary: Beautified RI in the spirit of fastri/qri. Unlike fastri, bri builds on top
|
144
141
|
of the rdoc 2.x/3.x backend, only output and formatting is handled by bri
|