rdoc 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +1 -3
  3. data/RI.md +75 -75
  4. data/exe/rdoc +2 -2
  5. data/lib/rdoc/code_object/alias.rb +71 -69
  6. data/lib/rdoc/code_object/any_method.rb +305 -303
  7. data/lib/rdoc/code_object/attr.rb +150 -148
  8. data/lib/rdoc/code_object/class_module.rb +798 -792
  9. data/lib/rdoc/code_object/constant.rb +175 -173
  10. data/lib/rdoc/code_object/context/section.rb +142 -138
  11. data/lib/rdoc/code_object/context.rb +926 -958
  12. data/lib/rdoc/code_object/extend.rb +7 -5
  13. data/lib/rdoc/code_object/include.rb +7 -5
  14. data/lib/rdoc/code_object/method_attr.rb +326 -319
  15. data/lib/rdoc/code_object/mixin.rb +97 -95
  16. data/lib/rdoc/code_object/normal_class.rb +77 -78
  17. data/lib/rdoc/code_object/normal_module.rb +61 -59
  18. data/lib/rdoc/code_object/require.rb +23 -39
  19. data/lib/rdoc/code_object/single_class.rb +21 -19
  20. data/lib/rdoc/code_object/top_level.rb +212 -219
  21. data/lib/rdoc/code_object.rb +305 -303
  22. data/lib/rdoc/comment.rb +275 -273
  23. data/lib/rdoc/cross_reference.rb +192 -190
  24. data/lib/rdoc/encoding.rb +105 -103
  25. data/lib/rdoc/erb_partial.rb +13 -11
  26. data/lib/rdoc/erbio.rb +29 -27
  27. data/lib/rdoc/generator/aliki.rb +161 -153
  28. data/lib/rdoc/generator/darkfish.rb +645 -635
  29. data/lib/rdoc/generator/json_index.rb +233 -229
  30. data/lib/rdoc/generator/markup.rb +164 -146
  31. data/lib/rdoc/generator/pot/message_extractor.rb +57 -51
  32. data/lib/rdoc/generator/pot/po.rb +52 -51
  33. data/lib/rdoc/generator/pot/po_entry.rb +138 -132
  34. data/lib/rdoc/generator/pot.rb +85 -81
  35. data/lib/rdoc/generator/ri.rb +23 -19
  36. data/lib/rdoc/generator/template/aliki/DESIGN.md +6 -4
  37. data/lib/rdoc/generator/template/aliki/_footer.rhtml +1 -1
  38. data/lib/rdoc/generator/template/aliki/_head.rhtml +10 -10
  39. data/lib/rdoc/generator/template/aliki/_header.rhtml +29 -44
  40. data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +4 -4
  41. data/lib/rdoc/generator/template/aliki/css/rdoc.css +207 -178
  42. data/lib/rdoc/generator/template/aliki/js/aliki.js +60 -84
  43. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +1 -1
  44. data/lib/rdoc/generator.rb +48 -46
  45. data/lib/rdoc/i18n/locale.rb +99 -95
  46. data/lib/rdoc/i18n/text.rb +109 -105
  47. data/lib/rdoc/i18n.rb +7 -5
  48. data/lib/rdoc/markdown/byte_runtime.rb +80 -0
  49. data/lib/rdoc/markdown.kpeg +15 -11
  50. data/lib/rdoc/markdown.rb +40 -47
  51. data/lib/rdoc/markup/block_quote.rb +12 -8
  52. data/lib/rdoc/markup/document.rb +127 -123
  53. data/lib/rdoc/markup/formatter.rb +219 -215
  54. data/lib/rdoc/markup/include.rb +33 -29
  55. data/lib/rdoc/markup/indented_paragraph.rb +37 -33
  56. data/lib/rdoc/markup/inline_parser.rb +281 -277
  57. data/lib/rdoc/markup/list.rb +80 -88
  58. data/lib/rdoc/markup/list_item.rb +73 -85
  59. data/lib/rdoc/markup/paragraph.rb +23 -19
  60. data/lib/rdoc/markup/parser.rb +501 -497
  61. data/lib/rdoc/markup/pre_process.rb +283 -279
  62. data/lib/rdoc/markup/raw.rb +2 -2
  63. data/lib/rdoc/markup/rule.rb +16 -12
  64. data/lib/rdoc/markup/to_ansi.rb +143 -139
  65. data/lib/rdoc/markup/to_bs.rb +72 -68
  66. data/lib/rdoc/markup/to_html.rb +594 -565
  67. data/lib/rdoc/markup/to_html_crossref.rb +234 -230
  68. data/lib/rdoc/markup/to_html_snippet.rb +232 -227
  69. data/lib/rdoc/markup/to_joined_paragraph.rb +36 -32
  70. data/lib/rdoc/markup/to_label.rb +63 -59
  71. data/lib/rdoc/markup/to_markdown.rb +212 -208
  72. data/lib/rdoc/markup/to_rdoc.rb +336 -332
  73. data/lib/rdoc/markup/to_table_of_contents.rb +66 -62
  74. data/lib/rdoc/markup/to_test.rb +60 -56
  75. data/lib/rdoc/markup/to_tt_only.rb +84 -80
  76. data/lib/rdoc/markup/verbatim.rb +62 -58
  77. data/lib/rdoc/markup.rb +198 -196
  78. data/lib/rdoc/options.rb +1063 -1061
  79. data/lib/rdoc/parser/c.rb +1039 -1037
  80. data/lib/rdoc/parser/changelog.rb +319 -315
  81. data/lib/rdoc/parser/markdown.rb +17 -13
  82. data/lib/rdoc/parser/rbs.rb +239 -235
  83. data/lib/rdoc/parser/rd.rb +17 -13
  84. data/lib/rdoc/parser/ruby.rb +1245 -1124
  85. data/lib/rdoc/parser/ruby_colorizer.rb +263 -213
  86. data/lib/rdoc/parser/simple.rb +31 -27
  87. data/lib/rdoc/parser/text.rb +12 -8
  88. data/lib/rdoc/parser.rb +228 -220
  89. data/lib/rdoc/rbs_helper.rb +1 -1
  90. data/lib/rdoc/rd/inline.rb +57 -53
  91. data/lib/rdoc/rd.rb +90 -88
  92. data/lib/rdoc/rdoc.rb +500 -491
  93. data/lib/rdoc/ri/driver.rb +1140 -1135
  94. data/lib/rdoc/ri/formatter.rb +7 -3
  95. data/lib/rdoc/ri/paths.rb +140 -136
  96. data/lib/rdoc/ri/servlet.rb +354 -350
  97. data/lib/rdoc/ri/store.rb +4 -2
  98. data/lib/rdoc/ri/task.rb +55 -51
  99. data/lib/rdoc/ri.rb +14 -12
  100. data/lib/rdoc/rubygems_hook.rb +183 -181
  101. data/lib/rdoc/server.rb +349 -347
  102. data/lib/rdoc/stats/normal.rb +46 -42
  103. data/lib/rdoc/stats/quiet.rb +39 -35
  104. data/lib/rdoc/stats/verbose.rb +35 -31
  105. data/lib/rdoc/stats.rb +365 -363
  106. data/lib/rdoc/store.rb +888 -902
  107. data/lib/rdoc/task.rb +260 -256
  108. data/lib/rdoc/text.rb +135 -133
  109. data/lib/rdoc/token_stream.rb +101 -93
  110. data/lib/rdoc/tom_doc.rb +203 -201
  111. data/lib/rdoc/version.rb +1 -1
  112. metadata +4 -5
  113. data/lib/rdoc/markdown/literals.kpeg +0 -21
  114. data/lib/rdoc/markdown/literals.rb +0 -454
data/lib/rdoc/options.rb CHANGED
@@ -2,730 +2,731 @@
2
2
  require 'optparse'
3
3
  require 'pathname'
4
4
 
5
- ##
6
- # RDoc::Options handles the parsing and storage of options
7
- #
8
- # == Saved Options
9
- #
10
- # You can save some options like the markup format in the
11
- # <tt>.rdoc_options</tt> file in your gem. The easiest way to do this is:
12
- #
13
- # rdoc --markup tomdoc --write-options
14
- #
15
- # Which will automatically create the file and fill it with the options you
16
- # specified.
17
- #
18
- # The following options will not be saved since they interfere with the user's
19
- # preferences or with the normal operation of RDoc:
20
- #
21
- # * +--coverage-report+
22
- # * +--dry-run+
23
- # * +--encoding+
24
- # * +--force-update+
25
- # * +--format+
26
- # * +--pipe+
27
- # * +--quiet+
28
- # * +--template+
29
- # * +--verbose+
30
- #
31
- # == Custom Options
32
- #
33
- # Generators can hook into RDoc::Options to add generator-specific command
34
- # line options.
35
- #
36
- # When <tt>--format</tt> is encountered in ARGV, RDoc calls ::setup_options on
37
- # the generator class to add extra options to the option parser. Options for
38
- # custom generators must occur after <tt>--format</tt>. <tt>rdoc --help</tt>
39
- # will list options for all installed generators.
40
- #
41
- # Example:
42
- #
43
- # class RDoc::Generator::Spellcheck
44
- # RDoc::RDoc.add_generator self
45
- #
46
- # def self.setup_options rdoc_options
47
- # op = rdoc_options.option_parser
48
- #
49
- # op.on('--spell-dictionary DICTIONARY',
50
- # RDoc::Options::Path) do |dictionary|
51
- # rdoc_options.spell_dictionary = dictionary
52
- # end
53
- # end
54
- # end
55
- #
56
- # Of course, RDoc::Options does not respond to +spell_dictionary+ by default
57
- # so you will need to add it:
58
- #
59
- # class RDoc::Options
60
- #
61
- # ##
62
- # # The spell dictionary used by the spell-checking plugin.
63
- #
64
- # attr_accessor :spell_dictionary
65
- #
66
- # end
67
- #
68
- # == Option Validators
69
- #
70
- # OptionParser validators will validate and cast user input values. In
71
- # addition to the validators that ship with OptionParser (String, Integer,
72
- # Float, TrueClass, FalseClass, Array, Regexp, Date, Time, URI, etc.),
73
- # RDoc::Options adds Path, PathArray and Template.
74
-
75
- class RDoc::Options
76
-
5
+ module RDoc
77
6
  ##
78
- # RDoc options ignored (or handled specially) by --write-options
79
-
80
- SPECIAL = %w[
81
- coverage_report
82
- dry_run
83
- encoding
84
- files
85
- force_output
86
- force_update
87
- generator
88
- generator_name
89
- generator_options
90
- generators
91
- locale
92
- op_dir
93
- page_dir
94
- option_parser
95
- pipe
96
- rdoc_include
97
- root
98
- server_port
99
- static_path
100
- template
101
- template_dir
102
- update_output_dir
103
- verbosity
104
- write_options
105
- ]
7
+ # RDoc::Options handles the parsing and storage of options
8
+ #
9
+ # == Saved Options
10
+ #
11
+ # You can save some options like the markup format in the
12
+ # <tt>.rdoc_options</tt> file in your gem. The easiest way to do this is:
13
+ #
14
+ # rdoc --markup tomdoc --write-options
15
+ #
16
+ # Which will automatically create the file and fill it with the options you
17
+ # specified.
18
+ #
19
+ # The following options will not be saved since they interfere with the user's
20
+ # preferences or with the normal operation of RDoc:
21
+ #
22
+ # * +--coverage-report+
23
+ # * +--dry-run+
24
+ # * +--encoding+
25
+ # * +--force-update+
26
+ # * +--format+
27
+ # * +--pipe+
28
+ # * +--quiet+
29
+ # * +--template+
30
+ # * +--verbose+
31
+ #
32
+ # == Custom Options
33
+ #
34
+ # Generators can hook into RDoc::Options to add generator-specific command
35
+ # line options.
36
+ #
37
+ # When <tt>--format</tt> is encountered in ARGV, RDoc calls ::setup_options on
38
+ # the generator class to add extra options to the option parser. Options for
39
+ # custom generators must occur after <tt>--format</tt>. <tt>rdoc --help</tt>
40
+ # will list options for all installed generators.
41
+ #
42
+ # Example:
43
+ #
44
+ # class RDoc::Generator::Spellcheck
45
+ # RDoc::RDoc.add_generator self
46
+ #
47
+ # def self.setup_options rdoc_options
48
+ # op = rdoc_options.option_parser
49
+ #
50
+ # op.on('--spell-dictionary DICTIONARY',
51
+ # RDoc::Options::Path) do |dictionary|
52
+ # rdoc_options.spell_dictionary = dictionary
53
+ # end
54
+ # end
55
+ # end
56
+ #
57
+ # Of course, RDoc::Options does not respond to +spell_dictionary+ by default
58
+ # so you will need to add it:
59
+ #
60
+ # class RDoc::Options
61
+ #
62
+ # ##
63
+ # # The spell dictionary used by the spell-checking plugin.
64
+ #
65
+ # attr_accessor :spell_dictionary
66
+ #
67
+ # end
68
+ #
69
+ # == Option Validators
70
+ #
71
+ # OptionParser validators will validate and cast user input values. In
72
+ # addition to the validators that ship with OptionParser (String, Integer,
73
+ # Float, TrueClass, FalseClass, Array, Regexp, Date, Time, URI, etc.),
74
+ # RDoc::Options adds Path, PathArray and Template.
75
+
76
+ class Options
77
+
78
+ ##
79
+ # RDoc options ignored (or handled specially) by --write-options
80
+
81
+ SPECIAL = %w[
82
+ coverage_report
83
+ dry_run
84
+ encoding
85
+ files
86
+ force_output
87
+ force_update
88
+ generator
89
+ generator_name
90
+ generator_options
91
+ generators
92
+ locale
93
+ op_dir
94
+ page_dir
95
+ option_parser
96
+ pipe
97
+ rdoc_include
98
+ root
99
+ server_port
100
+ static_path
101
+ template
102
+ template_dir
103
+ update_output_dir
104
+ verbosity
105
+ write_options
106
+ ]
106
107
 
107
- ##
108
- # Option validator for OptionParser that matches a directory that exists on
109
- # the filesystem.
108
+ ##
109
+ # Option validator for OptionParser that matches a directory that exists on
110
+ # the filesystem.
110
111
 
111
- Directory = Object.new
112
+ Directory = Object.new
112
113
 
113
- ##
114
- # Option validator for OptionParser that matches a file or directory that
115
- # exists on the filesystem.
114
+ ##
115
+ # Option validator for OptionParser that matches a file or directory that
116
+ # exists on the filesystem.
116
117
 
117
- Path = Object.new
118
+ Path = Object.new
118
119
 
119
- ##
120
- # Option validator for OptionParser that matches a comma-separated list of
121
- # files or directories that exist on the filesystem.
120
+ ##
121
+ # Option validator for OptionParser that matches a comma-separated list of
122
+ # files or directories that exist on the filesystem.
122
123
 
123
- PathArray = Object.new
124
+ PathArray = Object.new
124
125
 
125
- ##
126
- # Option validator for OptionParser that matches a template directory for an
127
- # installed generator that lives in
128
- # <tt>"rdoc/generator/template/#{template_name}"</tt>
126
+ ##
127
+ # Option validator for OptionParser that matches a template directory for an
128
+ # installed generator that lives in
129
+ # <tt>"rdoc/generator/template/#{template_name}"</tt>
129
130
 
130
- Template = Object.new
131
+ Template = Object.new
131
132
 
132
- ##
133
- # Character-set for HTML output. #encoding is preferred over #charset
133
+ ##
134
+ # Character-set for HTML output. #encoding is preferred over #charset
134
135
 
135
- attr_accessor :charset
136
+ attr_accessor :charset
136
137
 
137
- ##
138
- # If true, RDoc will not write any files.
138
+ ##
139
+ # If true, RDoc will not write any files.
139
140
 
140
- attr_accessor :dry_run
141
+ attr_accessor :dry_run
141
142
 
142
- ##
143
- # The output encoding. All input files will be transcoded to this encoding.
144
- #
145
- # The default encoding is UTF-8. This is set via --encoding.
143
+ ##
144
+ # The output encoding. All input files will be transcoded to this encoding.
145
+ #
146
+ # The default encoding is UTF-8. This is set via --encoding.
146
147
 
147
- attr_accessor :encoding
148
+ attr_accessor :encoding
148
149
 
149
- ##
150
- # Files matching this pattern will be excluded
150
+ ##
151
+ # Files matching this pattern will be excluded
151
152
 
152
- attr_writer :exclude
153
+ attr_writer :exclude
153
154
 
154
- ##
155
- # The list of files to be processed
155
+ ##
156
+ # The list of files to be processed
156
157
 
157
- attr_accessor :files
158
+ attr_accessor :files
158
159
 
159
- ##
160
- # Create the output even if the output directory does not look
161
- # like an rdoc output directory
160
+ ##
161
+ # Create the output even if the output directory does not look
162
+ # like an rdoc output directory
162
163
 
163
- attr_accessor :force_output
164
+ attr_accessor :force_output
164
165
 
165
- ##
166
- # Scan newer sources than the flag file if true.
166
+ ##
167
+ # Scan newer sources than the flag file if true.
167
168
 
168
- attr_accessor :force_update
169
+ attr_accessor :force_update
169
170
 
170
- ##
171
- # Formatter to mark up text with
171
+ ##
172
+ # Formatter to mark up text with
172
173
 
173
- attr_accessor :formatter
174
+ attr_accessor :formatter
174
175
 
175
- ##
176
- # Description of the output generator (set with the <tt>--format</tt> option)
176
+ ##
177
+ # Description of the output generator (set with the <tt>--format</tt> option)
177
178
 
178
- attr_accessor :generator
179
+ attr_accessor :generator
179
180
 
180
- ##
181
- # For #==
181
+ ##
182
+ # For #==
182
183
 
183
- attr_reader :generator_name # :nodoc:
184
+ attr_reader :generator_name # :nodoc:
184
185
 
185
- ##
186
- # Loaded generator options. Used to prevent --help from loading the same
187
- # options multiple times.
186
+ ##
187
+ # Loaded generator options. Used to prevent --help from loading the same
188
+ # options multiple times.
188
189
 
189
- attr_accessor :generator_options
190
+ attr_accessor :generator_options
190
191
 
191
- ##
192
- # Old rdoc behavior: hyperlink all words that match a method name,
193
- # even if not preceded by '#' or '::'
192
+ ##
193
+ # Old rdoc behavior: hyperlink all words that match a method name,
194
+ # even if not preceded by '#' or '::'
194
195
 
195
- attr_accessor :hyperlink_all
196
+ attr_accessor :hyperlink_all
196
197
 
197
- ##
198
- # Include line numbers in the source code
198
+ ##
199
+ # Include line numbers in the source code
199
200
 
200
- attr_accessor :line_numbers
201
+ attr_accessor :line_numbers
201
202
 
202
- ##
203
- # The output locale.
203
+ ##
204
+ # The output locale.
204
205
 
205
- attr_accessor :locale
206
+ attr_accessor :locale
206
207
 
207
- ##
208
- # The directory where locale data live.
208
+ ##
209
+ # The directory where locale data live.
209
210
 
210
- attr_accessor :locale_dir
211
+ attr_accessor :locale_dir
211
212
 
212
- ##
213
- # Name of the file, class or module to display in the initial index page (if
214
- # not specified the first file we encounter is used)
213
+ ##
214
+ # Name of the file, class or module to display in the initial index page (if
215
+ # not specified the first file we encounter is used)
215
216
 
216
- attr_accessor :main_page
217
-
218
- ##
219
- # The markup format.
220
- # One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
221
- # See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
222
- attr_accessor :markup
217
+ attr_accessor :main_page
223
218
 
224
- ##
225
- # If true, only report on undocumented files
219
+ ##
220
+ # The markup format.
221
+ # One of: +rdoc+ (the default), +markdown+, +rd+, +tomdoc+.
222
+ # See {Markup Formats}[rdoc-ref:RDoc::Markup@Markup+Formats].
223
+ attr_accessor :markup
226
224
 
227
- attr_accessor :coverage_report
225
+ ##
226
+ # If true, only report on undocumented files
228
227
 
229
- ##
230
- # The name of the output directory
228
+ attr_accessor :coverage_report
231
229
 
232
- attr_accessor :op_dir
230
+ ##
231
+ # The name of the output directory
233
232
 
234
- ##
235
- # The OptionParser for this instance
233
+ attr_accessor :op_dir
236
234
 
237
- attr_accessor :option_parser
235
+ ##
236
+ # The OptionParser for this instance
238
237
 
239
- ##
240
- # Output heading decorations?
241
- attr_accessor :output_decoration
238
+ attr_accessor :option_parser
242
239
 
243
- ##
244
- # Directory where guides, FAQ, and other pages not associated with a class
245
- # live. You may leave this unset if these are at the root of your project.
240
+ ##
241
+ # Output heading decorations?
242
+ attr_accessor :output_decoration
246
243
 
247
- attr_accessor :page_dir
244
+ ##
245
+ # Directory where guides, FAQ, and other pages not associated with a class
246
+ # live. You may leave this unset if these are at the root of your project.
248
247
 
249
- ##
250
- # Is RDoc in pipe mode?
248
+ attr_accessor :page_dir
251
249
 
252
- attr_accessor :pipe
250
+ ##
251
+ # Is RDoc in pipe mode?
253
252
 
254
- ##
255
- # Array of directories to search for files to satisfy an :include:
253
+ attr_accessor :pipe
256
254
 
257
- attr_accessor :rdoc_include
255
+ ##
256
+ # Array of directories to search for files to satisfy an :include:
258
257
 
259
- ##
260
- # Root of the source documentation will be generated for. Set this when
261
- # building documentation outside the source directory. Defaults to the
262
- # current directory.
258
+ attr_accessor :rdoc_include
263
259
 
264
- attr_accessor :root
260
+ ##
261
+ # Root of the source documentation will be generated for. Set this when
262
+ # building documentation outside the source directory. Defaults to the
263
+ # current directory.
265
264
 
266
- ##
267
- # Include the '#' at the front of hyperlinked instance method names
265
+ attr_accessor :root
268
266
 
269
- attr_accessor :show_hash
267
+ ##
268
+ # Include the '#' at the front of hyperlinked instance method names
270
269
 
271
- ##
272
- # Directory to copy static files from
270
+ attr_accessor :show_hash
273
271
 
274
- attr_accessor :static_path
272
+ ##
273
+ # Directory to copy static files from
275
274
 
276
- ##
277
- # The number of columns in a tab
275
+ attr_accessor :static_path
278
276
 
279
- attr_accessor :tab_width
277
+ ##
278
+ # The number of columns in a tab
280
279
 
281
- ##
282
- # Template to be used when generating output
280
+ attr_accessor :tab_width
283
281
 
284
- attr_accessor :template
282
+ ##
283
+ # Template to be used when generating output
285
284
 
286
- ##
287
- # Directory the template lives in
285
+ attr_accessor :template
288
286
 
289
- attr_accessor :template_dir
287
+ ##
288
+ # Directory the template lives in
290
289
 
291
- ##
292
- # Additional template stylesheets
290
+ attr_accessor :template_dir
293
291
 
294
- attr_accessor :template_stylesheets
292
+ ##
293
+ # Additional template stylesheets
295
294
 
296
- ##
297
- # Documentation title
295
+ attr_accessor :template_stylesheets
298
296
 
299
- attr_accessor :title
297
+ ##
298
+ # Documentation title
300
299
 
301
- ##
302
- # Should RDoc update the timestamps in the output dir?
300
+ attr_accessor :title
303
301
 
304
- attr_accessor :update_output_dir
302
+ ##
303
+ # Should RDoc update the timestamps in the output dir?
305
304
 
306
- ##
307
- # Verbosity, zero means quiet
305
+ attr_accessor :update_output_dir
308
306
 
309
- attr_accessor :verbosity
307
+ ##
308
+ # Verbosity, zero means quiet
310
309
 
311
- ##
312
- # Warn if rdoc-ref links can't be resolved
313
- # Default is +true+
310
+ attr_accessor :verbosity
314
311
 
315
- attr_accessor :warn_missing_rdoc_ref
312
+ ##
313
+ # Warn if rdoc-ref links can't be resolved
314
+ # Default is +true+
316
315
 
317
- ##
318
- # URL of web cvs frontend
316
+ attr_accessor :warn_missing_rdoc_ref
319
317
 
320
- attr_accessor :webcvs
318
+ ##
319
+ # URL of web cvs frontend
321
320
 
322
- ##
323
- # Minimum visibility of a documented method. One of +:public+, +:protected+,
324
- # +:private+ or +:nodoc+.
325
- #
326
- # The +:nodoc+ visibility ignores all directives related to visibility. The
327
- # other visibilities may be overridden on a per-method basis with the :doc:
328
- # directive.
321
+ attr_accessor :webcvs
329
322
 
330
- attr_reader :visibility
323
+ ##
324
+ # Minimum visibility of a documented method. One of +:public+, +:protected+,
325
+ # +:private+ or +:nodoc+.
326
+ #
327
+ # The +:nodoc+ visibility ignores all directives related to visibility. The
328
+ # other visibilities may be overridden on a per-method basis with the :doc:
329
+ # directive.
331
330
 
332
- ##
333
- # When set to a port number, starts a live-reloading server instead of
334
- # writing files. Defaults to +false+ (no server). Set via
335
- # <tt>--server[=PORT]</tt>.
331
+ attr_reader :visibility
336
332
 
337
- attr_reader :server_port
333
+ ##
334
+ # When set to a port number, starts a live-reloading server instead of
335
+ # writing files. Defaults to +false+ (no server). Set via
336
+ # <tt>--server[=PORT]</tt>.
338
337
 
339
- ##
340
- # Indicates if files of test suites should be skipped
341
- attr_accessor :skip_tests
338
+ attr_reader :server_port
342
339
 
343
- ##
344
- # Embed mixin methods, attributes, and constants into class documentation. Set via
345
- # +--[no-]embed-mixins+ (Default is +false+.)
346
- attr_accessor :embed_mixins
340
+ ##
341
+ # Indicates if files of test suites should be skipped
342
+ attr_accessor :skip_tests
347
343
 
348
- ##
349
- # Exclude the default patterns as well if true.
350
- attr_reader :apply_default_exclude
344
+ ##
345
+ # Embed mixin methods, attributes, and constants into class documentation. Set via
346
+ # +--[no-]embed-mixins+ (Default is +false+.)
347
+ attr_accessor :embed_mixins
351
348
 
352
- ##
353
- # Words to be ignored in autolink cross-references
354
- attr_accessor :autolink_excluded_words
349
+ ##
350
+ # Exclude the default patterns as well if true.
351
+ attr_reader :apply_default_exclude
355
352
 
356
- ##
357
- # The prefix to use for class and module page paths
353
+ ##
354
+ # Words to be ignored in autolink cross-references
355
+ attr_accessor :autolink_excluded_words
358
356
 
359
- attr_accessor :class_module_path_prefix
357
+ ##
358
+ # The prefix to use for class and module page paths
360
359
 
361
- ##
362
- # The prefix to use for file page paths
360
+ attr_accessor :class_module_path_prefix
363
361
 
364
- attr_accessor :file_path_prefix
362
+ ##
363
+ # The prefix to use for file page paths
365
364
 
366
- ##
367
- # The preferred root URL for the documentation
365
+ attr_accessor :file_path_prefix
368
366
 
369
- attr_accessor :canonical_root
367
+ ##
368
+ # The preferred root URL for the documentation
370
369
 
371
- ##
372
- # Custom footer content configuration for themes that support it.
373
- # Currently only supported by the Aliki theme.
374
- #
375
- # A hash where keys are column titles and values are hashes of link text => URL pairs.
376
- # Each column will be displayed in the upper footer section.
377
- #
378
- # Example:
379
- # {
380
- # "DOCUMENTATION" => {"Home" => "/index.html", "Guide" => "/guide.html"},
381
- # "RESOURCES" => {"RDoc" => "https://ruby.github.io/rdoc/", "GitHub" => "https://github.com/ruby/rdoc"}
382
- # }
370
+ attr_accessor :canonical_root
383
371
 
384
- attr_accessor :footer_content
372
+ ##
373
+ # Custom footer content configuration for themes that support it.
374
+ # Currently only supported by the Aliki theme.
375
+ #
376
+ # A hash where keys are column titles and values are hashes of link text => URL pairs.
377
+ # Each column will be displayed in the upper footer section.
378
+ #
379
+ # Example:
380
+ # {
381
+ # "DOCUMENTATION" => {"Home" => "/index.html", "Guide" => "/guide.html"},
382
+ # "RESOURCES" => {"RDoc" => "https://ruby.github.io/rdoc/", "GitHub" => "https://github.com/ruby/rdoc"}
383
+ # }
385
384
 
386
- def initialize(loaded_options = nil) # :nodoc:
387
- init_ivars
388
- override loaded_options if loaded_options
389
- end
385
+ attr_accessor :footer_content
390
386
 
391
- DEFAULT_EXCLUDE = %w[
392
- ~\z \.orig\z \.rej\z \.bak\z
393
- \.gemspec\z
394
- ]
395
-
396
- def init_ivars # :nodoc:
397
- @autolink_excluded_words = []
398
- @dry_run = false
399
- @embed_mixins = false
400
- @exclude = []
401
- @files = nil
402
- @force_output = false
403
- @force_update = true
404
- @generator_name = "aliki"
405
- @generators = RDoc::RDoc::GENERATORS
406
- @generator_options = []
407
- @hyperlink_all = false
408
- @line_numbers = false
409
- @locale = nil
410
- @locale_name = nil
411
- @locale_dir = 'locale'
412
- @main_page = nil
413
- @markup = 'rdoc'
414
- @coverage_report = false
415
- @op_dir = nil
416
- @page_dir = nil
417
- @pipe = false
418
- @output_decoration = true
419
- @rdoc_include = []
420
- @root = Pathname(Dir.pwd)
421
- @server_port = false
422
- @show_hash = false
423
- @static_path = []
424
- @tab_width = 8
425
- @template = nil
426
- @template_dir = nil
427
- @template_stylesheets = []
428
- @title = nil
429
- @update_output_dir = true
430
- @verbosity = 1
431
- @visibility = :protected
432
- @warn_missing_rdoc_ref = true
433
- @webcvs = nil
434
- @write_options = false
435
- @encoding = Encoding::UTF_8
436
- @charset = @encoding.name
437
- @skip_tests = true
438
- @apply_default_exclude = true
439
- @class_module_path_prefix = nil
440
- @file_path_prefix = nil
441
- @canonical_root = nil
442
- @footer_content = nil
443
- end
387
+ def initialize(loaded_options = nil) # :nodoc:
388
+ init_ivars
389
+ override loaded_options if loaded_options
390
+ end
444
391
 
445
- def init_with(map) # :nodoc:
446
- init_ivars
447
-
448
- encoding = map['encoding']
449
- @encoding = encoding ? Encoding.find(encoding) : encoding
450
-
451
- @charset = map['charset']
452
- @embed_mixins = map['embed_mixins']
453
- @exclude = map['exclude']
454
- @generator_name = map['generator_name']
455
- @hyperlink_all = map['hyperlink_all']
456
- @line_numbers = map['line_numbers']
457
- @locale_name = map['locale_name']
458
- @locale_dir = map['locale_dir']
459
- @main_page = map['main_page']
460
- @markup = map['markup']
461
- @op_dir = map['op_dir']
462
- @show_hash = map['show_hash']
463
- @tab_width = map['tab_width']
464
- @template_dir = map['template_dir']
465
- @title = map['title']
466
- @visibility = map['visibility']
467
- @webcvs = map['webcvs']
468
-
469
- @apply_default_exclude = map['apply_default_exclude']
470
- @autolink_excluded_words = map['autolink_excluded_words']
471
- @footer_content = map['footer_content']
472
-
473
- @rdoc_include = sanitize_path map['rdoc_include']
474
- @static_path = sanitize_path map['static_path']
475
- end
392
+ DEFAULT_EXCLUDE = %w[
393
+ ~\z \.orig\z \.rej\z \.bak\z
394
+ \.gemspec\z
395
+ ]
396
+
397
+ def init_ivars # :nodoc:
398
+ @autolink_excluded_words = []
399
+ @dry_run = false
400
+ @embed_mixins = false
401
+ @exclude = []
402
+ @files = nil
403
+ @force_output = false
404
+ @force_update = true
405
+ @generator_name = "aliki"
406
+ @generators = RDoc::GENERATORS
407
+ @generator_options = []
408
+ @hyperlink_all = false
409
+ @line_numbers = false
410
+ @locale = nil
411
+ @locale_name = nil
412
+ @locale_dir = 'locale'
413
+ @main_page = nil
414
+ @markup = 'rdoc'
415
+ @coverage_report = false
416
+ @op_dir = nil
417
+ @page_dir = nil
418
+ @pipe = false
419
+ @output_decoration = true
420
+ @rdoc_include = []
421
+ @root = Pathname(Dir.pwd)
422
+ @server_port = false
423
+ @show_hash = false
424
+ @static_path = []
425
+ @tab_width = 8
426
+ @template = nil
427
+ @template_dir = nil
428
+ @template_stylesheets = []
429
+ @title = nil
430
+ @update_output_dir = true
431
+ @verbosity = 1
432
+ @visibility = :protected
433
+ @warn_missing_rdoc_ref = true
434
+ @webcvs = nil
435
+ @write_options = false
436
+ @encoding = ::Encoding::UTF_8
437
+ @charset = @encoding.name
438
+ @skip_tests = true
439
+ @apply_default_exclude = true
440
+ @class_module_path_prefix = nil
441
+ @file_path_prefix = nil
442
+ @canonical_root = nil
443
+ @footer_content = nil
444
+ end
476
445
 
477
- def yaml_initialize(tag, map) # :nodoc:
478
- init_with map
479
- end
446
+ def init_with(map) # :nodoc:
447
+ init_ivars
480
448
 
481
- def override(map) # :nodoc:
482
- if map.has_key?('encoding')
483
449
  encoding = map['encoding']
484
- @encoding = encoding ? Encoding.find(encoding) : encoding
485
- end
450
+ @encoding = encoding ? ::Encoding.find(encoding) : encoding
451
+
452
+ @charset = map['charset']
453
+ @embed_mixins = map['embed_mixins']
454
+ @exclude = map['exclude']
455
+ @generator_name = map['generator_name']
456
+ @hyperlink_all = map['hyperlink_all']
457
+ @line_numbers = map['line_numbers']
458
+ @locale_name = map['locale_name']
459
+ @locale_dir = map['locale_dir']
460
+ @main_page = map['main_page']
461
+ @markup = map['markup']
462
+ @op_dir = map['op_dir']
463
+ @show_hash = map['show_hash']
464
+ @tab_width = map['tab_width']
465
+ @template_dir = map['template_dir']
466
+ @title = map['title']
467
+ @visibility = map['visibility']
468
+ @webcvs = map['webcvs']
469
+
470
+ @apply_default_exclude = map['apply_default_exclude']
471
+ @autolink_excluded_words = map['autolink_excluded_words']
472
+ @footer_content = map['footer_content']
486
473
 
487
- @charset = map['charset'] if map.has_key?('charset')
488
- @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
489
- @exclude = map['exclude'] if map.has_key?('exclude')
490
- @generator_name = map['generator_name'] if map.has_key?('generator_name')
491
- @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
492
- @line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
493
- @locale_name = map['locale_name'] if map.has_key?('locale_name')
494
- @locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
495
- @main_page = map['main_page'] if map.has_key?('main_page')
496
- @markup = map['markup'] if map.has_key?('markup')
497
- @op_dir = map['op_dir'] if map.has_key?('op_dir')
498
- @page_dir = map['page_dir'] if map.has_key?('page_dir')
499
- @show_hash = map['show_hash'] if map.has_key?('show_hash')
500
- @tab_width = map['tab_width'] if map.has_key?('tab_width')
501
- @template_dir = map['template_dir'] if map.has_key?('template_dir')
502
- @title = map['title'] if map.has_key?('title')
503
- @visibility = map['visibility'] if map.has_key?('visibility')
504
- @webcvs = map['webcvs'] if map.has_key?('webcvs')
505
- @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
506
- @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
507
- @canonical_root = map['canonical_root'] if map.has_key?('canonical_root')
508
- @footer_content = map['footer_content'] if map.has_key?('footer_content')
509
-
510
- @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
511
-
512
- if map.has_key?('rdoc_include')
513
474
  @rdoc_include = sanitize_path map['rdoc_include']
514
- end
515
- if map.has_key?('static_path')
516
475
  @static_path = sanitize_path map['static_path']
517
476
  end
518
- end
519
477
 
520
- def ==(other) # :nodoc:
521
- self.class === other and
522
- @encoding == other.encoding and
523
- @embed_mixins == other.embed_mixins and
524
- @generator_name == other.generator_name and
525
- @hyperlink_all == other.hyperlink_all and
526
- @line_numbers == other.line_numbers and
527
- @locale == other.locale and
528
- @locale_dir == other.locale_dir and
529
- @main_page == other.main_page and
530
- @markup == other.markup and
531
- @op_dir == other.op_dir and
532
- @rdoc_include == other.rdoc_include and
533
- @show_hash == other.show_hash and
534
- @static_path == other.static_path and
535
- @tab_width == other.tab_width and
536
- @template == other.template and
537
- @title == other.title and
538
- @visibility == other.visibility and
539
- @webcvs == other.webcvs and
540
- @apply_default_exclude == other.apply_default_exclude and
541
- @autolink_excluded_words == other.autolink_excluded_words
542
- end
478
+ def yaml_initialize(tag, map) # :nodoc:
479
+ init_with map
480
+ end
543
481
 
544
- ##
545
- # Check that the files on the command line exist
482
+ def override(map) # :nodoc:
483
+ if map.has_key?('encoding')
484
+ encoding = map['encoding']
485
+ @encoding = encoding ? ::Encoding.find(encoding) : encoding
486
+ end
487
+
488
+ @charset = map['charset'] if map.has_key?('charset')
489
+ @embed_mixins = map['embed_mixins'] if map.has_key?('embed_mixins')
490
+ @exclude = map['exclude'] if map.has_key?('exclude')
491
+ @generator_name = map['generator_name'] if map.has_key?('generator_name')
492
+ @hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
493
+ @line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
494
+ @locale_name = map['locale_name'] if map.has_key?('locale_name')
495
+ @locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
496
+ @main_page = map['main_page'] if map.has_key?('main_page')
497
+ @markup = map['markup'] if map.has_key?('markup')
498
+ @op_dir = map['op_dir'] if map.has_key?('op_dir')
499
+ @page_dir = map['page_dir'] if map.has_key?('page_dir')
500
+ @show_hash = map['show_hash'] if map.has_key?('show_hash')
501
+ @tab_width = map['tab_width'] if map.has_key?('tab_width')
502
+ @template_dir = map['template_dir'] if map.has_key?('template_dir')
503
+ @title = map['title'] if map.has_key?('title')
504
+ @visibility = map['visibility'] if map.has_key?('visibility')
505
+ @webcvs = map['webcvs'] if map.has_key?('webcvs')
506
+ @autolink_excluded_words = map['autolink_excluded_words'] if map.has_key?('autolink_excluded_words')
507
+ @apply_default_exclude = map['apply_default_exclude'] if map.has_key?('apply_default_exclude')
508
+ @canonical_root = map['canonical_root'] if map.has_key?('canonical_root')
509
+ @footer_content = map['footer_content'] if map.has_key?('footer_content')
510
+
511
+ @warn_missing_rdoc_ref = map['warn_missing_rdoc_ref'] if map.has_key?('warn_missing_rdoc_ref')
512
+
513
+ if map.has_key?('rdoc_include')
514
+ @rdoc_include = sanitize_path map['rdoc_include']
515
+ end
516
+ if map.has_key?('static_path')
517
+ @static_path = sanitize_path map['static_path']
518
+ end
519
+ end
520
+
521
+ def ==(other) # :nodoc:
522
+ self.class === other and
523
+ @encoding == other.encoding and
524
+ @embed_mixins == other.embed_mixins and
525
+ @generator_name == other.generator_name and
526
+ @hyperlink_all == other.hyperlink_all and
527
+ @line_numbers == other.line_numbers and
528
+ @locale == other.locale and
529
+ @locale_dir == other.locale_dir and
530
+ @main_page == other.main_page and
531
+ @markup == other.markup and
532
+ @op_dir == other.op_dir and
533
+ @rdoc_include == other.rdoc_include and
534
+ @show_hash == other.show_hash and
535
+ @static_path == other.static_path and
536
+ @tab_width == other.tab_width and
537
+ @template == other.template and
538
+ @title == other.title and
539
+ @visibility == other.visibility and
540
+ @webcvs == other.webcvs and
541
+ @apply_default_exclude == other.apply_default_exclude and
542
+ @autolink_excluded_words == other.autolink_excluded_words
543
+ end
544
+
545
+ ##
546
+ # Check that the files on the command line exist
546
547
 
547
- def check_files
548
- @files.delete_if do |file|
549
- if File.exist? file then
550
- if File.readable? file then
551
- false
548
+ def check_files
549
+ @files.delete_if do |file|
550
+ if File.exist? file
551
+ if File.readable? file
552
+ false
553
+ else
554
+ warn "file '#{file}' not readable"
555
+
556
+ true
557
+ end
552
558
  else
553
- warn "file '#{file}' not readable"
559
+ warn "file '#{file}' not found"
554
560
 
555
561
  true
556
562
  end
557
- else
558
- warn "file '#{file}' not found"
559
-
560
- true
561
563
  end
562
564
  end
563
- end
564
565
 
565
- ##
566
- # Ensure only one generator is loaded
566
+ ##
567
+ # Ensure only one generator is loaded
567
568
 
568
- def check_generator
569
- if @generator then
570
- raise OptionParser::InvalidOption,
571
- "generator already set to #{@generator_name}"
569
+ def check_generator
570
+ if @generator
571
+ raise OptionParser::InvalidOption,
572
+ "generator already set to #{@generator_name}"
573
+ end
572
574
  end
573
- end
574
575
 
575
- ##
576
- # Set the title, but only if not already set. Used to set the title
577
- # from a source file, so that a title set from the command line
578
- # will have the priority.
576
+ ##
577
+ # Set the title, but only if not already set. Used to set the title
578
+ # from a source file, so that a title set from the command line
579
+ # will have the priority.
579
580
 
580
- def default_title=(string)
581
- @title ||= string
582
- end
581
+ def default_title=(string)
582
+ @title ||= string
583
+ end
583
584
 
584
- ##
585
- # For dumping YAML
585
+ ##
586
+ # For dumping YAML
586
587
 
587
- def to_yaml(*options) # :nodoc:
588
- encoding = @encoding ? @encoding.name : nil
588
+ def to_yaml(*options) # :nodoc:
589
+ encoding = @encoding ? @encoding.name : nil
589
590
 
590
- yaml = {}
591
- yaml['encoding'] = encoding
592
- yaml['static_path'] = sanitize_path(@static_path)
593
- yaml['rdoc_include'] = sanitize_path(@rdoc_include)
594
- yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
591
+ yaml = {}
592
+ yaml['encoding'] = encoding
593
+ yaml['static_path'] = sanitize_path(@static_path)
594
+ yaml['rdoc_include'] = sanitize_path(@rdoc_include)
595
+ yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
595
596
 
596
- ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
597
- ivars -= SPECIAL
597
+ ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
598
+ ivars -= SPECIAL
598
599
 
599
- ivars.sort.each do |ivar|
600
- yaml[ivar] = instance_variable_get("@#{ivar}")
601
- end
600
+ ivars.sort.each do |ivar|
601
+ yaml[ivar] = instance_variable_get("@#{ivar}")
602
+ end
602
603
 
603
- if yaml.respond_to?(:to_yaml)
604
- yaml.to_yaml
605
- else
606
- RDoc.yaml_serializer.dump(yaml)
604
+ if yaml.respond_to?(:to_yaml)
605
+ yaml.to_yaml
606
+ else
607
+ ::RDoc.yaml_serializer.dump(yaml)
608
+ end
607
609
  end
608
- end
609
610
 
610
- ##
611
- # Create a regexp for #exclude
612
-
613
- def exclude
614
- if @exclude.nil? or Regexp === @exclude then
615
- # done, #finish is being re-run
616
- @exclude
617
- elsif !@apply_default_exclude and @exclude.empty? then
618
- nil
619
- else
620
- exclude = @exclude
621
- exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
622
- Regexp.new(exclude.join("|"))
611
+ ##
612
+ # Create a regexp for #exclude
613
+
614
+ def exclude
615
+ if @exclude.nil? or Regexp === @exclude
616
+ # done, #finish is being re-run
617
+ @exclude
618
+ elsif !@apply_default_exclude and @exclude.empty?
619
+ nil
620
+ else
621
+ exclude = @exclude
622
+ exclude |= DEFAULT_EXCLUDE if @apply_default_exclude
623
+ Regexp.new(exclude.join("|"))
624
+ end
623
625
  end
624
- end
625
626
 
626
- ##
627
- # Completes any unfinished option setup business such as filtering for
628
- # existent files, creating a regexp for #exclude and setting a default
629
- # #template.
627
+ ##
628
+ # Completes any unfinished option setup business such as filtering for
629
+ # existent files, creating a regexp for #exclude and setting a default
630
+ # #template.
630
631
 
631
- def finish
632
- if @write_options then
633
- write_options
634
- exit
635
- end
632
+ def finish
633
+ if @write_options
634
+ write_options
635
+ exit
636
+ end
636
637
 
637
- @op_dir ||= 'doc'
638
+ @op_dir ||= 'doc'
638
639
 
639
- root = @root.to_s
640
- if @rdoc_include.empty? || !@rdoc_include.include?(root)
641
- @rdoc_include << root
642
- end
640
+ root = @root.to_s
641
+ if @rdoc_include.empty? || !@rdoc_include.include?(root)
642
+ @rdoc_include << root
643
+ end
643
644
 
644
- @exclude = self.exclude
645
+ @exclude = self.exclude
645
646
 
646
- finish_page_dir
647
+ finish_page_dir
647
648
 
648
- check_files
649
+ check_files
649
650
 
650
- # If no template was specified, use the default template for the output
651
- # formatter
651
+ # If no template was specified, use the default template for the output
652
+ # formatter
652
653
 
653
- unless @template then
654
- @template = @generator_name
655
- @template_dir = template_dir_for @template
656
- end
654
+ unless @template
655
+ @template = @generator_name
656
+ @template_dir = template_dir_for @template
657
+ end
657
658
 
658
- if @locale_name
659
- @locale = RDoc::I18n::Locale[@locale_name]
660
- @locale.load(@locale_dir)
661
- else
662
- @locale = nil
659
+ if @locale_name
660
+ @locale = I18n::Locale[@locale_name]
661
+ @locale.load(@locale_dir)
662
+ else
663
+ @locale = nil
664
+ end
665
+
666
+ self
663
667
  end
664
668
 
665
- self
666
- end
669
+ ##
670
+ # Fixes the page_dir to be relative to the root_dir and adds the page_dir to
671
+ # the files list.
667
672
 
668
- ##
669
- # Fixes the page_dir to be relative to the root_dir and adds the page_dir to
670
- # the files list.
673
+ def finish_page_dir
674
+ return unless @page_dir
671
675
 
672
- def finish_page_dir
673
- return unless @page_dir
676
+ @files << @page_dir
674
677
 
675
- @files << @page_dir
678
+ page_dir = Pathname(@page_dir)
679
+ begin
680
+ page_dir = page_dir.expand_path.relative_path_from @root
681
+ rescue ArgumentError
682
+ # On Windows, sometimes crosses different drive letters.
683
+ page_dir = page_dir.expand_path
684
+ end
676
685
 
677
- page_dir = Pathname(@page_dir)
678
- begin
679
- page_dir = page_dir.expand_path.relative_path_from @root
680
- rescue ArgumentError
681
- # On Windows, sometimes crosses different drive letters.
682
- page_dir = page_dir.expand_path
686
+ @page_dir = page_dir
683
687
  end
684
688
 
685
- @page_dir = page_dir
686
- end
687
-
688
- ##
689
- # Returns a properly-space list of generators and their descriptions.
689
+ ##
690
+ # Returns a properly-space list of generators and their descriptions.
690
691
 
691
- def generator_descriptions
692
- lengths = []
692
+ def generator_descriptions
693
+ lengths = []
693
694
 
694
- generators = RDoc::RDoc::GENERATORS.map do |name, generator|
695
- lengths << name.length
695
+ generators = RDoc::GENERATORS.map do |name, generator|
696
+ lengths << name.length
696
697
 
697
- description = generator::DESCRIPTION if
698
- generator.const_defined? :DESCRIPTION
698
+ description = generator::DESCRIPTION if
699
+ generator.const_defined? :DESCRIPTION
699
700
 
700
- [name, description]
701
- end
701
+ [name, description]
702
+ end
702
703
 
703
- longest = lengths.max
704
+ longest = lengths.max
704
705
 
705
- generators.sort.map do |name, description|
706
- if description then
707
- " %-*s - %s" % [longest, name, description]
708
- else
709
- " #{name}"
710
- end
711
- end.join "\n"
712
- end
706
+ generators.sort.map do |name, description|
707
+ if description
708
+ " %-*s - %s" % [longest, name, description]
709
+ else
710
+ " #{name}"
711
+ end
712
+ end.join "\n"
713
+ end
713
714
 
714
- ##
715
- # Parses command line options.
715
+ ##
716
+ # Parses command line options.
716
717
 
717
- def parse(argv)
718
- ignore_invalid = true
718
+ def parse(argv)
719
+ ignore_invalid = true
719
720
 
720
- argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
721
+ argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
721
722
 
722
- opts = OptionParser.new do |opt|
723
- @option_parser = opt
724
- opt.program_name = File.basename $0
725
- opt.version = RDoc::VERSION
726
- opt.release = nil
727
- opt.summary_indent = ' ' * 4
728
- opt.banner = <<-EOF
723
+ opts = OptionParser.new do |opt|
724
+ @option_parser = opt
725
+ opt.program_name = File.basename $0
726
+ opt.version = VERSION
727
+ opt.release = nil
728
+ opt.summary_indent = ' ' * 4
729
+ opt.banner = <<-EOF
729
730
  Usage: #{opt.program_name} [options] [names...]
730
731
 
731
732
  Files are parsed, and the information they contain collected, before any
@@ -753,660 +754,661 @@ Usage: #{opt.program_name} [options] [names...]
753
754
 
754
755
  EOF
755
756
 
756
- parsers = Hash.new { |h, parser| h[parser] = [] }
757
-
758
- RDoc::Parser.parsers.each do |regexp, parser|
759
- parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
760
- end
761
-
762
- parsers.sort.each do |parser, regexp|
763
- opt.banner += " - #{parser}: #{regexp.join ', '}\n"
764
- end
765
- opt.banner += " - TomDoc: Only in ruby files\n"
766
-
767
- opt.accept Template do |template|
768
- template_dir = template_dir_for template
757
+ parsers = Hash.new { |h, parser| h[parser] = [] }
769
758
 
770
- unless template_dir then
771
- $stderr.puts "could not find template #{template}"
772
- nil
773
- else
774
- [template, template_dir]
759
+ Parser.parsers.each do |regexp, parser|
760
+ parsers[parser.name.sub('RDoc::Parser::', '')] << regexp.source
775
761
  end
776
- end
777
-
778
- opt.accept Directory do |directory|
779
- directory = File.expand_path directory
780
762
 
781
- raise OptionParser::InvalidArgument unless File.directory? directory
763
+ parsers.sort.each do |parser, regexp|
764
+ opt.banner += " - #{parser}: #{regexp.join ', '}\n"
765
+ end
766
+ opt.banner += " - TomDoc: Only in ruby files\n"
782
767
 
783
- directory
784
- end
768
+ opt.accept Template do |template|
769
+ template_dir = template_dir_for template
785
770
 
786
- opt.accept Path do |path|
787
- path = File.expand_path path
771
+ unless template_dir
772
+ $stderr.puts "could not find template #{template}"
773
+ nil
774
+ else
775
+ [template, template_dir]
776
+ end
777
+ end
788
778
 
789
- raise OptionParser::InvalidArgument unless File.exist? path
779
+ opt.accept Directory do |directory|
780
+ directory = File.expand_path directory
790
781
 
791
- path
792
- end
782
+ raise OptionParser::InvalidArgument unless File.directory? directory
793
783
 
794
- opt.accept PathArray do |paths,|
795
- paths = if paths then
796
- paths.split(',').map { |d| d unless d.empty? }
797
- end
784
+ directory
785
+ end
798
786
 
799
- paths.map do |path|
787
+ opt.accept Path do |path|
800
788
  path = File.expand_path path
801
789
 
802
790
  raise OptionParser::InvalidArgument unless File.exist? path
803
791
 
804
792
  path
805
793
  end
806
- end
807
794
 
808
- opt.separator nil
809
- opt.separator "Parsing options:"
810
- opt.separator nil
795
+ opt.accept PathArray do |paths,|
796
+ paths = if paths
797
+ paths.split(',').map { |d| d unless d.empty? }
798
+ end
811
799
 
812
- opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
813
- "Specifies the output encoding. All files",
814
- "read will be converted to this encoding.",
815
- "The default encoding is UTF-8.",
816
- "--encoding is preferred over --charset") do |value|
817
- @encoding = Encoding.find value
818
- @charset = @encoding.name # may not be valid value
819
- end
800
+ paths.map do |path|
801
+ path = File.expand_path path
820
802
 
821
- opt.separator nil
803
+ raise OptionParser::InvalidArgument unless File.exist? path
822
804
 
823
- opt.on("--locale=NAME",
824
- "Specifies the output locale.") do |value|
825
- @locale_name = value
826
- end
805
+ path
806
+ end
807
+ end
827
808
 
828
- opt.on("--locale-data-dir=DIR",
829
- "Specifies the directory where locale data live.") do |value|
830
- @locale_dir = value
831
- end
809
+ opt.separator nil
810
+ opt.separator "Parsing options:"
811
+ opt.separator nil
832
812
 
833
- opt.separator nil
813
+ opt.on("--encoding=ENCODING", "-e", ::Encoding.list.map { |e| e.name },
814
+ "Specifies the output encoding. All files",
815
+ "read will be converted to this encoding.",
816
+ "The default encoding is UTF-8.",
817
+ "--encoding is preferred over --charset") do |value|
818
+ @encoding = ::Encoding.find value
819
+ @charset = @encoding.name # may not be valid value
820
+ end
834
821
 
835
- opt.on("--all", "-a",
836
- "Synonym for --visibility=private.") do |value|
837
- @visibility = :private
838
- end
822
+ opt.separator nil
839
823
 
840
- opt.separator nil
824
+ opt.on("--locale=NAME",
825
+ "Specifies the output locale.") do |value|
826
+ @locale_name = value
827
+ end
841
828
 
842
- opt.on("--exclude=PATTERN", "-x", Regexp,
843
- "Do not process files or directories",
844
- "matching PATTERN.") do |value|
845
- @exclude << value
846
- end
829
+ opt.on("--locale-data-dir=DIR",
830
+ "Specifies the directory where locale data live.") do |value|
831
+ @locale_dir = value
832
+ end
847
833
 
848
- opt.on("--[no-]apply-default-exclude",
849
- "Use default PATTERN to exclude.") do |value|
850
- @apply_default_exclude = value
851
- end
834
+ opt.separator nil
835
+
836
+ opt.on("--all", "-a",
837
+ "Synonym for --visibility=private.") do |value|
838
+ @visibility = :private
839
+ end
852
840
 
853
- opt.separator nil
841
+ opt.separator nil
854
842
 
855
- opt.on("--no-skipping-tests", nil,
856
- "Don't skip generating documentation for test and spec files") do |value|
857
- @skip_tests = false
858
- end
843
+ opt.on("--exclude=PATTERN", "-x", Regexp,
844
+ "Do not process files or directories",
845
+ "matching PATTERN.") do |value|
846
+ @exclude << value
847
+ end
859
848
 
860
- opt.separator nil
849
+ opt.on("--[no-]apply-default-exclude",
850
+ "Use default PATTERN to exclude.") do |value|
851
+ @apply_default_exclude = value
852
+ end
861
853
 
862
- opt.on("--extension=NEW=OLD", "-E",
863
- "Treat files ending with .new as if they",
864
- "ended with .old. Using '-E cgi=rb' will",
865
- "cause xxx.cgi to be parsed as a Ruby file.") do |value|
866
- new, old = value.split(/=/, 2)
854
+ opt.separator nil
867
855
 
868
- unless new and old then
869
- raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
856
+ opt.on("--no-skipping-tests", nil,
857
+ "Don't skip generating documentation for test and spec files") do |value|
858
+ @skip_tests = false
870
859
  end
871
860
 
872
- unless RDoc::Parser.alias_extension old, new then
873
- raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
861
+ opt.separator nil
862
+
863
+ opt.on("--extension=NEW=OLD", "-E",
864
+ "Treat files ending with .new as if they",
865
+ "ended with .old. Using '-E cgi=rb' will",
866
+ "cause xxx.cgi to be parsed as a Ruby file.") do |value|
867
+ new, old = value.split(/=/, 2)
868
+
869
+ unless new and old
870
+ raise OptionParser::InvalidArgument, "Invalid parameter to '-E'"
871
+ end
872
+
873
+ unless Parser.alias_extension old, new
874
+ raise OptionParser::InvalidArgument, "Unknown extension .#{old} to -E"
875
+ end
874
876
  end
875
- end
876
877
 
877
- opt.separator nil
878
+ opt.separator nil
878
879
 
879
- opt.on("--[no-]force-update", "-U",
880
- "Forces rdoc to scan all sources even if",
881
- "no files are newer than the flag file.") do |value|
882
- @force_update = value
883
- end
880
+ opt.on("--[no-]force-update", "-U",
881
+ "Forces rdoc to scan all sources even if",
882
+ "no files are newer than the flag file.") do |value|
883
+ @force_update = value
884
+ end
884
885
 
885
- opt.separator nil
886
+ opt.separator nil
886
887
 
887
- opt.on("--pipe", "-p",
888
- "Convert RDoc on stdin to HTML") do
889
- @pipe = true
890
- end
888
+ opt.on("--pipe", "-p",
889
+ "Convert RDoc on stdin to HTML") do
890
+ @pipe = true
891
+ end
891
892
 
892
- opt.separator nil
893
+ opt.separator nil
893
894
 
894
- opt.on("--tab-width=WIDTH", "-w", Integer,
895
- "Set the width of tab characters.") do |value|
896
- raise OptionParser::InvalidArgument,
897
- "#{value} is an invalid tab width" if value <= 0
898
- @tab_width = value
899
- end
895
+ opt.on("--tab-width=WIDTH", "-w", Integer,
896
+ "Set the width of tab characters.") do |value|
897
+ raise OptionParser::InvalidArgument,
898
+ "#{value} is an invalid tab width" if value <= 0
899
+ @tab_width = value
900
+ end
900
901
 
901
- opt.separator nil
902
+ opt.separator nil
902
903
 
903
- opt.on("--visibility=VISIBILITY", RDoc::VISIBILITIES + [:nodoc],
904
- "Minimum visibility to document a method.",
905
- "One of 'public', 'protected' (the default),",
906
- "'private' or 'nodoc' (show everything)") do |value|
907
- @visibility = value
908
- end
904
+ opt.on("--visibility=VISIBILITY", VISIBILITIES + [:nodoc],
905
+ "Minimum visibility to document a method.",
906
+ "One of 'public', 'protected' (the default),",
907
+ "'private' or 'nodoc' (show everything)") do |value|
908
+ @visibility = value
909
+ end
909
910
 
910
- opt.separator nil
911
+ opt.separator nil
911
912
 
912
- opt.on("--[no-]embed-mixins",
913
- "Embed mixin methods, attributes, and constants",
914
- "into class documentation. (default false)") do |value|
915
- @embed_mixins = value
916
- end
913
+ opt.on("--[no-]embed-mixins",
914
+ "Embed mixin methods, attributes, and constants",
915
+ "into class documentation. (default false)") do |value|
916
+ @embed_mixins = value
917
+ end
917
918
 
918
- opt.separator nil
919
+ opt.separator nil
919
920
 
920
- markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
921
+ markup_formats = Text::MARKUP_FORMAT.keys.sort
921
922
 
922
- opt.on("--markup=MARKUP", markup_formats,
923
- "The markup format for the named files.",
924
- "The default is rdoc. Valid values are:",
925
- markup_formats.join(', ')) do |value|
926
- @markup = value
927
- end
923
+ opt.on("--markup=MARKUP", markup_formats,
924
+ "The markup format for the named files.",
925
+ "The default is rdoc. Valid values are:",
926
+ markup_formats.join(', ')) do |value|
927
+ @markup = value
928
+ end
928
929
 
929
- opt.separator nil
930
+ opt.separator nil
930
931
 
931
- opt.on("--root=ROOT", Directory,
932
- "Root of the source tree documentation",
933
- "will be generated for. Set this when",
934
- "building documentation outside the",
935
- "source directory. Default is the",
936
- "current directory.") do |root|
937
- @root = Pathname(root)
938
- end
932
+ opt.on("--root=ROOT", Directory,
933
+ "Root of the source tree documentation",
934
+ "will be generated for. Set this when",
935
+ "building documentation outside the",
936
+ "source directory. Default is the",
937
+ "current directory.") do |root|
938
+ @root = Pathname(root)
939
+ end
939
940
 
940
- opt.separator nil
941
+ opt.separator nil
941
942
 
942
- opt.on("--page-dir=DIR", Directory,
943
- "Directory where guides, your FAQ or",
944
- "other pages not associated with a class",
945
- "live. Set this when you don't store",
946
- "such files at your project root.",
947
- "NOTE: Do not use the same file name in",
948
- "the page dir and the root of your project") do |page_dir|
949
- @page_dir = page_dir
950
- end
943
+ opt.on("--page-dir=DIR", Directory,
944
+ "Directory where guides, your FAQ or",
945
+ "other pages not associated with a class",
946
+ "live. Set this when you don't store",
947
+ "such files at your project root.",
948
+ "NOTE: Do not use the same file name in",
949
+ "the page dir and the root of your project") do |page_dir|
950
+ @page_dir = page_dir
951
+ end
951
952
 
952
- opt.separator nil
953
- opt.separator "Common generator options:"
954
- opt.separator nil
953
+ opt.separator nil
954
+ opt.separator "Common generator options:"
955
+ opt.separator nil
955
956
 
956
- opt.on("--force-output", "-O",
957
- "Forces rdoc to write the output files,",
958
- "even if the output directory exists",
959
- "and does not seem to have been created",
960
- "by rdoc.") do |value|
961
- @force_output = value
962
- end
957
+ opt.on("--force-output", "-O",
958
+ "Forces rdoc to write the output files,",
959
+ "even if the output directory exists",
960
+ "and does not seem to have been created",
961
+ "by rdoc.") do |value|
962
+ @force_output = value
963
+ end
963
964
 
964
- opt.separator nil
965
+ opt.separator nil
965
966
 
966
- generator_text = @generators.keys.map { |name| " #{name}" }.sort
967
+ generator_text = @generators.keys.map { |name| " #{name}" }.sort
967
968
 
968
- opt.on("-f", "--fmt=FORMAT", "--format=FORMAT", @generators.keys,
969
- "Set the output formatter. One of:", *generator_text) do |value|
970
- check_generator
969
+ opt.on("-f", "--fmt=FORMAT", "--format=FORMAT", @generators.keys,
970
+ "Set the output formatter. One of:", *generator_text) do |value|
971
+ check_generator
971
972
 
972
- @generator_name = value.downcase
973
- setup_generator
974
- end
973
+ @generator_name = value.downcase
974
+ setup_generator
975
+ end
975
976
 
976
- opt.separator nil
977
+ opt.separator nil
977
978
 
978
- opt.on("--include=DIRECTORIES", "-i", PathArray,
979
- "Set (or add to) the list of directories to",
980
- "be searched when satisfying :include:",
981
- "requests. Can be used more than once.") do |value|
982
- @rdoc_include.concat value.map { |dir| dir.strip }
983
- end
979
+ opt.on("--include=DIRECTORIES", "-i", PathArray,
980
+ "Set (or add to) the list of directories to",
981
+ "be searched when satisfying :include:",
982
+ "requests. Can be used more than once.") do |value|
983
+ @rdoc_include.concat value.map { |dir| dir.strip }
984
+ end
984
985
 
985
- opt.separator nil
986
+ opt.separator nil
986
987
 
987
- opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer,
988
- "Prints a report on undocumented items.",
989
- "Does not generate files.") do |value|
990
- value = 0 if value.nil? # Integer converts -C to nil
988
+ opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer,
989
+ "Prints a report on undocumented items.",
990
+ "Does not generate files.") do |value|
991
+ value = 0 if value.nil? # Integer converts -C to nil
991
992
 
992
- @coverage_report = value
993
- @force_update = true if value
994
- end
993
+ @coverage_report = value
994
+ @force_update = true if value
995
+ end
995
996
 
996
- opt.separator nil
997
+ opt.separator nil
997
998
 
998
- opt.on("--output=DIR", "--op", "-o",
999
- "Set the output directory.") do |value|
1000
- @op_dir = value
1001
- end
999
+ opt.on("--output=DIR", "--op", "-o",
1000
+ "Set the output directory.") do |value|
1001
+ @op_dir = value
1002
+ end
1002
1003
 
1003
- opt.separator nil
1004
- opt.separator 'HTML generator options:'
1005
- opt.separator nil
1004
+ opt.separator nil
1005
+ opt.separator 'HTML generator options:'
1006
+ opt.separator nil
1006
1007
 
1007
- opt.on("--charset=CHARSET", "-c",
1008
- "Specifies the output HTML character-set.",
1009
- "Use --encoding instead of --charset if",
1010
- "available.") do |value|
1011
- @charset = value
1012
- end
1008
+ opt.on("--charset=CHARSET", "-c",
1009
+ "Specifies the output HTML character-set.",
1010
+ "Use --encoding instead of --charset if",
1011
+ "available.") do |value|
1012
+ @charset = value
1013
+ end
1013
1014
 
1014
- opt.separator nil
1015
+ opt.separator nil
1015
1016
 
1016
- opt.on("--autolink-excluded-words=WORDS", Array,
1017
- "Words to be ignored in autolink cross-references") do |value|
1018
- @autolink_excluded_words.concat value
1019
- end
1017
+ opt.on("--autolink-excluded-words=WORDS", Array,
1018
+ "Words to be ignored in autolink cross-references") do |value|
1019
+ @autolink_excluded_words.concat value
1020
+ end
1020
1021
 
1021
- opt.separator nil
1022
+ opt.separator nil
1022
1023
 
1023
- opt.on("--hyperlink-all", "-A",
1024
- "Generate hyperlinks for all words that",
1025
- "correspond to known methods, even if they",
1026
- "do not start with '#' or '::' (legacy",
1027
- "behavior).") do |value|
1028
- @hyperlink_all = value
1029
- end
1024
+ opt.on("--hyperlink-all", "-A",
1025
+ "Generate hyperlinks for all words that",
1026
+ "correspond to known methods, even if they",
1027
+ "do not start with '#' or '::' (legacy",
1028
+ "behavior).") do |value|
1029
+ @hyperlink_all = value
1030
+ end
1030
1031
 
1031
- opt.separator nil
1032
+ opt.separator nil
1032
1033
 
1033
- opt.on("--main=NAME", "-m",
1034
- "NAME will be the initial page displayed.") do |value|
1035
- @main_page = value
1036
- end
1034
+ opt.on("--main=NAME", "-m",
1035
+ "NAME will be the initial page displayed.") do |value|
1036
+ @main_page = value
1037
+ end
1037
1038
 
1038
- opt.separator nil
1039
+ opt.separator nil
1039
1040
 
1040
- opt.on("--[no-]line-numbers", "-N",
1041
- "Include line numbers in the source code.",
1042
- "By default, only the number of the first",
1043
- "line is displayed, in a leading comment.") do |value|
1044
- @line_numbers = value
1045
- end
1041
+ opt.on("--[no-]line-numbers", "-N",
1042
+ "Include line numbers in the source code.",
1043
+ "By default, only the number of the first",
1044
+ "line is displayed, in a leading comment.") do |value|
1045
+ @line_numbers = value
1046
+ end
1046
1047
 
1047
- opt.separator nil
1048
+ opt.separator nil
1048
1049
 
1049
- opt.on("--show-hash", "-H",
1050
- "A name of the form #name in a comment is a",
1051
- "possible hyperlink to an instance method",
1052
- "name. When displayed, the '#' is removed",
1053
- "unless this option is specified.") do |value|
1054
- @show_hash = value
1055
- end
1050
+ opt.on("--show-hash", "-H",
1051
+ "A name of the form #name in a comment is a",
1052
+ "possible hyperlink to an instance method",
1053
+ "name. When displayed, the '#' is removed",
1054
+ "unless this option is specified.") do |value|
1055
+ @show_hash = value
1056
+ end
1056
1057
 
1057
- opt.separator nil
1058
+ opt.separator nil
1058
1059
 
1059
- opt.on("--template=NAME", "-T", Template,
1060
- "Set the template used when generating",
1061
- "output. The default depends on the",
1062
- "formatter used.") do |(template, template_dir)|
1063
- @template = template
1064
- @template_dir = template_dir
1065
- end
1060
+ opt.on("--template=NAME", "-T", Template,
1061
+ "Set the template used when generating",
1062
+ "output. The default depends on the",
1063
+ "formatter used.") do |(template, template_dir)|
1064
+ @template = template
1065
+ @template_dir = template_dir
1066
+ end
1066
1067
 
1067
- opt.separator nil
1068
+ opt.separator nil
1068
1069
 
1069
- opt.on("--template-stylesheets=FILES", PathArray,
1070
- "Set (or add to) the list of files to",
1071
- "include with the html template.") do |value|
1072
- @template_stylesheets.concat value
1073
- end
1070
+ opt.on("--template-stylesheets=FILES", PathArray,
1071
+ "Set (or add to) the list of files to",
1072
+ "include with the html template.") do |value|
1073
+ @template_stylesheets.concat value
1074
+ end
1074
1075
 
1075
- opt.separator nil
1076
+ opt.separator nil
1076
1077
 
1077
- opt.on("--title=TITLE", "-t",
1078
- "Set TITLE as the title for HTML output.") do |value|
1079
- @title = value
1080
- end
1078
+ opt.on("--title=TITLE", "-t",
1079
+ "Set TITLE as the title for HTML output.") do |value|
1080
+ @title = value
1081
+ end
1081
1082
 
1082
- opt.separator nil
1083
+ opt.separator nil
1083
1084
 
1084
- opt.on("--copy-files=PATH", Path,
1085
- "Specify a file or directory to copy static",
1086
- "files from.",
1087
- "If a file is given it will be copied into",
1088
- "the output dir. If a directory is given the",
1089
- "entire directory will be copied.",
1090
- "You can use this multiple times") do |value|
1091
- @static_path << value
1092
- end
1085
+ opt.on("--copy-files=PATH", Path,
1086
+ "Specify a file or directory to copy static",
1087
+ "files from.",
1088
+ "If a file is given it will be copied into",
1089
+ "the output dir. If a directory is given the",
1090
+ "entire directory will be copied.",
1091
+ "You can use this multiple times") do |value|
1092
+ @static_path << value
1093
+ end
1093
1094
 
1094
- opt.separator nil
1095
+ opt.separator nil
1095
1096
 
1096
- opt.on("--webcvs=URL", "-W",
1097
- "Specify a URL for linking to a web frontend",
1098
- "to CVS. If the URL contains a '\%s', the",
1099
- "name of the current file will be",
1100
- "substituted; if the URL doesn't contain a",
1101
- "'\%s', the filename will be appended to it.") do |value|
1102
- @webcvs = value
1103
- end
1097
+ opt.on("--webcvs=URL", "-W",
1098
+ "Specify a URL for linking to a web frontend",
1099
+ "to CVS. If the URL contains a '\%s', the",
1100
+ "name of the current file will be",
1101
+ "substituted; if the URL doesn't contain a",
1102
+ "'\%s', the filename will be appended to it.") do |value|
1103
+ @webcvs = value
1104
+ end
1104
1105
 
1105
- opt.separator nil
1106
- opt.separator "ri generator options:"
1107
- opt.separator nil
1108
-
1109
- opt.on("--ri", "-r",
1110
- "Generate output for use by `ri`. The files",
1111
- "are stored in the '.rdoc' directory under",
1112
- "your home directory unless overridden by a",
1113
- "subsequent --op parameter, so no special",
1114
- "privileges are needed.") do |value|
1115
- check_generator
1116
-
1117
- @generator_name = "ri"
1118
- @op_dir ||= RDoc::RI::Paths::HOMEDIR
1119
- setup_generator
1120
- end
1106
+ opt.separator nil
1107
+ opt.separator "ri generator options:"
1108
+ opt.separator nil
1109
+
1110
+ opt.on("--ri", "-r",
1111
+ "Generate output for use by `ri`. The files",
1112
+ "are stored in the '.rdoc' directory under",
1113
+ "your home directory unless overridden by a",
1114
+ "subsequent --op parameter, so no special",
1115
+ "privileges are needed.") do |value|
1116
+ check_generator
1117
+
1118
+ @generator_name = "ri"
1119
+ @op_dir ||= RI::Paths::HOMEDIR
1120
+ setup_generator
1121
+ end
1121
1122
 
1122
- opt.separator nil
1123
+ opt.separator nil
1123
1124
 
1124
- opt.on("--ri-site", "-R",
1125
- "Generate output for use by `ri`. The files",
1126
- "are stored in a site-wide directory,",
1127
- "making them accessible to others, so",
1128
- "special privileges are needed.") do |value|
1129
- check_generator
1125
+ opt.on("--ri-site", "-R",
1126
+ "Generate output for use by `ri`. The files",
1127
+ "are stored in a site-wide directory,",
1128
+ "making them accessible to others, so",
1129
+ "special privileges are needed.") do |value|
1130
+ check_generator
1130
1131
 
1131
- @generator_name = "ri"
1132
- @op_dir = RDoc::RI::Paths.site_dir
1133
- setup_generator
1134
- end
1132
+ @generator_name = "ri"
1133
+ @op_dir = RI::Paths.site_dir
1134
+ setup_generator
1135
+ end
1135
1136
 
1136
- opt.separator nil
1137
- opt.separator "Generic options:"
1138
- opt.separator nil
1137
+ opt.separator nil
1138
+ opt.separator "Generic options:"
1139
+ opt.separator nil
1139
1140
 
1140
- opt.on("--server[=PORT]", Integer,
1141
- "Start a web server to preview",
1142
- "documentation with live reload.",
1143
- "Defaults to port 4000.") do |port|
1144
- @server_port = port || 4000
1145
- end
1141
+ opt.on("--server[=PORT]", Integer,
1142
+ "Start a web server to preview",
1143
+ "documentation with live reload.",
1144
+ "Defaults to port 4000.") do |port|
1145
+ @server_port = port || 4000
1146
+ end
1146
1147
 
1147
- opt.separator nil
1148
+ opt.separator nil
1148
1149
 
1149
- opt.on("--write-options",
1150
- "Write .rdoc_options to the current",
1151
- "directory with the given options. Not all",
1152
- "options will be used. See RDoc::Options",
1153
- "for details.") do |value|
1154
- @write_options = true
1155
- end
1150
+ opt.on("--write-options",
1151
+ "Write .rdoc_options to the current",
1152
+ "directory with the given options. Not all",
1153
+ "options will be used. See RDoc::Options",
1154
+ "for details.") do |value|
1155
+ @write_options = true
1156
+ end
1156
1157
 
1157
- opt.separator nil
1158
+ opt.separator nil
1158
1159
 
1159
- opt.on("--[no-]dry-run",
1160
- "Don't write any files") do |value|
1161
- @dry_run = value
1162
- end
1160
+ opt.on("--[no-]dry-run",
1161
+ "Don't write any files") do |value|
1162
+ @dry_run = value
1163
+ end
1163
1164
 
1164
- opt.separator nil
1165
+ opt.separator nil
1165
1166
 
1166
- opt.on("-D", "--[no-]debug",
1167
- "Displays lots on internal stuff.") do |value|
1168
- $DEBUG_RDOC = value
1169
- end
1167
+ opt.on("-D", "--[no-]debug",
1168
+ "Displays lots on internal stuff.") do |value|
1169
+ $DEBUG_RDOC = value
1170
+ end
1170
1171
 
1171
- opt.separator nil
1172
+ opt.separator nil
1172
1173
 
1173
- opt.on("--warn-missing-rdoc-ref",
1174
- "Warn if rdoc-ref links can't be resolved") do |value|
1175
- @warn_missing_rdoc_ref = value
1176
- end
1174
+ opt.on("--warn-missing-rdoc-ref",
1175
+ "Warn if rdoc-ref links can't be resolved") do |value|
1176
+ @warn_missing_rdoc_ref = value
1177
+ end
1177
1178
 
1178
- opt.separator nil
1179
+ opt.separator nil
1179
1180
 
1180
- opt.on("--[no-]ignore-invalid",
1181
- "Ignore invalid options and continue",
1182
- "(default true).") do |value|
1183
- ignore_invalid = value
1184
- end
1181
+ opt.on("--[no-]ignore-invalid",
1182
+ "Ignore invalid options and continue",
1183
+ "(default true).") do |value|
1184
+ ignore_invalid = value
1185
+ end
1185
1186
 
1186
- opt.separator nil
1187
+ opt.separator nil
1187
1188
 
1188
- opt.on("--quiet", "-q",
1189
- "Don't show progress as we parse.") do |value|
1190
- @verbosity = 0
1191
- end
1189
+ opt.on("--quiet", "-q",
1190
+ "Don't show progress as we parse.") do |value|
1191
+ @verbosity = 0
1192
+ end
1192
1193
 
1193
- opt.separator nil
1194
+ opt.separator nil
1194
1195
 
1195
- opt.on("--verbose", "-V",
1196
- "Display extra progress as RDoc parses") do |value|
1197
- @verbosity = 2
1198
- end
1196
+ opt.on("--verbose", "-V",
1197
+ "Display extra progress as RDoc parses") do |value|
1198
+ @verbosity = 2
1199
+ end
1199
1200
 
1200
- opt.separator nil
1201
+ opt.separator nil
1201
1202
 
1202
- opt.on("--version", "-v", "print the version") do
1203
- puts opt.version
1204
- exit
1205
- end
1203
+ opt.on("--version", "-v", "print the version") do
1204
+ puts opt.version
1205
+ exit
1206
+ end
1206
1207
 
1207
- opt.separator nil
1208
+ opt.separator nil
1208
1209
 
1209
- opt.on("--help", "-h", "Display this help") do
1210
- RDoc::RDoc::GENERATORS.each_key do |generator|
1211
- setup_generator generator
1210
+ opt.on("--help", "-h", "Display this help") do
1211
+ RDoc::GENERATORS.each_key do |generator|
1212
+ setup_generator generator
1213
+ end
1214
+
1215
+ puts opt.help
1216
+ exit
1212
1217
  end
1213
1218
 
1214
- puts opt.help
1215
- exit
1219
+ opt.separator nil
1216
1220
  end
1217
1221
 
1218
- opt.separator nil
1219
- end
1222
+ invalid = []
1220
1223
 
1221
- invalid = []
1224
+ begin
1225
+ opts.parse! argv
1226
+ rescue OptionParser::ParseError => e
1227
+ if %w[--format --ri -r --ri-site -R].include? e.args.first
1228
+ raise
1229
+ else
1230
+ invalid << e.args.join(' ')
1231
+ end
1222
1232
 
1223
- begin
1224
- opts.parse! argv
1225
- rescue OptionParser::ParseError => e
1226
- if %w[--format --ri -r --ri-site -R].include? e.args.first then
1227
- raise
1228
- else
1229
- invalid << e.args.join(' ')
1233
+ retry
1230
1234
  end
1231
1235
 
1232
- retry
1233
- end
1236
+ setup_generator unless @generator
1234
1237
 
1235
- setup_generator unless @generator
1236
-
1237
- if @pipe and not argv.empty? then
1238
- @pipe = false
1239
- invalid << '-p (with files)'
1240
- end
1238
+ if @pipe and not argv.empty?
1239
+ @pipe = false
1240
+ invalid << '-p (with files)'
1241
+ end
1241
1242
 
1242
- unless invalid.empty? then
1243
- invalid = "invalid options: #{invalid.join ', '}"
1243
+ unless invalid.empty?
1244
+ invalid = "invalid options: #{invalid.join ', '}"
1244
1245
 
1245
- if ignore_invalid then
1246
- unless quiet then
1246
+ if ignore_invalid
1247
+ unless quiet
1248
+ $stderr.puts invalid
1249
+ $stderr.puts '(invalid options are ignored)'
1250
+ end
1251
+ else
1252
+ unless quiet
1253
+ $stderr.puts opts
1254
+ end
1247
1255
  $stderr.puts invalid
1248
- $stderr.puts '(invalid options are ignored)'
1249
- end
1250
- else
1251
- unless quiet then
1252
- $stderr.puts opts
1256
+ exit 1
1253
1257
  end
1254
- $stderr.puts invalid
1255
- exit 1
1256
1258
  end
1257
- end
1258
-
1259
- @files = argv.dup
1260
1259
 
1261
- self
1262
- end
1263
-
1264
- ##
1265
- # Don't display progress as we process the files
1260
+ @files = argv.dup
1266
1261
 
1267
- def quiet
1268
- @verbosity.zero?
1269
- end
1262
+ self
1263
+ end
1270
1264
 
1271
- ##
1272
- # Set quietness to +bool+
1265
+ ##
1266
+ # Don't display progress as we process the files
1273
1267
 
1274
- def quiet=(bool)
1275
- @verbosity = bool ? 0 : 1
1276
- end
1268
+ def quiet
1269
+ @verbosity.zero?
1270
+ end
1277
1271
 
1278
- ##
1279
- # Removes directories from +path+ that are outside the current directory
1272
+ ##
1273
+ # Set quietness to +bool+
1280
1274
 
1281
- def sanitize_path(path)
1282
- require 'pathname'
1283
- dot = Pathname.new('.').expand_path
1275
+ def quiet=(bool)
1276
+ @verbosity = bool ? 0 : 1
1277
+ end
1284
1278
 
1285
- path.reject do |item|
1286
- path = Pathname.new(item).expand_path
1287
- is_reject = nil
1288
- relative = nil
1289
- begin
1290
- relative = path.relative_path_from(dot).to_s
1291
- rescue ArgumentError
1292
- # On Windows, sometimes crosses different drive letters.
1293
- is_reject = true
1294
- else
1295
- is_reject = relative.start_with? '..'
1279
+ ##
1280
+ # Removes directories from +path+ that are outside the current directory
1281
+
1282
+ def sanitize_path(path)
1283
+ require 'pathname'
1284
+ dot = Pathname.new('.').expand_path
1285
+
1286
+ path.reject do |item|
1287
+ path = Pathname.new(item).expand_path
1288
+ is_reject = nil
1289
+ relative = nil
1290
+ begin
1291
+ relative = path.relative_path_from(dot).to_s
1292
+ rescue ArgumentError
1293
+ # On Windows, sometimes crosses different drive letters.
1294
+ is_reject = true
1295
+ else
1296
+ is_reject = relative.start_with? '..'
1297
+ end
1298
+ is_reject
1296
1299
  end
1297
- is_reject
1298
1300
  end
1299
- end
1300
1301
 
1301
- ##
1302
- # Set up an output generator for the named +generator_name+.
1303
- #
1304
- # If the found generator responds to :setup_options it will be called with
1305
- # the options instance. This allows generators to add custom options or set
1306
- # default options.
1302
+ ##
1303
+ # Set up an output generator for the named +generator_name+.
1304
+ #
1305
+ # If the found generator responds to :setup_options it will be called with
1306
+ # the options instance. This allows generators to add custom options or set
1307
+ # default options.
1307
1308
 
1308
- def setup_generator(generator_name = @generator_name)
1309
- @generator = @generators[generator_name]
1309
+ def setup_generator(generator_name = @generator_name)
1310
+ @generator = @generators[generator_name]
1310
1311
 
1311
- unless @generator then
1312
- raise OptionParser::InvalidArgument,
1313
- "Invalid output formatter #{generator_name}"
1314
- end
1312
+ unless @generator
1313
+ raise OptionParser::InvalidArgument,
1314
+ "Invalid output formatter #{generator_name}"
1315
+ end
1315
1316
 
1316
- return if @generator_options.include? @generator
1317
+ return if @generator_options.include? @generator
1317
1318
 
1318
- @generator_name = generator_name
1319
- @generator_options << @generator
1319
+ @generator_name = generator_name
1320
+ @generator_options << @generator
1320
1321
 
1321
- if @generator.respond_to? :setup_options then
1322
- @option_parser ||= OptionParser.new
1323
- @generator.setup_options self
1322
+ if @generator.respond_to? :setup_options
1323
+ @option_parser ||= OptionParser.new
1324
+ @generator.setup_options self
1325
+ end
1324
1326
  end
1325
- end
1326
1327
 
1327
- ##
1328
- # Finds the template dir for +template+
1328
+ ##
1329
+ # Finds the template dir for +template+
1329
1330
 
1330
- def template_dir_for(template)
1331
- template_path = File.join 'rdoc', 'generator', 'template', template
1331
+ def template_dir_for(template)
1332
+ template_path = File.join 'rdoc', 'generator', 'template', template
1332
1333
 
1333
- $LOAD_PATH.map do |path|
1334
- File.join File.expand_path(path), template_path
1335
- end.find do |dir|
1336
- File.directory? dir
1334
+ $LOAD_PATH.map do |path|
1335
+ File.join File.expand_path(path), template_path
1336
+ end.find do |dir|
1337
+ File.directory? dir
1338
+ end
1337
1339
  end
1338
- end
1339
1340
 
1340
- # Sets the minimum visibility of a documented method.
1341
- #
1342
- # Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+.
1343
- #
1344
- # When +:all+ is passed, visibility is set to +:private+, similarly to
1345
- # RDOCOPT="--all", see #visibility for more information.
1346
-
1347
- def visibility=(visibility)
1348
- case visibility
1349
- when :all
1350
- @visibility = :private
1351
- else
1352
- @visibility = visibility
1341
+ # Sets the minimum visibility of a documented method.
1342
+ #
1343
+ # Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+.
1344
+ #
1345
+ # When +:all+ is passed, visibility is set to +:private+, similarly to
1346
+ # RDOCOPT="--all", see #visibility for more information.
1347
+
1348
+ def visibility=(visibility)
1349
+ case visibility
1350
+ when :all
1351
+ @visibility = :private
1352
+ else
1353
+ @visibility = visibility
1354
+ end
1353
1355
  end
1354
- end
1355
1356
 
1356
- ##
1357
- # Displays a warning using Kernel#warn if we're being verbose
1357
+ ##
1358
+ # Displays a warning using Kernel#warn if we're being verbose
1358
1359
 
1359
- def warn(message)
1360
- super message if @verbosity > 1
1361
- end
1360
+ def warn(message)
1361
+ super message if @verbosity > 1
1362
+ end
1362
1363
 
1363
- ##
1364
- # Writes the YAML file .rdoc_options to the current directory containing the
1365
- # parsed options.
1364
+ ##
1365
+ # Writes the YAML file .rdoc_options to the current directory containing the
1366
+ # parsed options.
1366
1367
 
1367
- def write_options
1368
- RDoc.load_yaml
1368
+ def write_options
1369
+ ::RDoc.load_yaml
1369
1370
 
1370
- File.open '.rdoc_options', 'w' do |io|
1371
- io.set_encoding Encoding::UTF_8
1371
+ File.open '.rdoc_options', 'w' do |io|
1372
+ io.set_encoding ::Encoding::UTF_8
1372
1373
 
1373
- io.print to_yaml
1374
+ io.print to_yaml
1375
+ end
1374
1376
  end
1375
- end
1376
1377
 
1377
- ##
1378
- # Loads options from .rdoc_options if the file exists, otherwise creates a
1379
- # new RDoc::Options instance.
1378
+ ##
1379
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1380
+ # new RDoc::Options instance.
1380
1381
 
1381
- def self.load_options
1382
- options_file = File.expand_path '.rdoc_options'
1383
- return RDoc::Options.new unless File.exist? options_file
1382
+ def self.load_options
1383
+ options_file = File.expand_path '.rdoc_options'
1384
+ return Options.new unless File.exist? options_file
1384
1385
 
1385
- RDoc.load_yaml
1386
+ ::RDoc.load_yaml
1386
1387
 
1387
- content = File.read('.rdoc_options')
1388
+ content = File.read('.rdoc_options')
1388
1389
 
1389
- if defined?(Psych)
1390
- begin
1391
- options = Psych.safe_load content, permitted_classes: [RDoc::Options, Symbol]
1392
- rescue Psych::SyntaxError
1393
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
1390
+ if defined?(Psych)
1391
+ begin
1392
+ options = Psych.safe_load content, permitted_classes: [Options, Symbol]
1393
+ rescue Psych::SyntaxError
1394
+ raise Error, "#{options_file} is not a valid rdoc options file"
1395
+ end
1396
+ else
1397
+ options = ::RDoc.yaml_serializer.load(content)
1394
1398
  end
1395
- else
1396
- options = RDoc.yaml_serializer.load(content)
1397
- end
1398
1399
 
1399
- return RDoc::Options.new unless options # Allow empty file.
1400
+ return Options.new unless options # Allow empty file.
1400
1401
 
1401
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1402
- RDoc::Options === options or Hash === options
1402
+ raise Error, "#{options_file} is not a valid rdoc options file" unless
1403
+ Options === options or Hash === options
1403
1404
 
1404
- if Hash === options
1405
- # Override the default values with the contents of YAML file.
1406
- options = RDoc::Options.new options
1405
+ if Hash === options
1406
+ # Override the default values with the contents of YAML file.
1407
+ options = Options.new options
1408
+ end
1409
+
1410
+ options
1407
1411
  end
1408
1412
 
1409
- options
1410
1413
  end
1411
-
1412
1414
  end