bri 0.5.0 → 1.0.0.pre.beta1

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Changelog +0 -2
  3. data/TODO +2 -3
  4. data/bin/bri +21 -8
  5. data/lib/bri/mall.rb +12 -17
  6. data/lib/bri/match/base.rb +2 -7
  7. data/lib/bri/match/class.rb +6 -3
  8. data/lib/bri/match/method.rb +3 -3
  9. data/lib/bri/renderer/blank_line.rb +9 -0
  10. data/lib/bri/renderer/default.rb +27 -0
  11. data/lib/bri/renderer/document.rb +11 -0
  12. data/lib/bri/renderer/heading.rb +9 -0
  13. data/lib/bri/renderer/list/base.rb +18 -0
  14. data/lib/bri/renderer/list/bullet.rb +15 -0
  15. data/lib/bri/renderer/list/labeled.rb +15 -0
  16. data/lib/bri/renderer/list/lower_lettered.rb +18 -0
  17. data/lib/bri/renderer/list/note.rb +15 -0
  18. data/lib/bri/renderer/list/numbered.rb +18 -0
  19. data/lib/bri/renderer/list/upper_lettered.rb +18 -0
  20. data/lib/bri/renderer/list.rb +24 -0
  21. data/lib/bri/renderer/list_item.rb +24 -0
  22. data/lib/bri/renderer/paragraph.rb +11 -0
  23. data/lib/bri/renderer/result.rb +73 -0
  24. data/lib/bri/renderer/rule.rb +9 -0
  25. data/lib/bri/renderer/verbatim.rb +14 -0
  26. data/lib/bri/renderer.rb +28 -188
  27. data/lib/bri/search/class.rb +3 -1
  28. data/lib/bri/search/method.rb +3 -3
  29. data/lib/bri/templates.rb +7 -38
  30. data/lib/bri/text_formatting_utils.rb +92 -0
  31. data/lib/bri.rb +18 -15
  32. metadata +27 -17
  33. data/spec/bri_dummy_spec_class.rb +0 -132
  34. data/spec/lib/bri/mall_spec.rb +0 -38
  35. data/spec/lib/bri/match/class_spec.rb +0 -125
  36. data/spec/lib/bri/match/method_spec.rb +0 -116
  37. data/spec/lib/bri/matcher_spec.rb +0 -70
  38. data/spec/lib/bri/renderer_spec.rb +0 -338
  39. data/spec/lib/bri/search/class_method_spec.rb +0 -173
  40. data/spec/lib/bri/search/class_spec.rb +0 -66
  41. data/spec/lib/bri/search/instance_method_spec.rb +0 -174
  42. data/spec/lib/bri/search/method_spec.rb +0 -41
  43. data/spec/spec_helper.rb +0 -22
@@ -1,132 +0,0 @@
1
- # This is a class description
2
- class BriDummySpecClassTwo
3
- include BriDummySpecModule
4
- extend BriDummySpecModuleTwo
5
- CONSTANT = 'value'
6
- OTHER_CONSTANT = nil
7
- attr_reader :read_attr
8
- attr_writer :write_attr
9
- attr_accessor :access_attr
10
-
11
- def self.bri_dummy_spec_second_singleton_method; end
12
- def bri_dummy_spec_instance_method_with_arguments( a, b ); end
13
- end
14
-
15
- class BriDummySpecClassEmpty; end
16
-
17
- module BriDummySpecModule; end
18
- module BriDummySpecModuleTwo; end
19
-
20
- module BriDummySpec
21
- class Class; end
22
- end
23
-
24
- class BriDummySpecClass
25
- def self.bri_dummy_spec_singleton_method; end
26
- def self.bri_dummy_spec_second_singleton_method; end
27
-
28
- def bri_dummy_spec_instance_method; end
29
-
30
- def bri_dummy_spec_instance_method_with_arguments( a, b ); end
31
-
32
- def bri_dummy_spec_instance_method_with_default_arguments( a, b, c = nil ); end
33
-
34
- def bri_dummy_spec_instance_method_which_yields
35
- yield yield_param_one, yield_param_two
36
- end
37
-
38
- def bri_dummy_spec_instance_method_with_yield_override # :yields: foo, bar
39
- yield yield_param_one, yield_param_two
40
- end
41
-
42
-
43
- # = This is a headline
44
- #
45
- # Followed by some introduction text.
46
- def basic_headline_and_paragraph_rendering_test_method; end
47
-
48
- # == This is a level two headline
49
- # This is a paragraph with a really really really really really really really really really really long line that needs to be wrapped.
50
- def level_two_headline_and_line_wrapping_rendering_test_method; end
51
-
52
- # This is some text before a horizontal rule.
53
- # ---
54
- # After a horizontal rule, the text continues.
55
- def horizontal_rule_rendering_test_method; end
56
-
57
- # * First item in a bulleted list
58
- # With a second line
59
- # * Second item in a bulleted list
60
- # * First item of a nested bulleted list
61
- # * Second item of a nested bulleted list
62
- # * Ending a bulleted list with a really really really really really really really really long line that needs to be wrapped
63
- def bulleted_list_rendering_test_method; end
64
-
65
- # - A second bulleted list
66
- # - Second item in second bulleted list
67
- # - Nested bulleted list
68
- # - Second nested bulleted list item
69
- # - Ending the second bulleted list
70
- def second_bulleted_list_rendering_test_method; end
71
-
72
- # 1. First numbered list item
73
- # 2. Second numbered list
74
- # 1. Nested numbered list item
75
- # 2. Second nested numbered list item
76
- # 3. Ending the main numbered list item
77
- def numbered_list_rendering_test_method; end
78
-
79
- # a. Some goes for lettered lists
80
- # b. Second item in a lettered list
81
- # a. And a nested lettered list item
82
- # c. Second nested lettered list item
83
- # c. Ending the main lettered list item.
84
- def lettered_list_rendering_test_method; end
85
-
86
- # * A mixed list, containing
87
- # * bullets in the main list
88
- # 1. And numbers in a sublist
89
- def mixed_list_rendering_test_method; end
90
-
91
- # 1. Also in reverse
92
- # 2. Second item
93
- # * Nested bulleted list
94
- def second_mixed_list_rendering_test_method; end
95
-
96
- # [First] And this is the list item body
97
- # With a second line containing more text
98
- #
99
- # [Second] Another labled list item
100
- def labeled_list_rendering_test_method; end
101
-
102
- # First:: With some text.
103
- # Secondarily:: Lets see if this lines up.
104
- def lined_up_labeled_list_rendering_test_method; end
105
-
106
- # * a list item
107
- # with a long item text
108
- # Containing verbatim text
109
- def list_containing_verbatim_text_rendering_test_method; end
110
-
111
- # Text with stylings: *bold*, _emphasized_ and +monospaced+.
112
- def simple_styling_rendering_test_method; end
113
-
114
- # Also with html: <b>Bold</b>, <em>emphasized</em>, <i>also emphasized</i>
115
- # and <tt>monospaced tt</tt> or <code>monospaced code</code>.
116
- def html_styling_rendering_test_method; end
117
-
118
- # These should not be styled: \<b>Not bold\</b>, \<em>not emphasized\</em>.
119
- def escaped_styling_rendering_test_method; end
120
-
121
- # Furthermore, this text contains links to raw links http://www.google.com mailto:spamidyspam@spam.com ftp://warez.teuto.de and plain web links: www.test.com .
122
- #
123
- # Then we have local links to other files: link:/etc/fstab
124
- def raw_link_rendering_test_method; end
125
-
126
- # Plus: Labled links SingleWordLabel[http://duckduckgo.com] and
127
- # {Multi Word Labels}[http://www.github.com].
128
- def labeled_link_rendering_test_method; end
129
-
130
- # Conversion characters: this: -- or --- should be an em-dash. We also have an ellipsis: ... . Copyright: (c) and registered trademark (r).
131
- def conversion_character_rendering_test_method; end
132
- end
@@ -1,38 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bri::Mall do
4
- # NOTE the specs here are commented out until I figure out how to properly
5
- # test singletons. Otherwise specs will fail in a bulk run while
6
- # running fine on their own
7
- subject { Bri::Mall.instance }
8
-
9
- before( :each ) do
10
- RDoc::RI::Paths.stub!( :each ).
11
- and_yield( "store1_path", "store1_type" ).
12
- and_yield( "store2_path", "store2_type" )
13
- RDoc::RI::Store.stub!( :new ).
14
- and_return { mock( RDoc::RI::Store, :load_cache=> true ) }
15
- end
16
-
17
- # describe "the instance" do
18
-
19
- # its( :stores ) { should have(2).objects }
20
- # end
21
-
22
- # describe "#classes" do
23
- # it "should query all stores for their modules" do
24
- # subject.stores.each do |store|
25
- # store.should_receive( :modules ).and_return( true )
26
- # end
27
-
28
- # subject.classes
29
- # end
30
-
31
- # it "should return a sorted array of unique class names" do
32
- # subject.stores.first.stub!( :modules => [ "C", "B", "A" ] )
33
- # subject.stores.last.stub!( :modules => [ "Z", "B", "C" ] )
34
- # subject.classes.should == [ "A", "B", "C", "Z" ]
35
- # end
36
- # end
37
-
38
- end
@@ -1,125 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bri::Match::Class do
4
- let( :fully_developed_class ) do
5
- search_instance = Bri::Search::Class.new( "BriDummySpecClassTwo" )
6
- search_instance.search
7
- search_instance.matches.first
8
- end
9
-
10
- let( :empty_class ) do
11
- search_instance = Bri::Search::Class.new( "BriDummySpecClassEmpty" )
12
- search_instance.search
13
- search_instance.matches.first
14
- end
15
-
16
- let( :empty_module ) do
17
- search_instance = Bri::Search::Class.new( "BriDummySpecModule" )
18
- search_instance.search
19
- search_instance.matches.first
20
- end
21
-
22
- let( :namespaced_class ) do
23
- search_instance = Bri::Search::Class.new( "BriDummySpec::Class" )
24
- search_instance.search
25
- search_instance.matches.first
26
- end
27
-
28
- describe "#type" do
29
- it "should be class for a class" do
30
- empty_class.type.should == "class"
31
- end
32
-
33
- it "should be module for a module" do
34
- empty_module.type.should == "module"
35
- end
36
- end
37
-
38
- describe "#name" do
39
- it "should contain the name of a class" do
40
- empty_class.name.should == "BriDummySpecClassEmpty < Object"
41
- end
42
-
43
- it "should contain the fully qualified name of a namespaced class" do
44
- namespaced_class.name.should == "BriDummySpec::Class < Object"
45
- end
46
- end
47
-
48
- describe "#description_paragraphs" do
49
- it "should be empty for an undocumented class" do
50
- empty_class.description_paragraphs.should == []
51
- end
52
-
53
- it "should contain rendered text for a documented class" do
54
- fully_developed_class.description_paragraphs.size.should == 1
55
- fully_developed_class.description_paragraphs.first.should =~ /This is a class description/
56
- end
57
- end
58
-
59
- describe "#includes" do
60
- it "should be empty for a class without includes" do
61
- empty_class.includes.should be_empty
62
- end
63
-
64
- it "should contain a list of includes for classes with includes" do
65
- fully_developed_class.includes.size.should == 1
66
- fully_developed_class.includes.should include( "BriDummySpecModule" )
67
- end
68
- end
69
-
70
- describe "#constants" do
71
- it "should be empty for a class without constants" do
72
- empty_class.constants.should be_empty
73
- end
74
-
75
- it "should contain a list of constants for classes with constants" do
76
- fully_developed_class.constants.size.should == 2
77
- fully_developed_class.constants.should include( "CONSTANT" )
78
- fully_developed_class.constants.should include( "OTHER_CONSTANT" )
79
- end
80
- end
81
-
82
- describe "#attributes" do
83
- it "should be empty for a class without attributes" do
84
- empty_class.attributes.should be_empty
85
- end
86
-
87
- it "should contain a list of attributes for classes with attr_* declarations" do
88
- fully_developed_class.attributes.should_not be_empty
89
- end
90
-
91
- it "should mark attr_readers as read only" do
92
- fully_developed_class.attributes.should include( "read_attr (R)" )
93
- end
94
-
95
- it "should mark attr_writers as write only" do
96
- fully_developed_class.attributes.should include( "write_attr (W)" )
97
- end
98
-
99
- it "should mark attr_accessors as read/writeable" do
100
- fully_developed_class.attributes.should include( "access_attr (RW)" )
101
- end
102
- end
103
-
104
- describe "#class_methods" do
105
- it "should be empty for a class without class methods" do
106
- empty_class.class_methods.should be_empty
107
- end
108
-
109
- it "should contain class methods for classes with class methods" do
110
- fully_developed_class.class_methods.size.should == 1
111
- fully_developed_class.class_methods.first.should == "bri_dummy_spec_second_singleton_method"
112
- end
113
- end
114
-
115
- describe "#instance_methods" do
116
- it "should be empty for a class without instance methods" do
117
- empty_class.instance_methods.should be_empty
118
- end
119
-
120
- it "should contain class methods for classes with class methods" do
121
- fully_developed_class.instance_methods.size.should == 1
122
- fully_developed_class.instance_methods.first.should == "bri_dummy_spec_instance_method_with_arguments"
123
- end
124
- end
125
- end
@@ -1,116 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bri::Match::Method do
4
- let( :fake_paragraph ) do
5
- RDoc::Markup::Paragraph.new "This is line one", "This is line two"
6
- end
7
-
8
- let( :fake_description ) do
9
- double( RDoc::Markup::Document, :parts => [ fake_paragraph ] )
10
- end
11
-
12
- let( :fake_comment ) do
13
- double( RDoc::Comment, :instance_variable_get => fake_description )
14
- end
15
-
16
- let( :rdoc_method ) do
17
- double( RDoc::AnyMethod, :full_name => "This::IS::My.full_name",
18
- :arglists => "First\nSecond\nThird",
19
- :comment => fake_comment )
20
- end
21
-
22
- describe "#initialize" do
23
- subject { Bri::Match::Method.new( rdoc_method ) }
24
-
25
- its( :full_name ) { should == rdoc_method.full_name }
26
- its( :call_syntaxes ) { should == " First\n Second\n Third\n" }
27
- its( :description_paragraphs ) { should == [ " This is line one This is line two" ] }
28
- end
29
-
30
- describe "#full_name" do
31
- subject do
32
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method" )
33
- search_instance.search( :fully_qualified )
34
- search_instance.matches.first
35
- end
36
-
37
- its( :full_name ) { should == "BriDummySpecClass#bri_dummy_spec_instance_method" }
38
- end
39
-
40
- describe "#call_syntaxes" do
41
- context "for methods with no arguments" do
42
- subject do
43
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method" )
44
- search_instance.search( :fully_qualified )
45
- search_instance.matches.first
46
- end
47
-
48
- its( :call_syntaxes ) { should == " bri_dummy_spec_instance_method()\n" }
49
- end
50
-
51
- context "for methods with arguments" do
52
- subject do
53
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method_with_arguments" )
54
- search_instance.search( :fully_qualified )
55
- search_instance.matches.first
56
- end
57
-
58
- its( :call_syntaxes ) { should == " bri_dummy_spec_instance_method_with_arguments( a, b )\n" }
59
- end
60
-
61
- context "for methods with default arguments" do
62
- subject do
63
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method_with_default_arguments" )
64
- search_instance.search( :fully_qualified )
65
- search_instance.matches.first
66
- end
67
-
68
- its( :call_syntaxes ) { should == " bri_dummy_spec_instance_method_with_default_arguments( a, b, c = nil )\n" }
69
- end
70
-
71
- context "for methods that yield" do
72
- subject do
73
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method_which_yields" )
74
- search_instance.search( :fully_qualified )
75
- search_instance.matches.first
76
- end
77
-
78
- its( :call_syntaxes ) { should == " bri_dummy_spec_instance_method_which_yields() { |yield_param_one, yield_param_two| ... }\n" }
79
- end
80
-
81
- context "for methods with an rdoc yield override" do
82
- subject do
83
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method_with_yield_override" )
84
- search_instance.search( :fully_qualified )
85
- search_instance.matches.first
86
- end
87
-
88
- its( :call_syntaxes ) { should == " bri_dummy_spec_instance_method_with_yield_override() { |foo, bar| ... }\n" }
89
- end
90
- end
91
-
92
- describe "#description_paragraphs" do
93
- context "for an undocumented method" do
94
- subject do
95
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#bri_dummy_spec_instance_method" )
96
- search_instance.search( :fully_qualified )
97
- search_instance.matches.first
98
- end
99
-
100
- its( :description_paragraphs ) { should == [] }
101
- end
102
-
103
- context "for a documented method" do
104
- subject do
105
- search_instance = Bri::Search::InstanceMethod.new( "BriDummySpecClass#basic_headline_and_paragraph_rendering_test_method" )
106
- search_instance.search( :fully_qualified )
107
- search_instance.matches.first
108
- end
109
-
110
- its( :description_paragraphs ) { should_not be_empty }
111
- it "should contain rendered paragraphs as the array elements" do
112
- subject.description_paragraphs.first.should =~ /This is a headline/
113
- end
114
- end
115
- end
116
- end
@@ -1,70 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Bri::Matcher do
4
- describe "#type" do
5
-
6
- context "the query term begins with a capital" do
7
- subject { Bri::Matcher.new( "Foo" ) }
8
- its( :type ) { should == :fully_qualified }
9
- end
10
-
11
- context "the query term begins with a lower case letter" do
12
- subject { Bri::Matcher.new( "foo" ) }
13
- its( :type ) { should == :unqualified }
14
- end
15
-
16
- context "the query term begins with a _" do
17
- subject { Bri::Matcher.new( "_foo" ) }
18
- its( :type ) { should == :unqualified }
19
- end
20
-
21
- context "the query begins with a ." do
22
- subject { Bri::Matcher.new( ".foo" ) }
23
- its( :type ) { should == :partially_qualified }
24
- end
25
-
26
- context "the query begins with a #" do
27
- subject { Bri::Matcher.new( "#foo" ) }
28
- its( :type ) { should == :partially_qualified }
29
- end
30
-
31
- context "it begins with a character other than _, ., #, or a letter" do
32
- subject { Bri::Matcher.new( "2134" ) }
33
- its( :type ) { should == :error }
34
- end
35
- end
36
-
37
- describe "#subject" do
38
- context "the term begins with a capital letter" do
39
- context "and the term contains a ." do
40
- subject { Bri::Matcher.new( "Foo.bar" ) }
41
- its( :subject ) { should == :class_method }
42
- end
43
-
44
- context "and the term contains a #" do
45
- subject { Bri::Matcher.new( "Foo#bar" ) }
46
- its( :subject ) { should == :instance_method }
47
- end
48
-
49
- context "and the term contains neither . nor #" do
50
- subject { Bri::Matcher.new( "FooBar" ) }
51
- its( :subject ) { should == :module }
52
- end
53
- end
54
- end
55
-
56
- context "the term begins with a ." do
57
- subject { Bri::Matcher.new( ".foo" ) }
58
- its( :subject ) { should == :class_method }
59
- end
60
-
61
- context "the term begins with a #" do
62
- subject { Bri::Matcher.new( "#foo" ) }
63
- its( :subject ) { should == :instance_method }
64
- end
65
-
66
- context "the term begins with neither a capital letter nor . or #" do
67
- subject { Bri::Matcher.new( "foo" ) }
68
- its( :subject ) { should == :method }
69
- end
70
- end