bri 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +6 -0
- data/lib/bri/match/class.rb +3 -2
- data/lib/bri/match/method.rb +3 -2
- data/lib/bri/renderer.rb +5 -4
- data/lib/bri/search/class.rb +1 -1
- data/lib/bri/search/method.rb +3 -3
- data/lib/bri/templates.rb +9 -0
- data/spec/lib/bri/match/method_spec.rb +1 -1
- data/spec/lib/bri/renderer_spec.rb +1 -1
- data/spec/lib/bri/search/class_method_spec.rb +10 -8
- data/spec/lib/bri/search/class_spec.rb +8 -6
- data/spec/lib/bri/search/instance_method_spec.rb +10 -8
- metadata +36 -42
data/Changelog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.2.1
|
2
|
+
- Show origin of class/method in description output
|
3
|
+
- Better textflow within paragraphs by ignoring the original newlines
|
4
|
+
- But keep original newlines within list items
|
5
|
+
- Add missing newline after verbatim sections
|
6
|
+
|
1
7
|
0.2.0
|
2
8
|
- Add extensive specs for matching, searching and rendering
|
3
9
|
- Fix bug with rendering very narrow horizontal rules
|
data/lib/bri/match/class.rb
CHANGED
@@ -9,9 +9,9 @@ module Bri
|
|
9
9
|
|
10
10
|
attr_reader :type, :name, :description_paragraphs
|
11
11
|
attr_reader :includes, :constants, :class_methods, :instance_methods
|
12
|
-
attr_reader :attributes
|
12
|
+
attr_reader :attributes, :origin
|
13
13
|
|
14
|
-
def initialize( rdoc_result )
|
14
|
+
def initialize( rdoc_result, store = nil )
|
15
15
|
@type = rdoc_result.type
|
16
16
|
@name = rdoc_result.full_name
|
17
17
|
@description_paragraphs = build_description( rdoc_result.comment.parts )
|
@@ -26,6 +26,7 @@ module Bri
|
|
26
26
|
partition { |m| m.singleton }
|
27
27
|
@class_methods = class_methods.collect { |m| m.name }
|
28
28
|
@instance_methods = instance_methods.collect { |m| m.name }
|
29
|
+
@origin = store ? store.friendly_path : nil
|
29
30
|
end
|
30
31
|
|
31
32
|
end
|
data/lib/bri/match/method.rb
CHANGED
@@ -4,14 +4,15 @@ module Bri
|
|
4
4
|
include Bri::Templates::Helpers
|
5
5
|
TEMPLATE = Bri::Templates::METHOD_DESCRIPTION
|
6
6
|
|
7
|
-
attr_accessor :full_name, :call_syntaxes, :description_paragraphs
|
7
|
+
attr_accessor :full_name, :call_syntaxes, :description_paragraphs, :origin
|
8
8
|
|
9
|
-
def initialize( rdoc_method )
|
9
|
+
def initialize( rdoc_method, store = nil )
|
10
10
|
@full_name = rdoc_method.full_name
|
11
11
|
@call_syntaxes = rdoc_method.arglists.split( "\n" ).
|
12
12
|
map { |e| " " + e }.
|
13
13
|
join( "\n" ) + "\n" rescue ''
|
14
14
|
@description_paragraphs = build_description( rdoc_method.comment.parts )
|
15
|
+
@origin = store ? store.friendly_path : nil
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
data/lib/bri/renderer.rb
CHANGED
@@ -11,7 +11,7 @@ module Bri
|
|
11
11
|
when RDoc::Markup::Verbatim
|
12
12
|
text = extract_text( element, width )
|
13
13
|
styled_text = replace_markup( text )
|
14
|
-
indent( styled_text )
|
14
|
+
indent( styled_text ) + "\n"
|
15
15
|
|
16
16
|
when RDoc::Markup::List
|
17
17
|
item_width = width - INDENT.length
|
@@ -54,10 +54,11 @@ module Bri
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
def self.extract_text( element, width, label_alignment_width = 0 )
|
57
|
+
def self.extract_text( element, width, label_alignment_width = 0, conserve_newlines = false )
|
58
58
|
text = case element
|
59
59
|
when RDoc::Markup::Paragraph
|
60
|
-
|
60
|
+
join_char = conserve_newlines ? "\n" : " "
|
61
|
+
element.parts.join( join_char )
|
61
62
|
when RDoc::Markup::BlankLine
|
62
63
|
""
|
63
64
|
when RDoc::Markup::Rule
|
@@ -67,7 +68,7 @@ module Bri
|
|
67
68
|
when RDoc::Markup::Heading
|
68
69
|
"<h>#{element.text}</h>"
|
69
70
|
when RDoc::Markup::ListItem
|
70
|
-
parts = element.parts.collect { |part| extract_text part, width }.join
|
71
|
+
parts = element.parts.collect { |part| extract_text part, width, 0, true }.join
|
71
72
|
element.label ? sprintf( "%*s %s", -label_alignment_width, "#{element.label}:", parts ) : parts
|
72
73
|
when RDoc::Markup::List
|
73
74
|
render( element, width - INDENT.length )
|
data/lib/bri/search/class.rb
CHANGED
@@ -6,7 +6,7 @@ module Bri
|
|
6
6
|
# NOTE: classes are only searched as fully qualified for the time being
|
7
7
|
# FIXME: What do we do if more than one store defines the same class?
|
8
8
|
store = Bri::Mall.instance.stores.detect { |s| s.modules.include? @term }
|
9
|
-
@matches << Bri::Match::Class.new( store.load_class( @term ) ) if store
|
9
|
+
@matches << Bri::Match::Class.new( store.load_class( @term ), store ) if store
|
10
10
|
end
|
11
11
|
|
12
12
|
end
|
data/lib/bri/search/method.rb
CHANGED
@@ -27,7 +27,7 @@ module Bri
|
|
27
27
|
def fully_qualified_search
|
28
28
|
store = store_for_method
|
29
29
|
|
30
|
-
@matches << Bri::Match::Method.new( method_rdoc( store ) ) if store
|
30
|
+
@matches << Bri::Match::Method.new( method_rdoc( store ), store ) if store
|
31
31
|
end
|
32
32
|
|
33
33
|
def store_for_method
|
@@ -58,7 +58,7 @@ module Bri
|
|
58
58
|
match_data = method_rdoc( store, klass, @method_term )
|
59
59
|
next unless match_data
|
60
60
|
|
61
|
-
@matches << Bri::Match::Method.new( match_data )
|
61
|
+
@matches << Bri::Match::Method.new( match_data, store )
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -79,7 +79,7 @@ module Bri
|
|
79
79
|
match_data = method_rdoc( store, klass, method )
|
80
80
|
next unless match_data
|
81
81
|
|
82
|
-
@matches << Bri::Match::Method.new( match_data )
|
82
|
+
@matches << Bri::Match::Method.new( match_data, store )
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
data/lib/bri/templates.rb
CHANGED
@@ -10,6 +10,8 @@ module Bri
|
|
10
10
|
|
11
11
|
CLASS_DESCRIPTION =<<-EOT
|
12
12
|
<%= hrule( type + ": " + name ) %>
|
13
|
+
<%= print_origin( origin ) %>
|
14
|
+
|
13
15
|
<% if description_paragraphs.empty? %>
|
14
16
|
(no description...)
|
15
17
|
<% else %>
|
@@ -52,6 +54,8 @@ module Bri
|
|
52
54
|
|
53
55
|
METHOD_DESCRIPTION =<<-EOT
|
54
56
|
<%= hrule( full_name ) %>
|
57
|
+
<%= print_origin( origin ) %>
|
58
|
+
|
55
59
|
<%= call_syntaxes %>
|
56
60
|
<%= hrule %>
|
57
61
|
<% if description_paragraphs.empty? %>
|
@@ -73,6 +77,11 @@ module Bri
|
|
73
77
|
end
|
74
78
|
module_function :hrule
|
75
79
|
|
80
|
+
def print_origin( origin_text, width = Bri.width )
|
81
|
+
return unless origin_text
|
82
|
+
"(#{origin_text})".rjust( width )
|
83
|
+
end
|
84
|
+
|
76
85
|
def section_header( text )
|
77
86
|
Term::ANSIColor::green + Term::ANSIColor::underline + text + Term::ANSIColor::reset + "\n"
|
78
87
|
end
|
@@ -20,7 +20,7 @@ describe Bri::Match::Method do
|
|
20
20
|
|
21
21
|
its( :full_name ) { should == rdoc_method.full_name }
|
22
22
|
its( :call_syntaxes ) { should == " First\n Second\n Third\n" }
|
23
|
-
its( :description_paragraphs ) { should == [ " This is line one
|
23
|
+
its( :description_paragraphs ) { should == [ " This is line one This is line two" ] }
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#full_name" do
|
@@ -308,7 +308,7 @@ describe Bri::Renderer do
|
|
308
308
|
|
309
309
|
context "with multi word labels" do
|
310
310
|
it "should show the link underlined after the label in brackets and remove the rdoc label curly braces" do
|
311
|
-
subject.should =~ /Multi
|
311
|
+
subject.should =~ /Multi\s+Word\s+Labels\s+\(#{underline}http:\/\/www.github.com#{reset}\)/m
|
312
312
|
end
|
313
313
|
end
|
314
314
|
end
|
@@ -8,15 +8,17 @@ describe Bri::Search::ClassMethod do
|
|
8
8
|
:arglists => "",
|
9
9
|
:comment => document ) }
|
10
10
|
before( :each ) do
|
11
|
-
store_one = mock( RDoc::RI::Store, :load_cache
|
12
|
-
:load_class
|
13
|
-
:load_method
|
14
|
-
:
|
11
|
+
store_one = mock( RDoc::RI::Store, :load_cache => true,
|
12
|
+
:load_class => true,
|
13
|
+
:load_method => rdoc_method,
|
14
|
+
:friendly_path => "ruby core",
|
15
|
+
:modules => %w{ ClassThree },
|
15
16
|
:class_methods => { "ClassThree" => [ "method" ] } )
|
16
|
-
store_two = mock( RDoc::RI::Store, :load_cache
|
17
|
-
:load_class
|
18
|
-
:load_method
|
19
|
-
:
|
17
|
+
store_two = mock( RDoc::RI::Store, :load_cache => true,
|
18
|
+
:load_class => true,
|
19
|
+
:load_method => rdoc_method,
|
20
|
+
:friendly_path => "ruby core",
|
21
|
+
:modules => %w{ ClassOne ClassTwo },
|
20
22
|
:class_methods => { "ClassOne" => [ "method" ],
|
21
23
|
"ClassTwo" => [ "method", "my_other_method" ] } )
|
22
24
|
Bri::Mall.instance.stub!( :stores => [ store_one, store_two ] )
|
@@ -13,12 +13,14 @@ describe Bri::Search::Class do
|
|
13
13
|
describe "#search" do
|
14
14
|
context "basic functionality" do
|
15
15
|
before( :each ) do
|
16
|
-
store_one = mock( RDoc::RI::Store, :load_cache
|
17
|
-
:load_class
|
18
|
-
:
|
19
|
-
|
20
|
-
|
21
|
-
:
|
16
|
+
store_one = mock( RDoc::RI::Store, :load_cache => true,
|
17
|
+
:load_class => true,
|
18
|
+
:friendly_path => "ruby core",
|
19
|
+
:modules => %w{ ClassThree } )
|
20
|
+
store_two = mock( RDoc::RI::Store, :load_cache => true,
|
21
|
+
:load_class => true,
|
22
|
+
:friendly_path => "ruby core",
|
23
|
+
:modules => %w{ ClassOne ClassTwo } )
|
22
24
|
Bri::Mall.instance.stub!( :stores => [ store_one, store_two ] )
|
23
25
|
Bri::Match::Class.stub!( :new ).and_return( mock( Bri::Match::Class ) )
|
24
26
|
end
|
@@ -8,15 +8,17 @@ describe Bri::Search::InstanceMethod do
|
|
8
8
|
:arglists => "",
|
9
9
|
:comment => document ) }
|
10
10
|
before( :each ) do
|
11
|
-
store_one = mock( RDoc::RI::Store, :load_cache
|
12
|
-
:load_class
|
13
|
-
:load_method
|
14
|
-
:
|
11
|
+
store_one = mock( RDoc::RI::Store, :load_cache => true,
|
12
|
+
:load_class => true,
|
13
|
+
:load_method => rdoc_method,
|
14
|
+
:friendly_path => "ruby core",
|
15
|
+
:modules => %w{ ClassThree },
|
15
16
|
:instance_methods => { "ClassThree" => [ "method" ] } )
|
16
|
-
store_two = mock( RDoc::RI::Store, :load_cache
|
17
|
-
:load_class
|
18
|
-
:load_method
|
19
|
-
:
|
17
|
+
store_two = mock( RDoc::RI::Store, :load_cache => true,
|
18
|
+
:load_class => true,
|
19
|
+
:load_method => rdoc_method,
|
20
|
+
:friendly_path => "ruby core",
|
21
|
+
:modules => %w{ ClassOne ClassTwo },
|
20
22
|
:instance_methods => { "ClassOne" => [ "method" ],
|
21
23
|
"ClassTwo" => [ "method", "my_other_method" ] } )
|
22
24
|
Bri::Mall.instance.stub!( :stores => [ store_one, store_two ] )
|
metadata
CHANGED
@@ -1,49 +1,46 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bri
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Sven Riedel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-05-20 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: term-ansicolor
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &10035380 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
24
21
|
version: 1.0.5
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rdoc
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *10035380
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rdoc
|
27
|
+
requirement: &10211940 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
29
|
+
requirements:
|
33
30
|
- - ~>
|
34
|
-
- !ruby/object:Gem::Version
|
31
|
+
- !ruby/object:Gem::Version
|
35
32
|
version: 3.5.2
|
36
33
|
type: :runtime
|
37
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *10211940
|
38
36
|
description: An alternative to the ri command
|
39
37
|
email: sr@gimp.org
|
40
|
-
executables:
|
38
|
+
executables:
|
41
39
|
- bri
|
42
40
|
extensions: []
|
43
|
-
|
44
|
-
extra_rdoc_files:
|
41
|
+
extra_rdoc_files:
|
45
42
|
- README
|
46
|
-
files:
|
43
|
+
files:
|
47
44
|
- README
|
48
45
|
- TODO
|
49
46
|
- Changelog
|
@@ -74,33 +71,30 @@ files:
|
|
74
71
|
- spec/lib/bri/search/class_method_spec.rb
|
75
72
|
- spec/lib/bri/search/instance_method_spec.rb
|
76
73
|
- spec/lib/bri/search/method_spec.rb
|
77
|
-
has_rdoc: true
|
78
74
|
homepage: http://github.com/sriedel/bri
|
79
75
|
licenses: []
|
80
|
-
|
81
76
|
post_install_message:
|
82
|
-
rdoc_options:
|
77
|
+
rdoc_options:
|
83
78
|
- --charset=UTF-8
|
84
|
-
require_paths:
|
79
|
+
require_paths:
|
85
80
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
82
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
91
86
|
version: 1.9.2
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
88
|
none: false
|
94
|
-
requirements:
|
95
|
-
- -
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version:
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
98
93
|
requirements: []
|
99
|
-
|
100
94
|
rubyforge_project:
|
101
|
-
rubygems_version: 1.
|
95
|
+
rubygems_version: 1.8.2
|
102
96
|
signing_key:
|
103
97
|
specification_version: 3
|
104
|
-
summary: Beautified RI in the spirit of fastri/qri. Unlike fastri, bri builds on top
|
98
|
+
summary: Beautified RI in the spirit of fastri/qri. Unlike fastri, bri builds on top
|
99
|
+
of the rdoc 2.x/3.x backend, only output and formatting is handled by bri
|
105
100
|
test_files: []
|
106
|
-
|