bri 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog +16 -0
- data/TODO +0 -1
- data/lib/bri/renderer.rb +28 -22
- data/lib/bri/templates.rb +8 -3
- metadata +4 -3
data/Changelog
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
0.1.4
|
2
|
+
- Better rendering of list items
|
3
|
+
- Bulleted Lists now have bullets in front of the list items
|
4
|
+
- Numbered Lists now have numbers in front of the list items
|
5
|
+
- Fix off-by-one bug in hrule output
|
6
|
+
|
7
|
+
0.1.3
|
8
|
+
- New line wrapping algorithm
|
9
|
+
- Colorize <tt>, <code>, headers, +foo+ and _bar_
|
10
|
+
- Use arglists instead of callseq to show method signature in output since
|
11
|
+
callseq can be empty at times
|
12
|
+
|
13
|
+
0.1.2
|
14
|
+
- Add --list-methods
|
15
|
+
- Add --list-names
|
16
|
+
- Add -w/--width and width evaluation from the COLUMNS environment variable
|
data/TODO
CHANGED
data/lib/bri/renderer.rb
CHANGED
@@ -8,12 +8,32 @@ module Bri
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def render( element, width = Bri.width )
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
case element
|
12
|
+
when RDoc::Markup::Verbatim
|
13
|
+
text = extract_text( element, width )
|
14
|
+
styled_text = replace_markup( text )
|
15
|
+
indent( styled_text )
|
16
|
+
|
17
|
+
when RDoc::Markup::List
|
18
|
+
item_width = width - INDENT.length
|
19
|
+
rendered_items = element.items.collect { |item| render item, item_width }
|
20
|
+
rendered_items.map! { |item| item.gsub( /\n/, "\n#{INDENT}" ) }
|
21
|
+
case element.type
|
22
|
+
when :BULLET
|
23
|
+
rendered_items.map! { |item| ' *' + item }
|
24
|
+
when :NUMBER
|
25
|
+
i = 0
|
26
|
+
rendered_items.map! { |item| i+=1; sprintf "%d.%s", i, item }
|
27
|
+
end
|
28
|
+
|
29
|
+
rendered_items.join( "\n\n" ) + "\n"
|
30
|
+
|
31
|
+
else
|
32
|
+
text = extract_text( element, width )
|
33
|
+
styled_text = replace_markup( text )
|
34
|
+
wrapped_text = wrap_to_width( styled_text, width )
|
35
|
+
indent( wrapped_text )
|
36
|
+
end
|
17
37
|
end
|
18
38
|
|
19
39
|
def extract_text( element, width )
|
@@ -27,18 +47,9 @@ module Bri
|
|
27
47
|
when RDoc::Markup::Verbatim
|
28
48
|
element.text
|
29
49
|
when RDoc::Markup::Heading
|
30
|
-
"<h>#{element.text}</h>"
|
50
|
+
"<h>#{element.text}</h>"
|
31
51
|
when RDoc::Markup::ListItem
|
32
52
|
element.label.to_s + element.parts.collect { |part| extract_text part, width }.join
|
33
|
-
when RDoc::Markup::List
|
34
|
-
prefix = case element.type
|
35
|
-
when :NOTE, :LABEL then "Note:\n"
|
36
|
-
when :NUMBER then "Numbered List:\n"
|
37
|
-
when :BULLET then "Bulletet List:\n"
|
38
|
-
else
|
39
|
-
raise "Don't know how to handle list type #{element.type}: #{element.inspect}"
|
40
|
-
end
|
41
|
-
prefix + element.items.collect { |item| extract_text item, width }.join
|
42
53
|
else
|
43
54
|
raise "Don't know how to handle type #{element.class}: #{element.inspect}"
|
44
55
|
end
|
@@ -63,12 +74,7 @@ module Bri
|
|
63
74
|
end
|
64
75
|
|
65
76
|
def printable_length( text )
|
66
|
-
|
67
|
-
if embedded_ansi_codes.empty?
|
68
|
-
text.length
|
69
|
-
else
|
70
|
-
text.length - embedded_ansi_codes.reduce( 0 ) { |total, code| code.length + total }
|
71
|
-
end
|
77
|
+
Term::ANSIColor.uncolored( text ).length
|
72
78
|
end
|
73
79
|
|
74
80
|
def wrap_to_width( styled_text, width )
|
data/lib/bri/templates.rb
CHANGED
@@ -64,9 +64,14 @@ module Bri
|
|
64
64
|
|
65
65
|
module Helpers
|
66
66
|
def hrule( text = '', width = Bri.width )
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
if text == ''
|
68
|
+
'-' * width + "\n"
|
69
|
+
else
|
70
|
+
text = " " + text if text != ''
|
71
|
+
'-' * ( width - text.length ) +
|
72
|
+
Term::ANSIColor::bold + text + Term::ANSIColor::reset +
|
73
|
+
"\n"
|
74
|
+
end
|
70
75
|
end
|
71
76
|
module_function :hrule
|
72
77
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sven Riedel
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-10-06 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -58,6 +58,7 @@ extra_rdoc_files:
|
|
58
58
|
files:
|
59
59
|
- README
|
60
60
|
- TODO
|
61
|
+
- Changelog
|
61
62
|
- bin/bri
|
62
63
|
- lib/bri.rb
|
63
64
|
- lib/bri/mall.rb
|