rdoc 3.9.5 → 3.10.pre.1
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/.autotest +6 -3
- data/History.txt +63 -13
- data/LICENSE.rdoc +57 -0
- data/Manifest.txt +60 -6
- data/Rakefile +24 -12
- data/TODO.rdoc +30 -0
- data/bin/rdoc +0 -2
- data/lib/rdoc.rb +55 -2
- data/lib/rdoc/alias.rb +0 -2
- data/lib/rdoc/anon_class.rb +0 -2
- data/lib/rdoc/any_method.rb +0 -3
- data/lib/rdoc/attr.rb +0 -2
- data/lib/rdoc/class_module.rb +40 -7
- data/lib/rdoc/code_object.rb +1 -3
- data/lib/rdoc/code_objects.rb +3 -21
- data/lib/rdoc/comment.rb +225 -0
- data/lib/rdoc/constant.rb +0 -2
- data/lib/rdoc/context.rb +37 -120
- data/lib/rdoc/context/section.rb +114 -0
- data/lib/rdoc/cross_reference.rb +16 -7
- data/lib/rdoc/encoding.rb +0 -2
- data/lib/rdoc/gauntlet.rb +1 -1
- data/lib/rdoc/generator.rb +7 -2
- data/lib/rdoc/generator/darkfish.rb +126 -20
- data/lib/rdoc/generator/json_index.rb +240 -0
- data/lib/rdoc/generator/markup.rb +17 -54
- data/lib/rdoc/generator/ri.rb +0 -3
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
- data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
- data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
- data/lib/rdoc/ghost_method.rb +0 -2
- data/lib/rdoc/include.rb +0 -2
- data/lib/rdoc/markup.rb +204 -43
- data/lib/rdoc/markup/attr_changer.rb +25 -0
- data/lib/rdoc/markup/attr_span.rb +29 -0
- data/lib/rdoc/markup/attribute.rb +51 -0
- data/lib/rdoc/markup/document.rb +22 -1
- data/lib/rdoc/markup/formatter.rb +4 -11
- data/lib/rdoc/markup/formatter_test_case.rb +1 -2
- data/lib/rdoc/markup/heading.rb +44 -0
- data/lib/rdoc/markup/include.rb +42 -0
- data/lib/rdoc/markup/inline.rb +1 -144
- data/lib/rdoc/markup/list.rb +2 -1
- data/lib/rdoc/markup/parser.rb +6 -16
- data/lib/rdoc/markup/pre_process.rb +64 -10
- data/lib/rdoc/markup/raw.rb +1 -1
- data/lib/rdoc/markup/special.rb +40 -0
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
- data/lib/rdoc/markup/to_ansi.rb +0 -2
- data/lib/rdoc/markup/to_bs.rb +0 -2
- data/lib/rdoc/markup/to_html.rb +102 -34
- data/lib/rdoc/markup/to_html_crossref.rb +36 -5
- data/lib/rdoc/markup/to_html_snippet.rb +270 -0
- data/lib/rdoc/markup/to_label.rb +55 -0
- data/lib/rdoc/markup/to_rdoc.rb +0 -3
- data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
- data/lib/rdoc/markup/to_test.rb +0 -3
- data/lib/rdoc/markup/to_tt_only.rb +0 -3
- data/lib/rdoc/markup/verbatim.rb +18 -0
- data/lib/rdoc/meta_method.rb +0 -2
- data/lib/rdoc/method_attr.rb +17 -1
- data/lib/rdoc/normal_class.rb +0 -2
- data/lib/rdoc/normal_module.rb +0 -2
- data/lib/rdoc/options.rb +18 -3
- data/lib/rdoc/parser.rb +74 -42
- data/lib/rdoc/parser/c.rb +79 -118
- data/lib/rdoc/parser/rd.rb +22 -0
- data/lib/rdoc/parser/ruby.rb +86 -54
- data/lib/rdoc/parser/simple.rb +21 -9
- data/lib/rdoc/parser/text.rb +11 -0
- data/lib/rdoc/rd.rb +95 -0
- data/lib/rdoc/rd/block_parser.ry +638 -0
- data/lib/rdoc/rd/inline.rb +71 -0
- data/lib/rdoc/rd/inline_parser.ry +575 -0
- data/lib/rdoc/rdoc.rb +8 -23
- data/lib/rdoc/require.rb +0 -2
- data/lib/rdoc/ri.rb +4 -2
- data/lib/rdoc/ri/driver.rb +2 -6
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ruby_lex.rb +43 -20
- data/lib/rdoc/ruby_token.rb +44 -2
- data/lib/rdoc/single_class.rb +0 -2
- data/lib/rdoc/stats.rb +0 -5
- data/lib/rdoc/task.rb +2 -6
- data/lib/rdoc/test_case.rb +59 -0
- data/lib/rdoc/text.rb +42 -30
- data/lib/rdoc/token_stream.rb +45 -0
- data/lib/rdoc/tom_doc.rb +232 -0
- data/lib/rdoc/top_level.rb +36 -4
- data/test/test_attribute_manager.rb +26 -29
- data/test/test_rdoc_any_method.rb +2 -26
- data/test/test_rdoc_attr.rb +4 -4
- data/test/test_rdoc_class_module.rb +95 -12
- data/test/test_rdoc_code_object.rb +10 -3
- data/test/test_rdoc_comment.rb +504 -0
- data/test/test_rdoc_context.rb +60 -11
- data/test/test_rdoc_context_section.rb +16 -17
- data/test/test_rdoc_cross_reference.rb +17 -2
- data/test/test_rdoc_encoding.rb +4 -7
- data/test/test_rdoc_generator_darkfish.rb +12 -11
- data/test/test_rdoc_generator_json_index.rb +255 -0
- data/test/test_rdoc_generator_markup.rb +56 -0
- data/test/test_rdoc_generator_ri.rb +8 -11
- data/test/test_rdoc_markup.rb +9 -5
- data/test/test_rdoc_markup_attribute_manager.rb +5 -8
- data/test/test_rdoc_markup_document.rb +34 -6
- data/test/test_rdoc_markup_formatter.rb +11 -13
- data/test/test_rdoc_markup_heading.rb +20 -0
- data/test/test_rdoc_markup_include.rb +19 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
- data/test/test_rdoc_markup_paragraph.rb +2 -5
- data/test/test_rdoc_markup_parser.rb +87 -7
- data/test/test_rdoc_markup_pre_process.rb +60 -9
- data/test/test_rdoc_markup_raw.rb +4 -6
- data/test/test_rdoc_markup_to_ansi.rb +1 -4
- data/test/test_rdoc_markup_to_bs.rb +1 -4
- data/test/test_rdoc_markup_to_html.rb +170 -31
- data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
- data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
- data/test/test_rdoc_markup_to_label.rb +50 -0
- data/test/test_rdoc_markup_to_rdoc.rb +1 -4
- data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
- data/test/test_rdoc_markup_to_tt_only.rb +1 -4
- data/test/test_rdoc_markup_verbatim.rb +16 -0
- data/test/test_rdoc_method_attr.rb +16 -1
- data/test/test_rdoc_options.rb +17 -7
- data/test/test_rdoc_parser.rb +75 -6
- data/test/test_rdoc_parser_c.rb +56 -104
- data/test/test_rdoc_parser_rd.rb +52 -0
- data/test/test_rdoc_parser_ruby.rb +264 -323
- data/test/test_rdoc_parser_simple.rb +33 -17
- data/test/test_rdoc_rd.rb +30 -0
- data/test/test_rdoc_rd_block_parser.rb +527 -0
- data/test/test_rdoc_rd_inline.rb +63 -0
- data/test/test_rdoc_rd_inline_parser.rb +173 -0
- data/test/test_rdoc_rdoc.rb +7 -9
- data/test/test_rdoc_ri_driver.rb +10 -15
- data/test/test_rdoc_ri_paths.rb +6 -6
- data/test/test_rdoc_ri_store.rb +6 -13
- data/test/test_rdoc_ruby_lex.rb +53 -5
- data/test/test_rdoc_rubygems_hook.rb +2 -1
- data/test/test_rdoc_stats.rb +83 -103
- data/test/test_rdoc_task.rb +5 -4
- data/test/test_rdoc_text.rb +156 -11
- data/test/test_rdoc_token_stream.rb +42 -0
- data/test/test_rdoc_tom_doc.rb +458 -0
- data/test/test_rdoc_top_level.rb +49 -2
- data/test/xref_test_case.rb +4 -8
- metadata +217 -111
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/LICENSE.txt +0 -57
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
data/lib/rdoc/markup/to_test.rb
CHANGED
data/lib/rdoc/markup/verbatim.rb
CHANGED
@@ -3,6 +3,17 @@
|
|
3
3
|
|
4
4
|
class RDoc::Markup::Verbatim < RDoc::Markup::Raw
|
5
5
|
|
6
|
+
##
|
7
|
+
# Format of this verbatim section
|
8
|
+
|
9
|
+
attr_accessor :format
|
10
|
+
|
11
|
+
def initialize *parts # :nodoc:
|
12
|
+
super
|
13
|
+
|
14
|
+
@format = nil
|
15
|
+
end
|
16
|
+
|
6
17
|
##
|
7
18
|
# Calls #accept_verbatim on +visitor+
|
8
19
|
|
@@ -34,6 +45,13 @@ class RDoc::Markup::Verbatim < RDoc::Markup::Raw
|
|
34
45
|
@parts = parts
|
35
46
|
end
|
36
47
|
|
48
|
+
##
|
49
|
+
# Is this verbatim section ruby code?
|
50
|
+
|
51
|
+
def ruby?
|
52
|
+
@format == :ruby
|
53
|
+
end
|
54
|
+
|
37
55
|
##
|
38
56
|
# The text of the section
|
39
57
|
|
data/lib/rdoc/meta_method.rb
CHANGED
data/lib/rdoc/method_attr.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'cgi'
|
2
2
|
|
3
3
|
##
|
4
4
|
# Abstract class representing either a method or an attribute.
|
@@ -343,6 +343,22 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
343
343
|
]
|
344
344
|
end
|
345
345
|
|
346
|
+
##
|
347
|
+
# Used by RDoc::Generator::JsonIndex to create a record for the search
|
348
|
+
# engine.
|
349
|
+
|
350
|
+
def search_record
|
351
|
+
[
|
352
|
+
@name,
|
353
|
+
full_name,
|
354
|
+
@name,
|
355
|
+
@parent.full_name,
|
356
|
+
path,
|
357
|
+
params,
|
358
|
+
snippet(@comment),
|
359
|
+
]
|
360
|
+
end
|
361
|
+
|
346
362
|
def to_s # :nodoc:
|
347
363
|
if @is_alias_for
|
348
364
|
"#{self.class.name}: #{full_name} -> #{is_alias_for}"
|
data/lib/rdoc/normal_class.rb
CHANGED
data/lib/rdoc/normal_module.rb
CHANGED
data/lib/rdoc/options.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
|
3
|
-
require 'rdoc/ri/paths'
|
4
|
-
|
5
3
|
##
|
6
4
|
# RDoc::Options handles the parsing and storage of options
|
7
5
|
|
@@ -98,6 +96,12 @@ class RDoc::Options
|
|
98
96
|
|
99
97
|
attr_accessor :main_page
|
100
98
|
|
99
|
+
##
|
100
|
+
# The default markup format. The default is 'rdoc'. 'tomdoc' and 'rd' are
|
101
|
+
# also built-in.
|
102
|
+
|
103
|
+
attr_accessor :markup
|
104
|
+
|
101
105
|
##
|
102
106
|
# If true, only report on undocumented files
|
103
107
|
|
@@ -171,7 +175,6 @@ class RDoc::Options
|
|
171
175
|
attr_accessor :visibility
|
172
176
|
|
173
177
|
def initialize # :nodoc:
|
174
|
-
require 'rdoc/rdoc'
|
175
178
|
@dry_run = false
|
176
179
|
@exclude = []
|
177
180
|
@force_output = false
|
@@ -183,6 +186,7 @@ class RDoc::Options
|
|
183
186
|
@hyperlink_all = false
|
184
187
|
@line_numbers = false
|
185
188
|
@main_page = nil
|
189
|
+
@markup = 'rdoc'
|
186
190
|
@coverage_report = false
|
187
191
|
@op_dir = nil
|
188
192
|
@pipe = false
|
@@ -451,6 +455,17 @@ Usage: #{opt.program_name} [options] [names...]
|
|
451
455
|
@visibility = value
|
452
456
|
end
|
453
457
|
|
458
|
+
opt.separator nil
|
459
|
+
|
460
|
+
markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
|
461
|
+
|
462
|
+
opt.on("--markup=MARKUP", markup_formats,
|
463
|
+
"The markup format for the named files.",
|
464
|
+
"The default is rdoc. Valid values are:",
|
465
|
+
markup_formats.join(', ')) do |value|
|
466
|
+
@markup = value
|
467
|
+
end
|
468
|
+
|
454
469
|
opt.separator nil
|
455
470
|
opt.separator "Common generator options:"
|
456
471
|
opt.separator nil
|
data/lib/rdoc/parser.rb
CHANGED
@@ -1,41 +1,31 @@
|
|
1
|
-
require 'rdoc'
|
2
|
-
require 'rdoc/code_objects'
|
3
|
-
require 'rdoc/markup/pre_process'
|
4
|
-
require 'rdoc/stats'
|
5
|
-
|
6
1
|
##
|
7
|
-
# A parser is a class that subclasses RDoc::Parser and implements
|
8
|
-
#
|
9
|
-
# #initialize top_level, file_name, body, options, stats
|
10
|
-
#
|
11
|
-
# and
|
2
|
+
# A parser is simple a class that subclasses RDoc::Parser and implements #scan
|
3
|
+
# to fill in an RDoc::TopLevel with parsed data.
|
12
4
|
#
|
13
|
-
#
|
5
|
+
# The initialize method takes an RDoc::TopLevel to fill with parsed content,
|
6
|
+
# the name of the file to be parsed, the content of the file, an RDoc::Options
|
7
|
+
# object and an RDoc::Stats object to inform the user of parsed items. The
|
8
|
+
# scan method is then called to parse the file and must return the
|
9
|
+
# RDoc::TopLevel object. By calling super these items will be set for you.
|
14
10
|
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
# appropriately parsed TopLevel code object.
|
11
|
+
# In order to be used by RDoc the parser needs to register the file extensions
|
12
|
+
# it can parse. Use ::parse_files_matching to register extensions.
|
18
13
|
#
|
19
|
-
#
|
20
|
-
# given filename extension. Parsers have to register themselves RDoc::Parser
|
21
|
-
# using parse_files_matching as when they are loaded:
|
22
|
-
#
|
23
|
-
# require "rdoc/parser"
|
14
|
+
# require 'rdoc'
|
24
15
|
#
|
25
16
|
# class RDoc::Parser::Xyz < RDoc::Parser
|
26
|
-
# parse_files_matching /\.xyz$/
|
17
|
+
# parse_files_matching /\.xyz$/
|
18
|
+
#
|
19
|
+
# def initialize top_level, file_name, content, options, stats
|
20
|
+
# super
|
27
21
|
#
|
28
|
-
#
|
29
|
-
# ...
|
22
|
+
# # extra initialization if needed
|
30
23
|
# end
|
31
24
|
#
|
32
25
|
# def scan
|
33
|
-
#
|
26
|
+
# # parse file and fill in @top_level
|
34
27
|
# end
|
35
28
|
# end
|
36
|
-
#
|
37
|
-
# If a plain text file is detected, RDoc also looks for a shebang line in case
|
38
|
-
# the file is a shell script.
|
39
29
|
|
40
30
|
class RDoc::Parser
|
41
31
|
|
@@ -154,26 +144,30 @@ class RDoc::Parser
|
|
154
144
|
end
|
155
145
|
|
156
146
|
##
|
157
|
-
#
|
158
|
-
#
|
147
|
+
# Finds and instantiates the correct parser for the given +file_name+ and
|
148
|
+
# +content+.
|
159
149
|
|
160
|
-
def self.for
|
150
|
+
def self.for top_level, file_name, content, options, stats
|
161
151
|
return if binary? file_name
|
162
152
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
153
|
+
parser = use_format content
|
154
|
+
|
155
|
+
unless parser then
|
156
|
+
# If no extension, look for shebang
|
157
|
+
if file_name !~ /\.\w+$/ && content =~ %r{\A#!(.+)} then
|
158
|
+
shebang = $1
|
159
|
+
case shebang
|
160
|
+
when %r{env\s+ruby}, %r{/ruby}
|
161
|
+
file_name = "dummy.rb"
|
162
|
+
end
|
169
163
|
end
|
170
|
-
end
|
171
164
|
|
172
|
-
|
165
|
+
parser = can_parse file_name
|
166
|
+
end
|
173
167
|
|
174
168
|
return unless parser
|
175
169
|
|
176
|
-
parser.new top_level, file_name,
|
170
|
+
parser.new top_level, file_name, content, options, stats
|
177
171
|
end
|
178
172
|
|
179
173
|
##
|
@@ -186,13 +180,44 @@ class RDoc::Parser
|
|
186
180
|
end
|
187
181
|
|
188
182
|
##
|
189
|
-
#
|
190
|
-
#
|
183
|
+
# If there is a <tt>format: parser_name</tt> comment at the front of the
|
184
|
+
# file, use it to determine the parser. For example:
|
185
|
+
#
|
186
|
+
# # format: rdoc
|
187
|
+
# # Class comment can go here
|
188
|
+
#
|
189
|
+
# class C
|
190
|
+
# end
|
191
191
|
#
|
192
|
-
#
|
192
|
+
# The comment should appear as the first line of the +content+.
|
193
|
+
#
|
194
|
+
# If the content contains a shebang or editor modeline the comment may
|
195
|
+
# appear on the second or third line.
|
196
|
+
#
|
197
|
+
# Any comment style may be used to hide the format comment.
|
198
|
+
|
199
|
+
def self.use_format content
|
200
|
+
format = content.lines.first(3).grep(/format:\s+(\w+)/) { $1 }.first
|
201
|
+
|
202
|
+
return unless format
|
203
|
+
|
204
|
+
format = Regexp.escape format
|
205
|
+
|
206
|
+
RDoc::Parser.parsers.find do |_, parser|
|
207
|
+
/^#{format}$/i =~ parser.name.sub(/.*:/, '')
|
208
|
+
end.last
|
209
|
+
end
|
210
|
+
|
211
|
+
##
|
212
|
+
# Creates a new Parser storing +top_level+, +file_name+, +content+,
|
213
|
+
# +options+ and +stats+ in instance variables. In +@preprocess+ an
|
214
|
+
# RDoc::Markup::PreProcess object is created which allows processing of
|
215
|
+
# directives.
|
193
216
|
|
194
|
-
def initialize
|
217
|
+
def initialize top_level, file_name, content, options, stats
|
195
218
|
@top_level = top_level
|
219
|
+
@top_level.parser = self.class
|
220
|
+
|
196
221
|
@file_name = file_name
|
197
222
|
@content = content
|
198
223
|
@options = options
|
@@ -202,7 +227,14 @@ class RDoc::Parser
|
|
202
227
|
@preprocess.options = @options
|
203
228
|
end
|
204
229
|
|
230
|
+
autoload :RubyTools, 'rdoc/parser/ruby_tools'
|
231
|
+
autoload :Text, 'rdoc/parser/text'
|
232
|
+
|
205
233
|
end
|
206
234
|
|
235
|
+
# simple must come first in order to show up last in the parsers list
|
207
236
|
require 'rdoc/parser/simple'
|
237
|
+
require 'rdoc/parser/rd'
|
238
|
+
require 'rdoc/parser/ruby'
|
239
|
+
require 'rdoc/parser/c'
|
208
240
|
|
data/lib/rdoc/parser/c.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
|
2
|
-
require 'rdoc/parser/ruby'
|
3
|
-
require 'rdoc/known_classes'
|
4
|
-
|
5
1
|
##
|
6
2
|
# RDoc::Parser::C attempts to parse C extension files. It looks for
|
7
3
|
# the standard patterns that you find in extensions: <tt>rb_define_class,
|
@@ -180,7 +176,9 @@ class RDoc::Parser::C < RDoc::Parser
|
|
180
176
|
al.singleton = @singleton_classes.key? var_name
|
181
177
|
|
182
178
|
comment = find_alias_comment var_name, new_name, old_name
|
183
|
-
|
179
|
+
|
180
|
+
comment.normalize
|
181
|
+
|
184
182
|
al.comment = comment
|
185
183
|
|
186
184
|
al.record_location @top_level
|
@@ -311,7 +309,9 @@ class RDoc::Parser::C < RDoc::Parser
|
|
311
309
|
@content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |c,m|
|
312
310
|
if cls = @classes[c]
|
313
311
|
m = @known_classes[m] || m
|
314
|
-
|
312
|
+
|
313
|
+
comment = RDoc::Comment.new '', @top_level
|
314
|
+
incl = cls.add_include RDoc::Include.new(m, comment)
|
315
315
|
incl.record_location @top_level
|
316
316
|
end
|
317
317
|
end
|
@@ -377,7 +377,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
377
377
|
\s*"#{Regexp.escape new_name}"\s*,
|
378
378
|
\s*"#{Regexp.escape old_name}"\s*\);%xm
|
379
379
|
|
380
|
-
$1 || ''
|
380
|
+
RDoc::Comment.new($1 || '', @top_level)
|
381
381
|
end
|
382
382
|
|
383
383
|
##
|
@@ -398,22 +398,24 @@ class RDoc::Parser::C < RDoc::Parser
|
|
398
398
|
/.*?/m
|
399
399
|
end
|
400
400
|
|
401
|
-
if @content =~ %r%((?>/\*.*?\*/\s+))
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
401
|
+
comment = if @content =~ %r%((?>/\*.*?\*/\s+))
|
402
|
+
rb_define_attr\((?:\s*#{var_name},)?\s*
|
403
|
+
"#{attr_name}"\s*,
|
404
|
+
#{rw}\)\s*;%xm then
|
405
|
+
$1
|
406
|
+
elsif @content =~ %r%((?>/\*.*?\*/\s+))
|
407
|
+
rb_attr\(\s*#{var_name}\s*,
|
408
|
+
\s*#{attr_name}\s*,
|
409
|
+
#{rw},.*?\)\s*;%xm then
|
410
|
+
$1
|
411
|
+
elsif @content =~ %r%Document-attr:\s#{attr_name}\s*?\n
|
412
|
+
((?>.*?\*/))%xm then
|
413
|
+
$1
|
414
|
+
else
|
415
|
+
''
|
416
|
+
end
|
417
|
+
|
418
|
+
RDoc::Comment.new comment, @top_level
|
417
419
|
end
|
418
420
|
|
419
421
|
##
|
@@ -425,11 +427,11 @@ class RDoc::Parser::C < RDoc::Parser
|
|
425
427
|
((?:(?:static|SWIGINTERN)\s+)?
|
426
428
|
(?:intern\s+)?VALUE\s+#{meth_name}
|
427
429
|
\s*(\([^)]*\))([^;]|$))%xm then
|
428
|
-
comment = $1
|
430
|
+
comment = RDoc::Comment.new $1, @top_level
|
429
431
|
body = $2
|
430
432
|
offset = $~.offset(2).first
|
431
433
|
|
432
|
-
|
434
|
+
comment.remove_private if comment
|
433
435
|
|
434
436
|
# try to find the whole body
|
435
437
|
body = $& if /#{Regexp.escape body}[^(]*?\{.*?^\}/m =~ file_content
|
@@ -443,6 +445,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
443
445
|
override_comment = find_override_comment class_name, meth_obj
|
444
446
|
comment = override_comment if override_comment
|
445
447
|
|
448
|
+
comment.normalize
|
446
449
|
find_modifiers comment, meth_obj if comment
|
447
450
|
|
448
451
|
#meth_obj.params = params
|
@@ -450,24 +453,26 @@ class RDoc::Parser::C < RDoc::Parser
|
|
450
453
|
tk = RDoc::RubyToken::Token.new nil, 1, 1
|
451
454
|
tk.set_text body
|
452
455
|
meth_obj.add_token tk
|
453
|
-
meth_obj.comment =
|
456
|
+
meth_obj.comment = comment
|
454
457
|
meth_obj.offset = offset
|
455
458
|
meth_obj.line = file_content[0, offset].count("\n") + 1
|
456
459
|
|
457
460
|
body
|
458
461
|
when %r%((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+#{meth_name}\s+(\w+))%m then
|
459
|
-
comment = $1
|
462
|
+
comment = RDoc::Comment.new $1, @top_level
|
460
463
|
body = $2
|
461
464
|
offset = $~.offset(2).first
|
462
465
|
|
463
466
|
find_body class_name, $3, meth_obj, file_content, true
|
467
|
+
|
468
|
+
comment.normalize
|
464
469
|
find_modifiers comment, meth_obj
|
465
470
|
|
466
471
|
meth_obj.start_collecting_tokens
|
467
472
|
tk = RDoc::RubyToken::Token.new nil, 1, 1
|
468
473
|
tk.set_text body
|
469
474
|
meth_obj.add_token tk
|
470
|
-
meth_obj.comment =
|
475
|
+
meth_obj.comment = comment
|
471
476
|
meth_obj.offset = offset
|
472
477
|
meth_obj.line = file_content[0, offset].count("\n") + 1
|
473
478
|
|
@@ -486,8 +491,9 @@ class RDoc::Parser::C < RDoc::Parser
|
|
486
491
|
comment = find_override_comment class_name, meth_obj
|
487
492
|
|
488
493
|
if comment then
|
494
|
+
comment.normalize
|
489
495
|
find_modifiers comment, meth_obj
|
490
|
-
meth_obj.comment =
|
496
|
+
meth_obj.comment = comment
|
491
497
|
|
492
498
|
''
|
493
499
|
else
|
@@ -551,17 +557,18 @@ class RDoc::Parser::C < RDoc::Parser
|
|
551
557
|
comment = $1.sub(%r%Document-(?:class|module):\s+#{class_name}%, '')
|
552
558
|
elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
|
553
559
|
(?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
|
554
|
-
comment = $1
|
560
|
+
comment = "/*\n#{$1}"
|
555
561
|
elsif @content =~ %r%((?>/\*.*?\*/\s+))
|
556
562
|
([\w\.\s]+\s* = \s+)?rb_define_(class|module).*?"(#{class_name})"%xm then
|
557
563
|
comment = $1
|
564
|
+
else
|
565
|
+
comment = ''
|
558
566
|
end
|
559
567
|
|
560
|
-
|
568
|
+
comment = RDoc::Comment.new comment, @top_level
|
569
|
+
comment.normalize
|
561
570
|
|
562
|
-
|
563
|
-
|
564
|
-
comment = look_for_directives_in class_mod, comment
|
571
|
+
look_for_directives_in class_mod, comment
|
565
572
|
|
566
573
|
class_mod.add_comment comment, @top_level
|
567
574
|
end
|
@@ -571,79 +578,33 @@ class RDoc::Parser::C < RDoc::Parser
|
|
571
578
|
# comment or in the matching Document- section.
|
572
579
|
|
573
580
|
def find_const_comment(type, const_name, class_name = nil)
|
574
|
-
if @content =~ %r%((?>^\s*/\*.*?\*/\s+))
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
581
|
+
comment = if @content =~ %r%((?>^\s*/\*.*?\*/\s+))
|
582
|
+
rb_define_#{type}\((?:\s*(\w+),)?\s*
|
583
|
+
"#{const_name}"\s*,
|
584
|
+
.*?\)\s*;%xmi then
|
585
|
+
$1
|
586
|
+
elsif class_name and
|
587
|
+
@content =~ %r%Document-(?:const|global|variable):\s
|
588
|
+
#{class_name}::#{const_name}
|
589
|
+
\s*?\n((?>.*?\*/))%xm then
|
590
|
+
"/*\n#{$1}"
|
591
|
+
elsif @content =~ %r%Document-(?:const|global|variable):
|
592
|
+
\s#{const_name}
|
593
|
+
\s*?\n((?>.*?\*/))%xm then
|
594
|
+
"/*\n#{$1}"
|
595
|
+
else
|
596
|
+
''
|
597
|
+
end
|
598
|
+
|
599
|
+
RDoc::Comment.new comment, @top_level
|
590
600
|
end
|
591
601
|
|
592
602
|
##
|
593
603
|
# Handles modifiers in +comment+ and updates +meth_obj+ as appropriate.
|
594
|
-
#
|
595
|
-
# If <tt>:nodoc:</tt> is found, documentation on +meth_obj+ is suppressed.
|
596
|
-
#
|
597
|
-
# If <tt>:yields:</tt> is followed by an argument list it is used for the
|
598
|
-
# #block_params of +meth_obj+.
|
599
|
-
#
|
600
|
-
# If the comment block contains a <tt>call-seq:</tt> section like:
|
601
|
-
#
|
602
|
-
# call-seq:
|
603
|
-
# ARGF.readlines(sep=$/) -> array
|
604
|
-
# ARGF.readlines(limit) -> array
|
605
|
-
# ARGF.readlines(sep, limit) -> array
|
606
|
-
#
|
607
|
-
# ARGF.to_a(sep=$/) -> array
|
608
|
-
# ARGF.to_a(limit) -> array
|
609
|
-
# ARGF.to_a(sep, limit) -> array
|
610
|
-
#
|
611
|
-
# it is used for the parameters of +meth_obj+.
|
612
604
|
|
613
605
|
def find_modifiers comment, meth_obj
|
614
|
-
|
615
|
-
|
616
|
-
# with ARGF at the same indent, but that are after the first description
|
617
|
-
# paragraph.
|
618
|
-
|
619
|
-
if comment =~ /call-seq:(.*?(?:\S|\*\/?).*?)^\s*(?:\*\/?)?\s*$/m then
|
620
|
-
all_start, all_stop = $~.offset(0)
|
621
|
-
seq_start, seq_stop = $~.offset(1)
|
622
|
-
|
623
|
-
# we get the following lines that start with the leading word at the
|
624
|
-
# same indent, even if they have blank lines before
|
625
|
-
if $1 =~ /(^\s*\*?\s*\n)+^(\s*\*?\s*\w+)/m then
|
626
|
-
leading = $2 # ' * ARGF' in the example above
|
627
|
-
re = %r%
|
628
|
-
\A(
|
629
|
-
(^\s*\*?\s*\n)+
|
630
|
-
(^#{Regexp.escape leading}.*?\n)+
|
631
|
-
)+
|
632
|
-
^\s*\*?\s*$
|
633
|
-
%xm
|
634
|
-
if comment[seq_stop..-1] =~ re then
|
635
|
-
all_stop = seq_stop + $~.offset(0).last
|
636
|
-
seq_stop = seq_stop + $~.offset(1).last
|
637
|
-
end
|
638
|
-
end
|
639
|
-
|
640
|
-
seq = comment[seq_start..seq_stop]
|
641
|
-
seq.gsub!(/^(\s*\*?\s*?)(\S|\n)/m, '\2')
|
642
|
-
comment.slice! all_start...all_stop
|
643
|
-
meth_obj.call_seq = seq
|
644
|
-
elsif comment.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '') then
|
645
|
-
meth_obj.call_seq = $1.strip
|
646
|
-
end
|
606
|
+
comment.normalize
|
607
|
+
comment.extract_call_seq meth_obj
|
647
608
|
|
648
609
|
look_for_directives_in meth_obj, comment
|
649
610
|
end
|
@@ -655,11 +616,18 @@ class RDoc::Parser::C < RDoc::Parser
|
|
655
616
|
name = Regexp.escape meth_obj.name
|
656
617
|
prefix = Regexp.escape meth_obj.name_prefix
|
657
618
|
|
658
|
-
if @content =~ %r%Document-method
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
619
|
+
comment = if @content =~ %r%Document-method:
|
620
|
+
\s+#{class_name}#{prefix}#{name}
|
621
|
+
\s*?\n((?>.*?\*/))%xm then
|
622
|
+
"/*#{$1}"
|
623
|
+
elsif @content =~ %r%Document-method:
|
624
|
+
\s#{name}\s*?\n((?>.*?\*/))%xm then
|
625
|
+
"/*#{$1}"
|
626
|
+
end
|
627
|
+
|
628
|
+
return unless comment
|
629
|
+
|
630
|
+
RDoc::Comment.new comment, @top_level
|
663
631
|
end
|
664
632
|
|
665
633
|
##
|
@@ -680,7 +648,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
680
648
|
return unless class_obj
|
681
649
|
|
682
650
|
comment = find_attr_comment var_name, attr_name
|
683
|
-
comment
|
651
|
+
comment.normalize
|
684
652
|
|
685
653
|
name = attr_name.gsub(/rb_intern\("([^"]+)"\)/, '\1')
|
686
654
|
|
@@ -770,14 +738,13 @@ class RDoc::Parser::C < RDoc::Parser
|
|
770
738
|
end
|
771
739
|
|
772
740
|
comment = find_const_comment type, const_name, class_name
|
773
|
-
comment
|
774
|
-
comment = normalize_comment comment
|
741
|
+
comment.normalize
|
775
742
|
|
776
743
|
# In the case of rb_define_const, the definition and comment are in
|
777
744
|
# "/* definition: comment */" form. The literal ':' and '\' characters
|
778
745
|
# can be escaped with a backslash.
|
779
746
|
if type.downcase == 'const' then
|
780
|
-
elements = comment.split ':'
|
747
|
+
elements = comment.text.split ':'
|
781
748
|
|
782
749
|
if elements.nil? or elements.empty? then
|
783
750
|
con = RDoc::Constant.new const_name, definition, comment
|
@@ -799,6 +766,8 @@ class RDoc::Parser::C < RDoc::Parser
|
|
799
766
|
"#{$1}#{elements.last.lstrip}"
|
800
767
|
end
|
801
768
|
|
769
|
+
new_comment = RDoc::Comment.new new_comment, @top_level
|
770
|
+
|
802
771
|
con = RDoc::Constant.new const_name, new_definition, new_comment
|
803
772
|
end
|
804
773
|
else
|
@@ -1020,14 +989,6 @@ class RDoc::Parser::C < RDoc::Parser
|
|
1020
989
|
@content.gsub!(%r%//.*rb_define_%, '//')
|
1021
990
|
end
|
1022
991
|
|
1023
|
-
##
|
1024
|
-
# Removes private comments from +comment+
|
1025
|
-
|
1026
|
-
def remove_private_comments(comment)
|
1027
|
-
comment.gsub!(/\/?\*--\n(.*?)\/?\*\+\+/m, '')
|
1028
|
-
comment.sub!(/\/?\*--\n.*/m, '')
|
1029
|
-
end
|
1030
|
-
|
1031
992
|
##
|
1032
993
|
# Extracts the classes, modules, methods, attributes, constants and aliases
|
1033
994
|
# from a C file and returns an RDoc::TopLevel for this file
|