rdoc 3.12.2 → 4.0.0.preview2

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.

Files changed (200) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +3 -2
  5. data/DEVELOPERS.rdoc +53 -0
  6. data/History.rdoc +159 -25
  7. data/LEGAL.rdoc +12 -0
  8. data/Manifest.txt +56 -3
  9. data/README.rdoc +87 -19
  10. data/Rakefile +11 -2
  11. data/TODO.rdoc +20 -13
  12. data/bin/rdoc +4 -0
  13. data/lib/gauntlet_rdoc.rb +1 -1
  14. data/lib/rdoc.rb +32 -71
  15. data/lib/rdoc/any_method.rb +75 -21
  16. data/lib/rdoc/attr.rb +49 -10
  17. data/lib/rdoc/class_module.rb +182 -32
  18. data/lib/rdoc/code_object.rb +54 -12
  19. data/lib/rdoc/comment.rb +8 -1
  20. data/lib/rdoc/constant.rb +100 -6
  21. data/lib/rdoc/context.rb +93 -41
  22. data/lib/rdoc/context/section.rb +143 -28
  23. data/lib/rdoc/cross_reference.rb +58 -50
  24. data/lib/rdoc/encoding.rb +34 -29
  25. data/lib/rdoc/erb_partial.rb +18 -0
  26. data/lib/rdoc/extend.rb +117 -0
  27. data/lib/rdoc/generator.rb +11 -6
  28. data/lib/rdoc/generator/darkfish.rb +250 -62
  29. data/lib/rdoc/generator/json_index.rb +20 -12
  30. data/lib/rdoc/generator/markup.rb +10 -12
  31. data/lib/rdoc/generator/ri.rb +7 -60
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
  38. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
  39. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
  41. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
  42. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
  43. data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
  44. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  45. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
  46. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  47. data/lib/rdoc/include.rb +12 -3
  48. data/lib/rdoc/markdown.kpeg +1186 -0
  49. data/lib/rdoc/markdown.rb +16336 -0
  50. data/lib/rdoc/markdown/entities.rb +2128 -0
  51. data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
  52. data/lib/rdoc/markdown/literals_1_8.rb +454 -0
  53. data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
  54. data/lib/rdoc/markdown/literals_1_9.rb +417 -0
  55. data/lib/rdoc/markup.rb +69 -10
  56. data/lib/rdoc/markup/attr_changer.rb +2 -5
  57. data/lib/rdoc/markup/attribute_manager.rb +23 -14
  58. data/lib/rdoc/markup/attributes.rb +70 -0
  59. data/lib/rdoc/markup/block_quote.rb +14 -0
  60. data/lib/rdoc/markup/document.rb +20 -4
  61. data/lib/rdoc/markup/formatter.rb +17 -6
  62. data/lib/rdoc/markup/formatter_test_case.rb +93 -24
  63. data/lib/rdoc/markup/hard_break.rb +31 -0
  64. data/lib/rdoc/markup/heading.rb +1 -1
  65. data/lib/rdoc/markup/indented_paragraph.rb +14 -0
  66. data/lib/rdoc/markup/list.rb +23 -4
  67. data/lib/rdoc/markup/list_item.rb +17 -4
  68. data/lib/rdoc/markup/paragraph.rb +14 -0
  69. data/lib/rdoc/markup/parser.rb +107 -60
  70. data/lib/rdoc/markup/raw.rb +4 -4
  71. data/lib/rdoc/markup/special.rb +3 -3
  72. data/lib/rdoc/markup/to_ansi.rb +7 -1
  73. data/lib/rdoc/markup/to_html.rb +42 -14
  74. data/lib/rdoc/markup/to_html_crossref.rb +10 -9
  75. data/lib/rdoc/markup/to_html_snippet.rb +20 -4
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
  77. data/lib/rdoc/markup/to_label.rb +20 -1
  78. data/lib/rdoc/markup/to_markdown.rb +134 -0
  79. data/lib/rdoc/markup/to_rdoc.rb +36 -5
  80. data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
  81. data/lib/rdoc/markup/to_tt_only.rb +11 -2
  82. data/lib/rdoc/markup/verbatim.rb +19 -0
  83. data/lib/rdoc/method_attr.rb +33 -19
  84. data/lib/rdoc/normal_class.rb +26 -7
  85. data/lib/rdoc/normal_module.rb +10 -5
  86. data/lib/rdoc/options.rb +95 -21
  87. data/lib/rdoc/parser.rb +6 -2
  88. data/lib/rdoc/parser/c.rb +212 -97
  89. data/lib/rdoc/parser/markdown.rb +23 -0
  90. data/lib/rdoc/parser/ruby.rb +115 -35
  91. data/lib/rdoc/parser/ruby_tools.rb +8 -3
  92. data/lib/rdoc/rd.rb +8 -4
  93. data/lib/rdoc/rd/block_parser.rb +1 -1
  94. data/lib/rdoc/rd/block_parser.ry +1 -1
  95. data/lib/rdoc/rdoc.rb +45 -21
  96. data/lib/rdoc/ri/driver.rb +322 -76
  97. data/lib/rdoc/ri/paths.rb +90 -31
  98. data/lib/rdoc/ri/store.rb +2 -353
  99. data/lib/rdoc/ruby_lex.rb +5 -21
  100. data/lib/rdoc/ruby_token.rb +2 -3
  101. data/lib/rdoc/rubygems_hook.rb +21 -9
  102. data/lib/rdoc/servlet.rb +302 -0
  103. data/lib/rdoc/stats.rb +28 -20
  104. data/lib/rdoc/store.rb +881 -0
  105. data/lib/rdoc/task.rb +2 -1
  106. data/lib/rdoc/test_case.rb +103 -1
  107. data/lib/rdoc/text.rb +5 -4
  108. data/lib/rdoc/tom_doc.rb +17 -16
  109. data/lib/rdoc/top_level.rb +43 -285
  110. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
  111. data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
  112. data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
  113. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
  114. data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
  115. data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
  116. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
  117. data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
  118. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
  119. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
  120. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
  121. data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
  122. data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
  123. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
  124. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
  125. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
  126. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
  127. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
  128. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
  129. data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
  130. data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
  131. data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
  132. data/test/test_attribute_manager.rb +7 -4
  133. data/test/test_rdoc_any_method.rb +84 -13
  134. data/test/test_rdoc_attr.rb +59 -9
  135. data/test/test_rdoc_class_module.rb +670 -73
  136. data/test/test_rdoc_code_object.rb +21 -1
  137. data/test/test_rdoc_comment.rb +1 -1
  138. data/test/test_rdoc_constant.rb +132 -0
  139. data/test/test_rdoc_context.rb +84 -18
  140. data/test/test_rdoc_context_section.rb +99 -15
  141. data/test/test_rdoc_cross_reference.rb +1 -1
  142. data/test/test_rdoc_encoding.rb +17 -1
  143. data/test/test_rdoc_extend.rb +94 -0
  144. data/test/test_rdoc_generator_darkfish.rb +45 -19
  145. data/test/test_rdoc_generator_json_index.rb +27 -7
  146. data/test/test_rdoc_generator_markup.rb +3 -3
  147. data/test/test_rdoc_generator_ri.rb +11 -9
  148. data/test/test_rdoc_include.rb +12 -0
  149. data/test/test_rdoc_markdown.rb +977 -0
  150. data/test/test_rdoc_markdown_test.rb +1891 -0
  151. data/test/test_rdoc_markup.rb +1 -1
  152. data/test/test_rdoc_markup_attribute_manager.rb +2 -2
  153. data/test/test_rdoc_markup_attributes.rb +39 -0
  154. data/test/test_rdoc_markup_document.rb +16 -1
  155. data/test/test_rdoc_markup_formatter.rb +7 -4
  156. data/test/test_rdoc_markup_hard_break.rb +31 -0
  157. data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
  158. data/test/test_rdoc_markup_paragraph.rb +15 -1
  159. data/test/test_rdoc_markup_parser.rb +152 -89
  160. data/test/test_rdoc_markup_to_ansi.rb +23 -2
  161. data/test/test_rdoc_markup_to_bs.rb +24 -0
  162. data/test/test_rdoc_markup_to_html.rb +50 -19
  163. data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
  164. data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
  165. data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
  166. data/test/test_rdoc_markup_to_label.rb +63 -1
  167. data/test/test_rdoc_markup_to_markdown.rb +352 -0
  168. data/test/test_rdoc_markup_to_rdoc.rb +22 -2
  169. data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
  170. data/test/test_rdoc_markup_to_tt_only.rb +20 -0
  171. data/test/test_rdoc_markup_verbatim.rb +13 -0
  172. data/test/test_rdoc_method_attr.rb +5 -0
  173. data/test/test_rdoc_normal_class.rb +24 -5
  174. data/test/test_rdoc_normal_module.rb +1 -1
  175. data/test/test_rdoc_options.rb +21 -6
  176. data/test/test_rdoc_parser.rb +24 -0
  177. data/test/test_rdoc_parser_c.rb +151 -26
  178. data/test/test_rdoc_parser_markdown.rb +55 -0
  179. data/test/test_rdoc_parser_rd.rb +2 -2
  180. data/test/test_rdoc_parser_ruby.rb +468 -109
  181. data/test/test_rdoc_parser_simple.rb +2 -2
  182. data/test/test_rdoc_rd_block_parser.rb +0 -4
  183. data/test/test_rdoc_rdoc.rb +110 -22
  184. data/test/test_rdoc_ri_driver.rb +415 -80
  185. data/test/test_rdoc_ri_paths.rb +122 -13
  186. data/test/test_rdoc_ruby_lex.rb +5 -61
  187. data/test/test_rdoc_ruby_token.rb +19 -0
  188. data/test/test_rdoc_rubygems_hook.rb +64 -43
  189. data/test/test_rdoc_servlet.rb +429 -0
  190. data/test/test_rdoc_stats.rb +83 -24
  191. data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
  192. data/test/test_rdoc_task.rb +2 -2
  193. data/test/test_rdoc_text.rb +37 -11
  194. data/test/test_rdoc_tom_doc.rb +59 -62
  195. data/test/test_rdoc_top_level.rb +71 -113
  196. data/test/xref_test_case.rb +7 -9
  197. metadata +122 -39
  198. metadata.gz.sig +0 -0
  199. data/CVE-2013-0256.rdoc +0 -49
  200. data/lib/rdoc/markup/attribute.rb +0 -51
@@ -11,11 +11,18 @@ class RDoc::Context::Section
11
11
 
12
12
  include RDoc::Text
13
13
 
14
+ MARSHAL_VERSION = 0 # :nodoc:
15
+
14
16
  ##
15
17
  # Section comment
16
18
 
17
19
  attr_reader :comment
18
20
 
21
+ ##
22
+ # Section comments
23
+
24
+ attr_reader :comments
25
+
19
26
  ##
20
27
  # Context this Section lives in
21
28
 
@@ -38,8 +45,9 @@ class RDoc::Context::Section
38
45
  @@sequence.succ!
39
46
  @sequence = @@sequence.dup
40
47
 
41
- @comment = nil
42
- @comment = extract_comment comment if comment
48
+ @comments = []
49
+
50
+ add_comment comment
43
51
  end
44
52
 
45
53
  ##
@@ -50,30 +58,34 @@ class RDoc::Context::Section
50
58
  end
51
59
 
52
60
  ##
53
- # Anchor reference for linking to this section
54
-
55
- def aref
56
- title = @title || '[untitled]'
57
-
58
- CGI.escape(title).gsub('%', '-').sub(/^-/, '')
59
- end
60
-
61
- ##
62
- # Appends +comment+ to the current comment separated by a rule.
61
+ # Adds +comment+ to this section
63
62
 
64
- def comment= comment
63
+ def add_comment comment
65
64
  comment = extract_comment comment
66
65
 
67
66
  return if comment.empty?
68
67
 
69
- if @comment then
70
- # HACK should section comments get joined?
71
- @comment.text += "\n# ---\n#{comment.text}"
68
+ case comment
69
+ when RDoc::Comment then
70
+ @comments << comment
71
+ when RDoc::Markup::Document then
72
+ @comments.concat comment.parts
73
+ when Array then
74
+ @comments.concat comment
72
75
  else
73
- @comment = comment
76
+ raise TypeError, "unknown comment type: #{comment.inspect}"
74
77
  end
75
78
  end
76
79
 
80
+ ##
81
+ # Anchor reference for linking to this section
82
+
83
+ def aref
84
+ title = @title || '[untitled]'
85
+
86
+ CGI.escape(title).gsub('%', '-').sub(/^-/, '')
87
+ end
88
+
77
89
  ##
78
90
  # Extracts the comment for this section from the original comment block.
79
91
  # If the first line contains :section:, strip it and use the rest.
@@ -84,24 +96,106 @@ class RDoc::Context::Section
84
96
  # # The body
85
97
 
86
98
  def extract_comment comment
87
- if comment.text =~ /^#[ \t]*:section:.*\n/ then
88
- start = $`
89
- rest = $'
90
-
91
- comment.text = if start.empty? then
92
- rest
93
- else
94
- rest.sub(/#{start.chomp}\Z/, '')
95
- end
99
+ case comment
100
+ when Array then
101
+ comment.map do |c|
102
+ extract_comment c
103
+ end
104
+ when nil
105
+ RDoc::Comment.new ''
106
+ when RDoc::Comment then
107
+ if comment.text =~ /^#[ \t]*:section:.*\n/ then
108
+ start = $`
109
+ rest = $'
110
+
111
+ comment.text = if start.empty? then
112
+ rest
113
+ else
114
+ rest.sub(/#{start.chomp}\Z/, '')
115
+ end
116
+ end
117
+
118
+ comment
119
+ when RDoc::Markup::Document then
120
+ comment
121
+ else
122
+ raise TypeError, "unknown comment #{comment.inspect}"
96
123
  end
97
-
98
- comment
99
124
  end
100
125
 
101
126
  def inspect # :nodoc:
102
127
  "#<%s:0x%x %p>" % [self.class, object_id, title]
103
128
  end
104
129
 
130
+ ##
131
+ # The files comments in this section come from
132
+
133
+ def in_files
134
+ return [] if @comments.empty?
135
+
136
+ case @comments
137
+ when Array then
138
+ @comments.map do |comment|
139
+ comment.file
140
+ end
141
+ when RDoc::Markup::Document then
142
+ @comment.parts.map do |document|
143
+ document.file
144
+ end
145
+ else
146
+ raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
147
+ end
148
+ end
149
+
150
+ ##
151
+ # Serializes this Section. The title and parsed comment are saved, but not
152
+ # the section parent which must be restored manually.
153
+
154
+ def marshal_dump
155
+ [
156
+ MARSHAL_VERSION,
157
+ @title,
158
+ parse,
159
+ ]
160
+ end
161
+
162
+ ##
163
+ # De-serializes this Section. The section parent must be restored manually.
164
+
165
+ def marshal_load array
166
+ @parent = nil
167
+
168
+ @title = array[1]
169
+ @comments = array[2]
170
+ end
171
+
172
+ ##
173
+ # Parses +comment_location+ into an RDoc::Markup::Document composed of
174
+ # multiple RDoc::Markup::Documents with their file set.
175
+
176
+ def parse
177
+ case @comments
178
+ when String then
179
+ super
180
+ when Array then
181
+ docs = @comments.map do |comment, location|
182
+ doc = super comment
183
+ doc.file = location if location
184
+ doc
185
+ end
186
+
187
+ RDoc::Markup::Document.new(*docs)
188
+ when RDoc::Comment then
189
+ doc = super @comments.text, comments.format
190
+ doc.file = @comments.location
191
+ doc
192
+ when RDoc::Markup::Document then
193
+ return @comments
194
+ else
195
+ raise ArgumentError, "unknown comment class #{comments.class}"
196
+ end
197
+ end
198
+
105
199
  ##
106
200
  # The section's title, or 'Top Section' if the title is nil.
107
201
  #
@@ -111,6 +205,27 @@ class RDoc::Context::Section
111
205
  @title || 'Top Section'
112
206
  end
113
207
 
208
+ ##
209
+ # Removes a comment from this section if it is from the same file as
210
+ # +comment+
211
+
212
+ def remove_comment comment
213
+ return if @comments.empty?
214
+
215
+ case @comments
216
+ when Array then
217
+ @comments.delete_if do |my_comment|
218
+ my_comment.file == comment.file
219
+ end
220
+ when RDoc::Markup::Document then
221
+ @comments.parts.delete_if do |document|
222
+ document.file == comment.file.name
223
+ end
224
+ else
225
+ raise RDoc::Error, "BUG: unknown comment class #{@comments.class}"
226
+ end
227
+ end
228
+
114
229
  ##
115
230
  # Section sequence number (deprecated)
116
231
 
@@ -27,69 +27,76 @@ class RDoc::CrossReference
27
27
  # have been suppressed, since the suppression characters are removed by the
28
28
  # code that is triggered.
29
29
 
30
- CROSSREF_REGEXP = /(
31
- # A::B::C.meth
32
- #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
33
-
34
- # Stand-alone method (preceded by a #)
35
- | \\?\##{METHOD_REGEXP_STR}
36
-
37
- # Stand-alone method (preceded by ::)
38
- | ::#{METHOD_REGEXP_STR}
39
-
40
- # A::B::C
41
- # The stuff after CLASS_REGEXP_STR is a
42
- # nasty hack. CLASS_REGEXP_STR unfortunately matches
43
- # words like dog and cat (these are legal "class"
44
- # names in Fortran 95). When a word is flagged as a
45
- # potential cross-reference, limitations in the markup
46
- # engine suppress other processing, such as typesetting.
47
- # This is particularly noticeable for contractions.
48
- # In order that words like "can't" not
49
- # be flagged as potential cross-references, only
50
- # flag potential class cross-references if the character
51
- # after the cross-reference is a space, sentence
52
- # punctuation, tag start character, or attribute
53
- # marker.
54
- | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
55
-
56
- # Things that look like filenames
57
- # The key thing is that there must be at least
58
- # one special character (period, slash, or
59
- # underscore).
60
- | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
61
-
62
- # Things that have markup suppressed
63
- # Don't process things like '\<' in \<tt>, though.
64
- # TODO: including < is a hack, not very satisfying.
65
- | \\[^\s<]
30
+ CROSSREF_REGEXP = /(?:^|\s)
31
+ (
32
+ (?:
33
+ # A::B::C.meth
34
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
35
+
36
+ # Stand-alone method (preceded by a #)
37
+ | \\?\##{METHOD_REGEXP_STR}
38
+
39
+ # Stand-alone method (preceded by ::)
40
+ | ::#{METHOD_REGEXP_STR}
41
+
42
+ # A::B::C
43
+ # The stuff after CLASS_REGEXP_STR is a
44
+ # nasty hack. CLASS_REGEXP_STR unfortunately matches
45
+ # words like dog and cat (these are legal "class"
46
+ # names in Fortran 95). When a word is flagged as a
47
+ # potential cross-reference, limitations in the markup
48
+ # engine suppress other processing, such as typesetting.
49
+ # This is particularly noticeable for contractions.
50
+ # In order that words like "can't" not
51
+ # be flagged as potential cross-references, only
52
+ # flag potential class cross-references if the character
53
+ # after the cross-reference is a space, sentence
54
+ # punctuation, tag start character, or attribute
55
+ # marker.
56
+ | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
57
+
58
+ # Things that look like filenames
59
+ # The key thing is that there must be at least
60
+ # one special character (period, slash, or
61
+ # underscore).
62
+ | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
63
+
64
+ # Things that have markup suppressed
65
+ # Don't process things like '\<' in \<tt>, though.
66
+ # TODO: including < is a hack, not very satisfying.
67
+ | \\[^\s<]
66
68
  )
67
69
 
68
70
  # labels for headings
69
- (?:@[\w+%-]+)?/x
71
+ (?:@[\w+%-]+(?:\.[\w|%-]+)?)?
72
+ )/x
70
73
 
71
74
  ##
72
75
  # Version of CROSSREF_REGEXP used when <tt>--hyperlink-all</tt> is specified.
73
76
 
74
- ALL_CROSSREF_REGEXP = /(
75
- # A::B::C.meth
76
- #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
77
+ ALL_CROSSREF_REGEXP = /
78
+ (?:^|\s)
79
+ (
80
+ (?:
81
+ # A::B::C.meth
82
+ #{CLASS_REGEXP_STR}(?:[.#]|::)#{METHOD_REGEXP_STR}
77
83
 
78
- # Stand-alone method
79
- | \\?#{METHOD_REGEXP_STR}
84
+ # Stand-alone method
85
+ | \\?#{METHOD_REGEXP_STR}
80
86
 
81
- # A::B::C
82
- | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
87
+ # A::B::C
88
+ | #{CLASS_REGEXP_STR}(?=[@\s).?!,;<\000]|\z)
83
89
 
84
- # Things that look like filenames
85
- | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
90
+ # Things that look like filenames
91
+ | (?:\.\.\/)*[-\/\w]+[_\/.][-\w\/.]+
86
92
 
87
- # Things that have markup suppressed
88
- | \\[^\s<]
93
+ # Things that have markup suppressed
94
+ | \\[^\s<]
89
95
  )
90
96
 
91
97
  # labels for headings
92
- (?:@[\w+%-]+)?/x
98
+ (?:@[\w+%-]+)?
99
+ )/x
93
100
 
94
101
  ##
95
102
  # Hash of references that have been looked-up to their replacements
@@ -102,6 +109,7 @@ class RDoc::CrossReference
102
109
 
103
110
  def initialize context
104
111
  @context = context
112
+ @store = context.store
105
113
 
106
114
  @seen = {}
107
115
  end
@@ -146,7 +154,7 @@ class RDoc::CrossReference
146
154
  end unless ref
147
155
 
148
156
  # Try a page name
149
- ref = RDoc::TopLevel.page name if not ref and name =~ /^\w+$/
157
+ ref = @store.page name if not ref and name =~ /^\w+$/
150
158
 
151
159
  ref = nil if RDoc::Alias === ref # external alias, can't link to it
152
160
 
@@ -25,26 +25,40 @@ module RDoc::Encoding
25
25
  RDoc::Encoding.set_encoding content
26
26
 
27
27
  if Object.const_defined? :Encoding then
28
- encoding ||= Encoding.default_external
29
- orig_encoding = content.encoding
30
-
31
- if utf8 then
32
- content.force_encoding Encoding::UTF_8
33
- content.encode! encoding
34
- else
35
- # assume the content is in our output encoding
36
- content.force_encoding encoding
37
- end
38
-
39
- unless content.valid_encoding? then
40
- # revert and try to transcode
41
- content.force_encoding orig_encoding
42
- content.encode! encoding
43
- end
44
-
45
- unless content.valid_encoding? then
46
- warn "unable to convert #{filename} to #{encoding}, skipping"
47
- content = nil
28
+ begin
29
+ encoding ||= Encoding.default_external
30
+ orig_encoding = content.encoding
31
+
32
+ if utf8 then
33
+ content.force_encoding Encoding::UTF_8
34
+ content.encode! encoding
35
+ else
36
+ # assume the content is in our output encoding
37
+ content.force_encoding encoding
38
+ end
39
+
40
+ unless content.valid_encoding? then
41
+ # revert and try to transcode
42
+ content.force_encoding orig_encoding
43
+ content.encode! encoding
44
+ end
45
+
46
+ unless content.valid_encoding? then
47
+ warn "unable to convert #{filename} to #{encoding}, skipping"
48
+ content = nil
49
+ end
50
+ rescue Encoding::InvalidByteSequenceError,
51
+ Encoding::UndefinedConversionError => e
52
+ if force_transcode then
53
+ content.force_encoding orig_encoding
54
+ content.encode!(encoding,
55
+ :invalid => :replace, :undef => :replace,
56
+ :replace => '?')
57
+ return content
58
+ else
59
+ warn "unable to convert #{e.message} for #{filename}, skipping"
60
+ return nil
61
+ end
48
62
  end
49
63
  end
50
64
 
@@ -53,15 +67,6 @@ module RDoc::Encoding
53
67
  raise unless e.message =~ /unknown encoding name - (.*)/
54
68
  warn "unknown encoding name \"#{$1}\" for #{filename}, skipping"
55
69
  nil
56
- rescue Encoding::UndefinedConversionError => e
57
- if force_transcode then
58
- content.force_encoding orig_encoding
59
- content.encode! encoding, :undef => :replace, :replace => '?'
60
- content
61
- else
62
- warn "unable to convert #{e.message} for #{filename}, skipping"
63
- nil
64
- end
65
70
  rescue Errno::EISDIR, Errno::ENOENT
66
71
  nil
67
72
  end
@@ -0,0 +1,18 @@
1
+ ##
2
+ # Allows an ERB template to be rendered in the context (binding) of an
3
+ # existing ERB template evaluation.
4
+
5
+ class RDoc::ERBPartial < ERB
6
+
7
+ ##
8
+ # Overrides +compiler+ startup to set the +eoutvar+ to an empty string only
9
+ # if it isn't already set.
10
+
11
+ def set_eoutvar compiler, eoutvar = '_erbout'
12
+ super
13
+
14
+ compiler.pre_cmd = ["#{eoutvar} ||= ''"]
15
+ end
16
+
17
+ end
18
+