rdoc 2.5.11 → 3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.document +1 -0
- data/History.txt +95 -0
- data/Manifest.txt +13 -4
- data/README.txt +9 -3
- data/Rakefile +1 -1
- data/lib/rdoc.rb +15 -298
- data/lib/rdoc/alias.rb +65 -16
- data/lib/rdoc/any_method.rb +27 -150
- data/lib/rdoc/attr.rb +36 -115
- data/lib/rdoc/class_module.rb +236 -22
- data/lib/rdoc/code_object.rb +76 -31
- data/lib/rdoc/constant.rb +32 -4
- data/lib/rdoc/context.rb +494 -222
- data/lib/rdoc/encoding.rb +79 -0
- data/lib/rdoc/erbio.rb +37 -0
- data/lib/rdoc/gauntlet.rb +9 -5
- data/lib/rdoc/generator.rb +33 -1
- data/lib/rdoc/generator/darkfish.rb +284 -375
- data/lib/rdoc/generator/markup.rb +72 -36
- data/lib/rdoc/generator/ri.rb +4 -4
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +267 -274
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +91 -91
- data/lib/rdoc/generator/template/darkfish/index.rhtml +45 -45
- data/lib/rdoc/generator/template/darkfish/rdoc.css +298 -298
- data/lib/rdoc/include.rb +40 -1
- data/lib/rdoc/known_classes.rb +1 -0
- data/lib/rdoc/markup.rb +467 -2
- data/lib/rdoc/markup/attribute_manager.rb +24 -6
- data/lib/rdoc/markup/blank_line.rb +11 -3
- data/lib/rdoc/markup/document.rb +6 -0
- data/lib/rdoc/markup/formatter.rb +10 -0
- data/lib/rdoc/markup/formatter_test_case.rb +339 -3
- data/lib/rdoc/markup/heading.rb +3 -0
- data/lib/rdoc/markup/inline.rb +11 -1
- data/lib/rdoc/markup/list.rb +3 -0
- data/lib/rdoc/markup/list_item.rb +3 -0
- data/lib/rdoc/markup/paragraph.rb +3 -0
- data/lib/rdoc/markup/parser.rb +191 -237
- data/lib/rdoc/markup/{preprocess.rb → pre_process.rb} +50 -29
- data/lib/rdoc/markup/raw.rb +4 -0
- data/lib/rdoc/markup/rule.rb +3 -0
- data/lib/rdoc/markup/text_formatter_test_case.rb +116 -0
- data/lib/rdoc/markup/to_ansi.rb +14 -2
- data/lib/rdoc/markup/to_bs.rb +8 -2
- data/lib/rdoc/markup/to_html.rb +84 -91
- data/lib/rdoc/markup/to_html_crossref.rb +77 -26
- data/lib/rdoc/markup/to_rdoc.rb +94 -49
- data/lib/rdoc/markup/to_test.rb +9 -1
- data/lib/rdoc/markup/verbatim.rb +6 -3
- data/lib/rdoc/method_attr.rb +353 -0
- data/lib/rdoc/normal_class.rb +11 -2
- data/lib/rdoc/normal_module.rb +0 -5
- data/lib/rdoc/options.rb +373 -82
- data/lib/rdoc/parser.rb +59 -23
- data/lib/rdoc/parser/c.rb +224 -86
- data/lib/rdoc/parser/ruby.rb +219 -111
- data/lib/rdoc/parser/ruby_tools.rb +4 -1
- data/lib/rdoc/parser/simple.rb +9 -4
- data/lib/rdoc/rdoc.rb +68 -28
- data/lib/rdoc/require.rb +21 -0
- data/lib/rdoc/ri/driver.rb +20 -10
- data/lib/rdoc/ri/paths.rb +2 -2
- data/lib/rdoc/ri/store.rb +22 -5
- data/lib/rdoc/ruby_lex.rb +11 -12
- data/lib/rdoc/ruby_token.rb +2 -2
- data/lib/rdoc/single_class.rb +2 -1
- data/lib/rdoc/stats.rb +202 -162
- data/lib/rdoc/stats/normal.rb +51 -0
- data/lib/rdoc/stats/quiet.rb +59 -0
- data/lib/rdoc/stats/verbose.rb +45 -0
- data/lib/rdoc/text.rb +133 -4
- data/lib/rdoc/{tokenstream.rb → token_stream.rb} +0 -2
- data/lib/rdoc/top_level.rb +230 -39
- data/test/test_attribute_manager.rb +58 -7
- data/test/test_rdoc_alias.rb +13 -0
- data/test/test_rdoc_any_method.rb +43 -2
- data/test/test_rdoc_attr.rb +15 -8
- data/test/test_rdoc_class_module.rb +133 -0
- data/test/test_rdoc_code_object.rb +62 -5
- data/test/test_rdoc_context.rb +72 -26
- data/test/test_rdoc_encoding.rb +145 -0
- data/test/test_rdoc_generator_darkfish.rb +119 -0
- data/test/test_rdoc_generator_ri.rb +22 -2
- data/test/test_rdoc_include.rb +79 -0
- data/test/test_rdoc_markup_attribute_manager.rb +4 -4
- data/test/test_rdoc_markup_parser.rb +134 -95
- data/test/test_rdoc_markup_pre_process.rb +7 -2
- data/test/test_rdoc_markup_to_ansi.rb +43 -153
- data/test/test_rdoc_markup_to_bs.rb +42 -156
- data/test/test_rdoc_markup_to_html.rb +130 -58
- data/test/test_rdoc_markup_to_html_crossref.rb +10 -10
- data/test/test_rdoc_markup_to_rdoc.rb +40 -151
- data/test/test_rdoc_method_attr.rb +122 -0
- data/test/test_rdoc_normal_class.rb +1 -1
- data/test/test_rdoc_normal_module.rb +6 -1
- data/test/test_rdoc_options.rb +237 -12
- data/test/test_rdoc_parser.rb +3 -22
- data/test/test_rdoc_parser_c.rb +203 -2
- data/test/test_rdoc_parser_ruby.rb +403 -89
- data/test/test_rdoc_parser_simple.rb +25 -1
- data/test/test_rdoc_rdoc.rb +44 -32
- data/test/test_rdoc_ri_driver.rb +29 -24
- data/test/test_rdoc_ri_store.rb +46 -3
- data/test/test_rdoc_task.rb +1 -1
- data/test/test_rdoc_text.rb +102 -8
- data/test/test_rdoc_top_level.rb +13 -4
- data/test/xref_data.rb +8 -0
- data/test/xref_test_case.rb +6 -0
- metadata +29 -19
- metadata.gz.sig +0 -0
- data/lib/rdoc/parser/perl.rb +0 -165
- data/test/test_rdoc_parser_perl.rb +0 -73
@@ -9,10 +9,10 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
9
9
|
##
|
10
10
|
# Regular expression to match class references
|
11
11
|
#
|
12
|
-
# 1
|
13
|
-
# 2
|
12
|
+
# 1. There can be a '\\' in front of text to suppress the cross-reference
|
13
|
+
# 2. There can be a '::' in front of class names to reference from the
|
14
14
|
# top-level namespace.
|
15
|
-
# 3
|
15
|
+
# 3. The method can be followed by parenthesis (not recommended)
|
16
16
|
|
17
17
|
CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)'
|
18
18
|
|
@@ -34,10 +34,10 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
34
34
|
# A::B::C.meth
|
35
35
|
#{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
|
36
36
|
|
37
|
-
# Stand-alone method (
|
37
|
+
# Stand-alone method (preceeded by a #)
|
38
38
|
| \\?\##{METHOD_REGEXP_STR}
|
39
39
|
|
40
|
-
# Stand-alone method (
|
40
|
+
# Stand-alone method (preceeded by ::)
|
41
41
|
| ::#{METHOD_REGEXP_STR}
|
42
42
|
|
43
43
|
# A::B::C
|
@@ -51,9 +51,10 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
51
51
|
# In order that words like "can't" not
|
52
52
|
# be flagged as potential cross-references, only
|
53
53
|
# flag potential class cross-references if the character
|
54
|
-
# after the cross-referece is a space
|
55
|
-
# punctuation
|
56
|
-
|
54
|
+
# after the cross-referece is a space, sentence
|
55
|
+
# punctuation, tag start character, or attribute
|
56
|
+
# marker.
|
57
|
+
| #{CLASS_REGEXP_STR}(?=[\s\)\.\?\!\,\;<\000]|\z)
|
57
58
|
|
58
59
|
# Things that look like filenames
|
59
60
|
# The key thing is that there must be at least
|
@@ -62,7 +63,29 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
62
63
|
| (?:\.\.\/)*[-\/\w]+[_\/\.][-\w\/\.]+
|
63
64
|
|
64
65
|
# Things that have markup suppressed
|
65
|
-
|
66
|
+
# Don't process things like '\<' in \<tt>, though.
|
67
|
+
# TODO: including < is a hack, not very satisfying.
|
68
|
+
| \\[^\s<]
|
69
|
+
)/x
|
70
|
+
|
71
|
+
##
|
72
|
+
# Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
|
73
|
+
|
74
|
+
ALL_CROSSREF_REGEXP = /(
|
75
|
+
# A::B::C.meth
|
76
|
+
#{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
|
77
|
+
|
78
|
+
# Stand-alone method
|
79
|
+
| \\?#{METHOD_REGEXP_STR}
|
80
|
+
|
81
|
+
# A::B::C
|
82
|
+
| #{CLASS_REGEXP_STR}(?=[\s\)\.\?\!\,\;<\000]|\z)
|
83
|
+
|
84
|
+
# Things that look like filenames
|
85
|
+
| (?:\.\.\/)*[-\/\w]+[_\/\.][-\w\/\.]+
|
86
|
+
|
87
|
+
# Things that have markup suppressed
|
88
|
+
| \\[^\s<]
|
66
89
|
)/x
|
67
90
|
|
68
91
|
##
|
@@ -78,17 +101,21 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
78
101
|
##
|
79
102
|
# Creates a new crossref resolver that generates links relative to +context+
|
80
103
|
# which lives at +from_path+ in the generated files. '#' characters on
|
81
|
-
# references are removed unless +show_hash+ is true.
|
104
|
+
# references are removed unless +show_hash+ is true. Only method names
|
105
|
+
# preceded by '#' or '::' are hyperlinked, unless +hyperlink_all+ is true.
|
82
106
|
|
83
|
-
def initialize(from_path, context, show_hash)
|
107
|
+
def initialize(from_path, context, show_hash, hyperlink_all = false)
|
84
108
|
raise ArgumentError, 'from_path cannot be nil' if from_path.nil?
|
85
109
|
super()
|
86
110
|
|
87
|
-
|
111
|
+
crossref_re = hyperlink_all ? ALL_CROSSREF_REGEXP : CROSSREF_REGEXP
|
112
|
+
|
113
|
+
@markup.add_special crossref_re, :CROSSREF
|
88
114
|
|
89
115
|
@from_path = from_path
|
90
116
|
@context = context
|
91
117
|
@show_hash = show_hash
|
118
|
+
@hyperlink_all = hyperlink_all
|
92
119
|
|
93
120
|
@seen = {}
|
94
121
|
end
|
@@ -97,18 +124,21 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
97
124
|
# We're invoked when any text matches the CROSSREF pattern. If we find the
|
98
125
|
# corresponding reference, generate a hyperlink. If the name we're looking
|
99
126
|
# for contains no punctuation, we look for it up the module/class chain.
|
100
|
-
# For example,
|
101
|
-
# because we look for it in module
|
127
|
+
# For example, ToHtml is found, even without the <tt>RDoc::Markup::</tt>
|
128
|
+
# prefix, because we look for it in module Markup first.
|
102
129
|
|
103
130
|
def handle_special_CROSSREF(special)
|
104
131
|
name = special.text
|
105
132
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
133
|
+
unless @hyperlink_all then
|
134
|
+
# This ensures that words entirely consisting of lowercase letters will
|
135
|
+
# not have cross-references generated (to suppress lots of erroneous
|
136
|
+
# cross-references to "new" in text, for instance)
|
137
|
+
return name if name =~ /\A[a-z]*\z/
|
138
|
+
end
|
110
139
|
|
111
140
|
return @seen[name] if @seen.include? name
|
141
|
+
|
112
142
|
lookup = name
|
113
143
|
|
114
144
|
name = name[1..-1] unless @show_hash if name[0, 1] == '#'
|
@@ -124,26 +154,47 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
124
154
|
# whether the string as a whole is a known symbol).
|
125
155
|
|
126
156
|
if /#{CLASS_REGEXP_STR}([.#]|::)#{METHOD_REGEXP_STR}/ =~ lookup then
|
127
|
-
container = $1
|
128
157
|
type = $2
|
129
|
-
type = '
|
158
|
+
type = '' if type == '.' # will find either #method or ::method
|
130
159
|
method = "#{type}#{$3}"
|
131
|
-
|
160
|
+
container = @context.find_symbol_module($1)
|
161
|
+
elsif /^([.#]|::)#{METHOD_REGEXP_STR}/ =~ lookup then
|
162
|
+
type = $1
|
163
|
+
type = '' if type == '.'
|
164
|
+
method = "#{type}#{$2}"
|
165
|
+
container = @context
|
166
|
+
else
|
167
|
+
container = nil
|
168
|
+
end
|
169
|
+
|
170
|
+
if container then
|
171
|
+
ref = container.find_local_symbol method
|
172
|
+
|
173
|
+
unless ref || RDoc::TopLevel === container then
|
174
|
+
ref = container.find_ancestor_local_symbol method
|
175
|
+
end
|
132
176
|
end
|
133
177
|
|
134
178
|
ref = @context.find_symbol lookup unless ref
|
179
|
+
ref = nil if RDoc::Alias === ref # external alias: can't link to it
|
135
180
|
|
136
181
|
out = if lookup == '\\' then
|
137
182
|
lookup
|
138
183
|
elsif lookup =~ /^\\/ then
|
139
|
-
|
140
|
-
|
141
|
-
|
184
|
+
# we remove the \ only in front of what we know:
|
185
|
+
# other backslashes are treated later, only outside of <tt>
|
186
|
+
ref ? $' : lookup
|
187
|
+
elsif ref then
|
188
|
+
if ref.document_self then
|
189
|
+
"<a href=\"#{ref.as_href @from_path}\">#{name}</a>"
|
190
|
+
else
|
191
|
+
name
|
192
|
+
end
|
142
193
|
else
|
143
|
-
|
194
|
+
lookup
|
144
195
|
end
|
145
196
|
|
146
|
-
@seen[
|
197
|
+
@seen[lookup] = out
|
147
198
|
|
148
199
|
out
|
149
200
|
end
|
data/lib/rdoc/markup/to_rdoc.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rdoc/markup/formatter'
|
1
2
|
require 'rdoc/markup/inline'
|
2
3
|
|
3
4
|
##
|
@@ -5,21 +6,49 @@ require 'rdoc/markup/inline'
|
|
5
6
|
|
6
7
|
class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
7
8
|
|
9
|
+
##
|
10
|
+
# Current indent amount for output in characters
|
11
|
+
|
8
12
|
attr_accessor :indent
|
13
|
+
|
14
|
+
##
|
15
|
+
# Output width in characters
|
16
|
+
|
17
|
+
attr_accessor :width
|
18
|
+
|
19
|
+
##
|
20
|
+
# Stack of current list indexes for alphabetic and numeric lists
|
21
|
+
|
9
22
|
attr_reader :list_index
|
23
|
+
|
24
|
+
##
|
25
|
+
# Stack of list types
|
26
|
+
|
10
27
|
attr_reader :list_type
|
28
|
+
|
29
|
+
##
|
30
|
+
# Stack of list widths for indentation
|
31
|
+
|
11
32
|
attr_reader :list_width
|
33
|
+
|
34
|
+
##
|
35
|
+
# Prefix for the next list item. See #use_prefix
|
36
|
+
|
12
37
|
attr_reader :prefix
|
38
|
+
|
39
|
+
##
|
40
|
+
# Output accumulator
|
41
|
+
|
13
42
|
attr_reader :res
|
14
43
|
|
44
|
+
##
|
45
|
+
# Creates a new formatter that will output (mostly) \RDoc markup
|
46
|
+
|
15
47
|
def initialize
|
16
48
|
super
|
17
49
|
|
18
|
-
@markup.add_special(
|
19
|
-
|
50
|
+
@markup.add_special(/\\\S/, :SUPPRESSED_CROSSREF)
|
20
51
|
@width = 78
|
21
|
-
@prefix = ''
|
22
|
-
|
23
52
|
init_tags
|
24
53
|
|
25
54
|
@headings = {}
|
@@ -34,7 +63,7 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
34
63
|
end
|
35
64
|
|
36
65
|
##
|
37
|
-
# Maps attributes to
|
66
|
+
# Maps attributes to HTML sequences
|
38
67
|
|
39
68
|
def init_tags
|
40
69
|
add_tag :BOLD, "<b>", "</b>"
|
@@ -42,10 +71,16 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
42
71
|
add_tag :EM, "<em>", "</em>"
|
43
72
|
end
|
44
73
|
|
74
|
+
##
|
75
|
+
# Adds +blank_line+ to the output
|
76
|
+
|
45
77
|
def accept_blank_line blank_line
|
46
78
|
@res << "\n"
|
47
79
|
end
|
48
80
|
|
81
|
+
##
|
82
|
+
# Adds +heading+ to the output
|
83
|
+
|
49
84
|
def accept_heading heading
|
50
85
|
use_prefix or @res << ' ' * @indent
|
51
86
|
@res << @headings[heading.level][0]
|
@@ -54,12 +89,18 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
54
89
|
@res << "\n"
|
55
90
|
end
|
56
91
|
|
92
|
+
##
|
93
|
+
# Finishes consumption of +list+
|
94
|
+
|
57
95
|
def accept_list_end list
|
58
96
|
@list_index.pop
|
59
97
|
@list_type.pop
|
60
98
|
@list_width.pop
|
61
99
|
end
|
62
100
|
|
101
|
+
##
|
102
|
+
# Finishes consumption of +list_item+
|
103
|
+
|
63
104
|
def accept_list_item_end list_item
|
64
105
|
width = case @list_type.last
|
65
106
|
when :BULLET then
|
@@ -76,29 +117,29 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
76
117
|
@indent -= width
|
77
118
|
end
|
78
119
|
|
120
|
+
##
|
121
|
+
# Prepares the visitor for consuming +list_item+
|
122
|
+
|
79
123
|
def accept_list_item_start list_item
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
when :NOTE, :LABEL then
|
84
|
-
attributes(list_item.label) + ":\n"
|
85
|
-
else
|
86
|
-
@list_index.last.to_s + '.'
|
87
|
-
end
|
88
|
-
|
89
|
-
case @list_type.last
|
124
|
+
type = @list_type.last
|
125
|
+
|
126
|
+
case type
|
90
127
|
when :NOTE, :LABEL then
|
128
|
+
bullet = attributes(list_item.label) + ":\n"
|
129
|
+
@prefix = ' ' * @indent
|
91
130
|
@indent += 2
|
92
|
-
@prefix
|
131
|
+
@prefix << bullet + (' ' * @indent)
|
93
132
|
else
|
133
|
+
bullet = type == :BULLET ? '*' : @list_index.last.to_s + '.'
|
94
134
|
@prefix = (' ' * @indent) + bullet.ljust(bullet.length + 1)
|
95
|
-
|
96
135
|
width = bullet.length + 1
|
97
|
-
|
98
136
|
@indent += width
|
99
137
|
end
|
100
138
|
end
|
101
139
|
|
140
|
+
##
|
141
|
+
# Prepares the visitor for consuming +list+
|
142
|
+
|
102
143
|
def accept_list_start list
|
103
144
|
case list.type
|
104
145
|
when :BULLET then
|
@@ -123,14 +164,23 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
123
164
|
@list_type << list.type
|
124
165
|
end
|
125
166
|
|
167
|
+
##
|
168
|
+
# Adds +paragraph+ to the output
|
169
|
+
|
126
170
|
def accept_paragraph paragraph
|
127
171
|
wrap attributes(paragraph.text)
|
128
172
|
end
|
129
173
|
|
174
|
+
##
|
175
|
+
# Adds +raw+ to the output
|
176
|
+
|
130
177
|
def accept_raw raw
|
131
178
|
@res << raw.parts.join("\n")
|
132
179
|
end
|
133
180
|
|
181
|
+
##
|
182
|
+
# Adds +rule+ to the output
|
183
|
+
|
134
184
|
def accept_rule rule
|
135
185
|
use_prefix or @res << ' ' * @indent
|
136
186
|
@res << '-' * (@width - @indent)
|
@@ -138,58 +188,46 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
138
188
|
end
|
139
189
|
|
140
190
|
##
|
141
|
-
# Outputs +verbatim+
|
191
|
+
# Outputs +verbatim+ indented 2 columns
|
142
192
|
|
143
193
|
def accept_verbatim verbatim
|
144
194
|
indent = ' ' * (@indent + 2)
|
145
195
|
|
146
|
-
lines = []
|
147
|
-
current_line = []
|
148
|
-
|
149
|
-
# split into lines
|
150
196
|
verbatim.parts.each do |part|
|
151
|
-
|
152
|
-
|
153
|
-
if part == "\n" then
|
154
|
-
lines << current_line
|
155
|
-
current_line = []
|
156
|
-
end
|
197
|
+
@res << indent unless part == "\n"
|
198
|
+
@res << part
|
157
199
|
end
|
158
200
|
|
159
|
-
|
160
|
-
|
161
|
-
# calculate margin
|
162
|
-
indented = lines.select { |line| line != ["\n"] }
|
163
|
-
margin = indented.map { |line| line.first.length }.min
|
164
|
-
|
165
|
-
# flush left
|
166
|
-
indented.each { |line| line[0][0...margin] = '' }
|
167
|
-
|
168
|
-
# output
|
169
|
-
use_prefix or @res << indent # verbatim is unlikely to have prefix
|
170
|
-
@res << lines.shift.join
|
171
|
-
|
172
|
-
lines.each do |line|
|
173
|
-
@res << indent unless line == ["\n"]
|
174
|
-
@res << line.join
|
175
|
-
end
|
176
|
-
|
177
|
-
@res << "\n"
|
201
|
+
@res << "\n" unless @res =~ /\n\z/
|
178
202
|
end
|
179
203
|
|
204
|
+
##
|
205
|
+
# Applies attribute-specific markup to +text+ using RDoc::AttributeManager
|
206
|
+
|
180
207
|
def attributes text
|
181
208
|
flow = @am.flow text.dup
|
182
209
|
convert_flow flow
|
183
210
|
end
|
184
211
|
|
212
|
+
##
|
213
|
+
# Returns the generated output
|
214
|
+
|
185
215
|
def end_accepting
|
186
216
|
@res.join
|
187
217
|
end
|
188
218
|
|
219
|
+
##
|
220
|
+
# Removes preceeding \\ from the suppressed crossref +special+
|
221
|
+
|
189
222
|
def handle_special_SUPPRESSED_CROSSREF special
|
190
|
-
special.text
|
223
|
+
text = special.text
|
224
|
+
text = text.sub('\\', '') unless in_tt?
|
225
|
+
text
|
191
226
|
end
|
192
227
|
|
228
|
+
##
|
229
|
+
# Prepares the visitor for text generation
|
230
|
+
|
193
231
|
def start_accepting
|
194
232
|
@res = [""]
|
195
233
|
@indent = 0
|
@@ -200,6 +238,10 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
200
238
|
@list_width = []
|
201
239
|
end
|
202
240
|
|
241
|
+
##
|
242
|
+
# Adds the stored #prefix to the output and clears it. Lists generate a
|
243
|
+
# prefix for later consumption.
|
244
|
+
|
203
245
|
def use_prefix
|
204
246
|
prefix = @prefix
|
205
247
|
@prefix = nil
|
@@ -208,6 +250,9 @@ class RDoc::Markup::ToRdoc < RDoc::Markup::Formatter
|
|
208
250
|
prefix
|
209
251
|
end
|
210
252
|
|
253
|
+
##
|
254
|
+
# Wraps +text+ to #width
|
255
|
+
|
211
256
|
def wrap text
|
212
257
|
return unless text && !text.empty?
|
213
258
|
|
data/lib/rdoc/markup/to_test.rb
CHANGED
@@ -6,6 +6,8 @@ require 'rdoc/markup/formatter'
|
|
6
6
|
|
7
7
|
class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
8
8
|
|
9
|
+
# :stopdoc:
|
10
|
+
|
9
11
|
##
|
10
12
|
# :section: Visitor
|
11
13
|
|
@@ -22,8 +24,12 @@ class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
|
22
24
|
@res << paragraph.text
|
23
25
|
end
|
24
26
|
|
27
|
+
def accept_raw raw
|
28
|
+
@res << raw.parts.join
|
29
|
+
end
|
30
|
+
|
25
31
|
def accept_verbatim(verbatim)
|
26
|
-
@res << verbatim.text
|
32
|
+
@res << verbatim.text.gsub(/^(\S)/, ' \1')
|
27
33
|
end
|
28
34
|
|
29
35
|
def accept_list_start(list)
|
@@ -60,5 +66,7 @@ class RDoc::Markup::ToTest < RDoc::Markup::Formatter
|
|
60
66
|
@res << '-' * rule.weight
|
61
67
|
end
|
62
68
|
|
69
|
+
# :startdoc:
|
70
|
+
|
63
71
|
end
|
64
72
|
|