rdoc 3.10.pre.3 → 3.10
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/History.rdoc +35 -4
- data/LEGAL.rdoc +27 -0
- data/Manifest.txt +1 -0
- data/Rakefile +4 -0
- data/TODO.rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +36 -4
- data/lib/rdoc.rb +21 -2
- data/lib/rdoc/any_method.rb +6 -2
- data/lib/rdoc/class_module.rb +4 -0
- data/lib/rdoc/context.rb +1 -2
- data/lib/rdoc/generator/template/darkfish/class.rhtml +4 -2
- data/lib/rdoc/include.rb +19 -7
- data/lib/rdoc/markup/parser.rb +21 -4
- data/lib/rdoc/markup/to_html_crossref.rb +2 -0
- data/lib/rdoc/method_attr.rb +15 -2
- data/lib/rdoc/options.rb +229 -5
- data/lib/rdoc/parser/c.rb +19 -6
- data/lib/rdoc/parser/ruby.rb +3 -5
- data/lib/rdoc/rdoc.rb +33 -6
- data/lib/rdoc/ruby_lex.rb +4 -3
- data/lib/rdoc/test_case.rb +17 -0
- data/lib/rdoc/top_level.rb +8 -0
- data/test/test_rdoc_any_method.rb +9 -0
- data/test/test_rdoc_attr.rb +13 -0
- data/test/test_rdoc_class_module.rb +13 -0
- data/test/test_rdoc_context.rb +10 -10
- data/test/test_rdoc_cross_reference.rb +8 -8
- data/test/test_rdoc_markup_parser.rb +58 -0
- data/test/test_rdoc_markup_to_html_crossref.rb +16 -8
- data/test/test_rdoc_method_attr.rb +13 -0
- data/test/test_rdoc_options.rb +161 -13
- data/test/test_rdoc_parser_c.rb +15 -0
- data/test/test_rdoc_rdoc.rb +35 -16
- data/test/test_rdoc_ruby_lex.rb +19 -0
- data/test/test_rdoc_top_level.rb +9 -0
- metadata +5 -5
- metadata.gz.sig +0 -0
data/lib/rdoc/method_attr.rb
CHANGED
@@ -268,14 +268,27 @@ class RDoc::MethodAttr < RDoc::CodeObject
|
|
268
268
|
# Full method/attribute name including namespace
|
269
269
|
|
270
270
|
def full_name
|
271
|
-
@full_name
|
271
|
+
@full_name ||= "#{parent_name}#{pretty_name}"
|
272
272
|
end
|
273
273
|
|
274
274
|
##
|
275
275
|
# '::' for a class method/attribute, '#' for an instance method.
|
276
276
|
|
277
277
|
def name_prefix
|
278
|
-
singleton ? '::' : '#'
|
278
|
+
@singleton ? '::' : '#'
|
279
|
+
end
|
280
|
+
|
281
|
+
##
|
282
|
+
# Name for output to HTML. For class methods the full name with a "." is
|
283
|
+
# used like +SomeClass.method_name+. For instance methods the class name is
|
284
|
+
# used if +context+ does not match the parent.
|
285
|
+
#
|
286
|
+
# This is to help prevent people from using :: to call class methods.
|
287
|
+
|
288
|
+
def output_name context
|
289
|
+
return "#{name_prefix}#{@name}" if context == parent
|
290
|
+
|
291
|
+
"#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
|
279
292
|
end
|
280
293
|
|
281
294
|
##
|
data/lib/rdoc/options.rb
CHANGED
@@ -2,6 +2,29 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
##
|
4
4
|
# RDoc::Options handles the parsing and storage of options
|
5
|
+
#
|
6
|
+
# == Saved Options
|
7
|
+
#
|
8
|
+
# You can save some options like the markup format in the
|
9
|
+
# <tt>.rdoc_options</tt> file in your gem. The easiest way to do this is:
|
10
|
+
#
|
11
|
+
# rdoc --markup tomdoc --write-options
|
12
|
+
#
|
13
|
+
# Which will automatically create the file and fill it with the options you
|
14
|
+
# specified.
|
15
|
+
#
|
16
|
+
# The following options will not be saved since they interfere with the user's
|
17
|
+
# preferences or with the normal operation of RDoc:
|
18
|
+
#
|
19
|
+
# * +--coverage-report+
|
20
|
+
# * +--dry-run+
|
21
|
+
# * +--encoding+
|
22
|
+
# * +--force-update+
|
23
|
+
# * +--format+
|
24
|
+
# * +--pipe+
|
25
|
+
# * +--quiet+
|
26
|
+
# * +--template+
|
27
|
+
# * +--verbose+
|
5
28
|
|
6
29
|
class RDoc::Options
|
7
30
|
|
@@ -22,11 +45,43 @@ class RDoc::Options
|
|
22
45
|
'--ri-system' => 'Ruby installers use other techniques',
|
23
46
|
}
|
24
47
|
|
48
|
+
##
|
49
|
+
# RDoc options ignored (or handled specially) by --write-options
|
50
|
+
|
51
|
+
SPECIAL = %w[
|
52
|
+
coverage_report
|
53
|
+
dry_run
|
54
|
+
encoding
|
55
|
+
files
|
56
|
+
force_output
|
57
|
+
force_update
|
58
|
+
generator
|
59
|
+
generator_name
|
60
|
+
generator_options
|
61
|
+
generators
|
62
|
+
op_dir
|
63
|
+
option_parser
|
64
|
+
pipe
|
65
|
+
rdoc_include
|
66
|
+
static_path
|
67
|
+
stylesheet_url
|
68
|
+
template
|
69
|
+
template_dir
|
70
|
+
update_output_dir
|
71
|
+
verbosity
|
72
|
+
write_options
|
73
|
+
]
|
74
|
+
|
25
75
|
##
|
26
76
|
# Path option validator for OptionParser
|
27
77
|
|
28
78
|
Path = Object.new
|
29
79
|
|
80
|
+
##
|
81
|
+
# Array of Paths option validator for OptionParser
|
82
|
+
|
83
|
+
PathArray = Object.new
|
84
|
+
|
30
85
|
##
|
31
86
|
# Template option validator for OptionParser
|
32
87
|
|
@@ -45,7 +100,7 @@ class RDoc::Options
|
|
45
100
|
##
|
46
101
|
# Encoding of output where. This is set via --encoding.
|
47
102
|
|
48
|
-
attr_accessor :encoding
|
103
|
+
attr_accessor :encoding
|
49
104
|
|
50
105
|
##
|
51
106
|
# Files matching this pattern will be excluded
|
@@ -78,6 +133,11 @@ class RDoc::Options
|
|
78
133
|
|
79
134
|
attr_accessor :generator
|
80
135
|
|
136
|
+
##
|
137
|
+
# For #==
|
138
|
+
|
139
|
+
attr_reader :generator_name # :nodoc:
|
140
|
+
|
81
141
|
##
|
82
142
|
# Loaded generator options. Used to prevent --help from loading the same
|
83
143
|
# options multiple times.
|
@@ -185,8 +245,13 @@ class RDoc::Options
|
|
185
245
|
attr_accessor :visibility
|
186
246
|
|
187
247
|
def initialize # :nodoc:
|
248
|
+
init_ivars
|
249
|
+
end
|
250
|
+
|
251
|
+
def init_ivars # :nodoc:
|
188
252
|
@dry_run = false
|
189
253
|
@exclude = []
|
254
|
+
@files = nil
|
190
255
|
@force_output = false
|
191
256
|
@force_update = true
|
192
257
|
@generator = nil
|
@@ -203,7 +268,7 @@ class RDoc::Options
|
|
203
268
|
@rdoc_include = []
|
204
269
|
@show_hash = false
|
205
270
|
@static_path = []
|
206
|
-
@stylesheet_url = nil
|
271
|
+
@stylesheet_url = nil # TODO remove in RDoc 4
|
207
272
|
@tab_width = 8
|
208
273
|
@template = nil
|
209
274
|
@template_dir = nil
|
@@ -212,15 +277,67 @@ class RDoc::Options
|
|
212
277
|
@verbosity = 1
|
213
278
|
@visibility = :protected
|
214
279
|
@webcvs = nil
|
280
|
+
@write_options = false
|
215
281
|
|
216
282
|
if Object.const_defined? :Encoding then
|
217
283
|
@encoding = Encoding.default_external
|
218
284
|
@charset = @encoding.to_s
|
219
285
|
else
|
286
|
+
@encoding = nil
|
220
287
|
@charset = 'UTF-8'
|
221
288
|
end
|
222
289
|
end
|
223
290
|
|
291
|
+
def init_with map # :nodoc:
|
292
|
+
init_ivars
|
293
|
+
|
294
|
+
encoding = map['encoding']
|
295
|
+
@encoding = if Object.const_defined? :Encoding then
|
296
|
+
encoding ? Encoding.find(encoding) : encoding
|
297
|
+
end
|
298
|
+
|
299
|
+
@charset = map['charset']
|
300
|
+
@exclude = map['exclude']
|
301
|
+
@generator_name = map['generator_name']
|
302
|
+
@hyperlink_all = map['hyperlink_all']
|
303
|
+
@line_numbers = map['line_numbers']
|
304
|
+
@main_page = map['main_page']
|
305
|
+
@markup = map['markup']
|
306
|
+
@op_dir = map['op_dir']
|
307
|
+
@show_hash = map['show_hash']
|
308
|
+
@tab_width = map['tab_width']
|
309
|
+
@template_dir = map['template_dir']
|
310
|
+
@title = map['title']
|
311
|
+
@visibility = map['visibility']
|
312
|
+
@webcvs = map['webcvs']
|
313
|
+
|
314
|
+
@rdoc_include = sanitize_path map['rdoc_include']
|
315
|
+
@static_path = sanitize_path map['static_path']
|
316
|
+
end
|
317
|
+
|
318
|
+
def yaml_initialize tag, map # :nodoc:
|
319
|
+
init_with map
|
320
|
+
end
|
321
|
+
|
322
|
+
def == other # :nodoc:
|
323
|
+
self.class === other and
|
324
|
+
@encoding == other.encoding and
|
325
|
+
@generator_name == other.generator_name and
|
326
|
+
@hyperlink_all == other.hyperlink_all and
|
327
|
+
@line_numbers == other.line_numbers and
|
328
|
+
@main_page == other.main_page and
|
329
|
+
@markup == other.markup and
|
330
|
+
@op_dir == other.op_dir and
|
331
|
+
@rdoc_include == other.rdoc_include and
|
332
|
+
@show_hash == other.show_hash and
|
333
|
+
@static_path == other.static_path and
|
334
|
+
@tab_width == other.tab_width and
|
335
|
+
@template == other.template and
|
336
|
+
@title == other.title and
|
337
|
+
@visibility == other.visibility and
|
338
|
+
@webcvs == other.webcvs
|
339
|
+
end
|
340
|
+
|
224
341
|
##
|
225
342
|
# Check that the files on the command line exist
|
226
343
|
|
@@ -261,6 +378,24 @@ class RDoc::Options
|
|
261
378
|
@title ||= string
|
262
379
|
end
|
263
380
|
|
381
|
+
##
|
382
|
+
# For dumping YAML
|
383
|
+
|
384
|
+
def encode_with coder # :nodoc:
|
385
|
+
encoding = @encoding ? @encoding.name : nil
|
386
|
+
|
387
|
+
coder.add 'encoding', encoding
|
388
|
+
coder.add 'static_path', sanitize_path(@static_path)
|
389
|
+
coder.add 'rdoc_include', sanitize_path(@rdoc_include)
|
390
|
+
|
391
|
+
ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
|
392
|
+
ivars -= SPECIAL
|
393
|
+
|
394
|
+
ivars.sort.each do |ivar|
|
395
|
+
coder.add ivar, instance_variable_get("@#{ivar}")
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
264
399
|
##
|
265
400
|
# Completes any unfinished option setup business such as filtering for
|
266
401
|
# existent files, creating a regexp for #exclude and setting a default
|
@@ -321,7 +456,7 @@ class RDoc::Options
|
|
321
456
|
##
|
322
457
|
# Parses command line options.
|
323
458
|
|
324
|
-
def parse
|
459
|
+
def parse argv
|
325
460
|
ignore_invalid = true
|
326
461
|
|
327
462
|
argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
|
@@ -382,7 +517,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
382
517
|
template_dir = template_dir_for template
|
383
518
|
|
384
519
|
unless template_dir then
|
385
|
-
|
520
|
+
$stderr.puts "could not find template #{template}"
|
386
521
|
nil
|
387
522
|
else
|
388
523
|
[template, template_dir]
|
@@ -397,6 +532,20 @@ Usage: #{opt.program_name} [options] [names...]
|
|
397
532
|
directory
|
398
533
|
end
|
399
534
|
|
535
|
+
opt.accept PathArray do |directories,|
|
536
|
+
directories = if directories then
|
537
|
+
directories.split(',').map { |d| d unless d.empty? }
|
538
|
+
end
|
539
|
+
|
540
|
+
directories.map do |directory|
|
541
|
+
directory = File.expand_path directory
|
542
|
+
|
543
|
+
raise OptionParser::InvalidArgument unless File.exist? directory
|
544
|
+
|
545
|
+
directory
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
400
549
|
opt.separator nil
|
401
550
|
opt.separator "Parsing options:"
|
402
551
|
opt.separator nil
|
@@ -511,7 +660,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
511
660
|
|
512
661
|
opt.separator nil
|
513
662
|
|
514
|
-
opt.on("--include=DIRECTORIES", "-i",
|
663
|
+
opt.on("--include=DIRECTORIES", "-i", PathArray,
|
515
664
|
"Set (or add to) the list of directories to",
|
516
665
|
"be searched when satisfying :include:",
|
517
666
|
"requests. Can be used more than once.") do |value|
|
@@ -666,32 +815,52 @@ Usage: #{opt.program_name} [options] [names...]
|
|
666
815
|
opt.separator "Generic options:"
|
667
816
|
opt.separator nil
|
668
817
|
|
818
|
+
opt.on("--write-options",
|
819
|
+
"Write .rdoc_options to the current",
|
820
|
+
"directory with the given options. Not all",
|
821
|
+
"options will be used. See RDoc::Options",
|
822
|
+
"for details.") do |value|
|
823
|
+
@write_options = true
|
824
|
+
end
|
825
|
+
|
826
|
+
opt.separator nil
|
827
|
+
|
669
828
|
opt.on("--[no-]dry-run",
|
670
829
|
"Don't write any files") do |value|
|
671
830
|
@dry_run = value
|
672
831
|
end
|
673
832
|
|
833
|
+
opt.separator nil
|
834
|
+
|
674
835
|
opt.on("-D", "--[no-]debug",
|
675
836
|
"Displays lots on internal stuff.") do |value|
|
676
837
|
$DEBUG_RDOC = value
|
677
838
|
end
|
678
839
|
|
840
|
+
opt.separator nil
|
841
|
+
|
679
842
|
opt.on("--[no-]ignore-invalid",
|
680
843
|
"Ignore invalid options and continue",
|
681
844
|
"(default true).") do |value|
|
682
845
|
ignore_invalid = value
|
683
846
|
end
|
684
847
|
|
848
|
+
opt.separator nil
|
849
|
+
|
685
850
|
opt.on("--quiet", "-q",
|
686
851
|
"Don't show progress as we parse.") do |value|
|
687
852
|
@verbosity = 0
|
688
853
|
end
|
689
854
|
|
855
|
+
opt.separator nil
|
856
|
+
|
690
857
|
opt.on("--verbose", "-v",
|
691
858
|
"Display extra progress as RDoc parses") do |value|
|
692
859
|
@verbosity = 2
|
693
860
|
end
|
694
861
|
|
862
|
+
opt.separator nil
|
863
|
+
|
695
864
|
opt.on("--help",
|
696
865
|
"Display this help") do
|
697
866
|
RDoc::RDoc::GENERATORS.each_key do |generator|
|
@@ -757,6 +926,13 @@ Usage: #{opt.program_name} [options] [names...]
|
|
757
926
|
@files = argv.dup
|
758
927
|
|
759
928
|
finish
|
929
|
+
|
930
|
+
if @write_options then
|
931
|
+
write_options
|
932
|
+
exit
|
933
|
+
end
|
934
|
+
|
935
|
+
self
|
760
936
|
end
|
761
937
|
|
762
938
|
##
|
@@ -773,6 +949,20 @@ Usage: #{opt.program_name} [options] [names...]
|
|
773
949
|
@verbosity = bool ? 0 : 1
|
774
950
|
end
|
775
951
|
|
952
|
+
##
|
953
|
+
# Removes directories from +path+ that are outside the current directory
|
954
|
+
|
955
|
+
def sanitize_path path
|
956
|
+
require 'pathname'
|
957
|
+
dot = Pathname.new('.').expand_path
|
958
|
+
|
959
|
+
path.reject do |item|
|
960
|
+
path = Pathname.new(item).expand_path
|
961
|
+
relative = path.relative_path_from(dot).to_s
|
962
|
+
relative.start_with? '..'
|
963
|
+
end
|
964
|
+
end
|
965
|
+
|
776
966
|
##
|
777
967
|
# Set up an output generator for the named +generator_name+.
|
778
968
|
#
|
@@ -812,5 +1002,39 @@ Usage: #{opt.program_name} [options] [names...]
|
|
812
1002
|
end
|
813
1003
|
end
|
814
1004
|
|
1005
|
+
##
|
1006
|
+
# This is compatibility code for syck
|
1007
|
+
|
1008
|
+
def to_yaml opts = {} # :nodoc:
|
1009
|
+
return super if YAML.const_defined?(:ENGINE) and not YAML::ENGINE.syck?
|
1010
|
+
|
1011
|
+
YAML.quick_emit self, opts do |out|
|
1012
|
+
out.map taguri, to_yaml_style do |map|
|
1013
|
+
encode_with map
|
1014
|
+
end
|
1015
|
+
end
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
##
|
1019
|
+
# Displays a warning using Kernel#warn if we're being verbose
|
1020
|
+
|
1021
|
+
def warn message
|
1022
|
+
super message if @verbosity > 1
|
1023
|
+
end
|
1024
|
+
|
1025
|
+
##
|
1026
|
+
# Writes the YAML file .rdoc_options to the current directory containing the
|
1027
|
+
# parsed options.
|
1028
|
+
|
1029
|
+
def write_options
|
1030
|
+
RDoc.load_yaml
|
1031
|
+
|
1032
|
+
open '.rdoc_options', 'w' do |io|
|
1033
|
+
io.set_encoding Encoding::UTF_8 if Object.const_defined? :Encoding
|
1034
|
+
|
1035
|
+
YAML.dump self, io
|
1036
|
+
end
|
1037
|
+
end
|
1038
|
+
|
815
1039
|
end
|
816
1040
|
|
data/lib/rdoc/parser/c.rb
CHANGED
@@ -165,7 +165,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
165
165
|
class_name = @known_classes[var_name]
|
166
166
|
|
167
167
|
unless class_name then
|
168
|
-
warn "Enclosing class/module %p for alias %s %s not known" % [
|
168
|
+
@options.warn "Enclosing class/module %p for alias %s %s not known" % [
|
169
169
|
var_name, new_name, old_name]
|
170
170
|
next
|
171
171
|
end
|
@@ -230,6 +230,17 @@ class RDoc::Parser::C < RDoc::Parser
|
|
230
230
|
handle_class_module(var_name, "class", class_name, parent, nil)
|
231
231
|
end
|
232
232
|
|
233
|
+
@content.scan(/([\w\.]+)\s* = \s*rb_struct_define_without_accessor\s*
|
234
|
+
\(
|
235
|
+
\s*"(\w+)", # Class name
|
236
|
+
\s*(\w+), # Parent class
|
237
|
+
\s*\w+, # Allocation function
|
238
|
+
(\s*"\w+",)* # Attributes
|
239
|
+
\s*NULL
|
240
|
+
\)/mx) do |var_name, class_name, parent|
|
241
|
+
handle_class_module(var_name, "class", class_name, parent, nil)
|
242
|
+
end
|
243
|
+
|
233
244
|
@content.scan(/(\w+)\s*=\s*boot_defclass\s*\(\s*"(\w+?)",\s*(\w+?)\s*\)/) do
|
234
245
|
|var_name, class_name, parent|
|
235
246
|
parent = nil if parent == "0"
|
@@ -485,7 +496,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
485
496
|
|
486
497
|
return body if body
|
487
498
|
|
488
|
-
warn "No definition for #{meth_name}"
|
499
|
+
@options.warn "No definition for #{meth_name}"
|
489
500
|
false
|
490
501
|
else # No body, but might still have an override comment
|
491
502
|
comment = find_override_comment class_name, meth_obj
|
@@ -497,7 +508,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
497
508
|
|
498
509
|
''
|
499
510
|
else
|
500
|
-
warn "No definition for #{meth_name}"
|
511
|
+
@options.warn "No definition for #{meth_name}"
|
501
512
|
false
|
502
513
|
end
|
503
514
|
end
|
@@ -676,7 +687,8 @@ class RDoc::Parser::C < RDoc::Parser
|
|
676
687
|
end
|
677
688
|
|
678
689
|
unless enclosure then
|
679
|
-
warn "Enclosing class/module '#{in_module}' for
|
690
|
+
@options.warn "Enclosing class/module '#{in_module}' for " \
|
691
|
+
"#{type} #{class_name} not known"
|
680
692
|
return
|
681
693
|
end
|
682
694
|
else
|
@@ -733,7 +745,7 @@ class RDoc::Parser::C < RDoc::Parser
|
|
733
745
|
class_obj = find_class var_name, class_name
|
734
746
|
|
735
747
|
unless class_obj then
|
736
|
-
warn "Enclosing class/module #{const_name.inspect} not known"
|
748
|
+
@options.warn "Enclosing class/module #{const_name.inspect} not known"
|
737
749
|
return
|
738
750
|
end
|
739
751
|
|
@@ -820,7 +832,8 @@ class RDoc::Parser::C < RDoc::Parser
|
|
820
832
|
if File.exist? file_name then
|
821
833
|
file_content = (@@known_bodies[file_name] ||= File.read(file_name))
|
822
834
|
else
|
823
|
-
warn "unknown source #{source_file} for
|
835
|
+
@options.warn "unknown source #{source_file} for " \
|
836
|
+
"#{meth_name} in #{@file_name}"
|
824
837
|
end
|
825
838
|
else
|
826
839
|
file_content = @content
|