rdoc 3.1 → 6.3.3
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.
- checksums.yaml +7 -0
- data/CONTRIBUTING.rdoc +220 -0
- data/CVE-2013-0256.rdoc +49 -0
- data/ExampleMarkdown.md +37 -0
- data/ExampleRDoc.rdoc +208 -0
- data/Gemfile +12 -0
- data/History.rdoc +1666 -0
- data/LEGAL.rdoc +50 -0
- data/LICENSE.rdoc +57 -0
- data/README.rdoc +129 -0
- data/RI.rdoc +57 -0
- data/Rakefile +84 -81
- data/TODO.rdoc +59 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/{bin → exe}/rdoc +11 -2
- data/exe/ri +12 -0
- data/lib/rdoc/alias.rb +1 -2
- data/lib/rdoc/anon_class.rb +3 -2
- data/lib/rdoc/any_method.rb +234 -40
- data/lib/rdoc/attr.rb +79 -11
- data/lib/rdoc/class_module.rb +443 -71
- data/lib/rdoc/code_object.rb +216 -20
- data/lib/rdoc/code_objects.rb +4 -21
- data/lib/rdoc/comment.rb +250 -0
- data/lib/rdoc/constant.rb +110 -9
- data/lib/rdoc/context/section.rb +232 -0
- data/lib/rdoc/context.rb +392 -172
- data/lib/rdoc/cross_reference.rb +202 -0
- data/lib/rdoc/encoding.rb +83 -28
- data/lib/rdoc/erb_partial.rb +19 -0
- data/lib/rdoc/erbio.rb +8 -3
- data/lib/rdoc/extend.rb +10 -0
- data/lib/rdoc/generator/darkfish.rb +507 -84
- data/lib/rdoc/generator/json_index.rb +300 -0
- data/lib/rdoc/generator/markup.rb +27 -74
- data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
- data/lib/rdoc/generator/pot/po.rb +84 -0
- data/lib/rdoc/generator/pot/po_entry.rb +141 -0
- data/lib/rdoc/generator/pot.rb +98 -0
- data/lib/rdoc/generator/ri.rb +8 -62
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
- data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
- data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
- data/lib/rdoc/generator/template/json_index/.document +1 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
- data/lib/rdoc/generator.rb +24 -13
- data/lib/rdoc/ghost_method.rb +1 -2
- data/lib/rdoc/i18n/locale.rb +102 -0
- data/lib/rdoc/i18n/text.rb +126 -0
- data/lib/rdoc/i18n.rb +10 -0
- data/lib/rdoc/include.rb +5 -95
- data/lib/rdoc/known_classes.rb +5 -2
- data/lib/rdoc/markdown/entities.rb +2132 -0
- data/lib/rdoc/markdown/literals.kpeg +23 -0
- data/lib/rdoc/markdown/literals.rb +416 -0
- data/lib/rdoc/markdown.kpeg +1237 -0
- data/lib/rdoc/markdown.rb +16684 -0
- data/lib/rdoc/markup/attr_changer.rb +23 -0
- data/lib/rdoc/markup/attr_span.rb +36 -0
- data/lib/rdoc/markup/attribute_manager.rb +135 -62
- data/lib/rdoc/markup/attributes.rb +71 -0
- data/lib/rdoc/markup/blank_line.rb +1 -0
- data/lib/rdoc/markup/block_quote.rb +15 -0
- data/lib/rdoc/markup/document.rb +96 -9
- data/lib/rdoc/markup/formatter.rb +138 -25
- data/lib/rdoc/markup/hard_break.rb +32 -0
- data/lib/rdoc/markup/heading.rb +61 -2
- data/lib/rdoc/markup/include.rb +43 -0
- data/lib/rdoc/markup/indented_paragraph.rb +48 -0
- data/lib/rdoc/markup/list.rb +25 -4
- data/lib/rdoc/markup/list_item.rb +18 -4
- data/lib/rdoc/markup/paragraph.rb +15 -0
- data/lib/rdoc/markup/parser.rb +180 -88
- data/lib/rdoc/markup/pre_process.rb +183 -38
- data/lib/rdoc/markup/raw.rb +6 -5
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -0
- data/lib/rdoc/markup/table.rb +47 -0
- data/lib/rdoc/markup/to_ansi.rb +17 -7
- data/lib/rdoc/markup/to_bs.rb +5 -8
- data/lib/rdoc/markup/to_html.rb +238 -137
- data/lib/rdoc/markup/to_html_crossref.rb +125 -152
- data/lib/rdoc/markup/to_html_snippet.rb +285 -0
- data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
- data/lib/rdoc/markup/to_label.rb +75 -0
- data/lib/rdoc/markup/to_markdown.rb +192 -0
- data/lib/rdoc/markup/to_rdoc.rb +85 -15
- data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
- data/lib/rdoc/markup/to_test.rb +2 -4
- data/lib/rdoc/markup/to_tt_only.rb +121 -0
- data/lib/rdoc/markup/verbatim.rb +39 -0
- data/lib/rdoc/markup.rb +388 -110
- data/lib/rdoc/meta_method.rb +1 -2
- data/lib/rdoc/method_attr.rb +87 -21
- data/lib/rdoc/mixin.rb +121 -0
- data/lib/rdoc/normal_class.rb +39 -10
- data/lib/rdoc/normal_module.rb +22 -7
- data/lib/rdoc/options.rb +613 -73
- data/lib/rdoc/parser/c.rb +621 -287
- data/lib/rdoc/parser/changelog.rb +335 -0
- data/lib/rdoc/parser/markdown.rb +24 -0
- data/lib/rdoc/parser/rd.rb +23 -0
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +1368 -762
- data/lib/rdoc/parser/ruby_tools.rb +42 -35
- data/lib/rdoc/parser/simple.rb +23 -11
- data/lib/rdoc/parser/text.rb +12 -0
- data/lib/rdoc/parser.rb +162 -89
- data/lib/rdoc/rd/block_parser.rb +1056 -0
- data/lib/rdoc/rd/block_parser.ry +639 -0
- data/lib/rdoc/rd/inline.rb +72 -0
- data/lib/rdoc/rd/inline_parser.rb +1208 -0
- data/lib/rdoc/rd/inline_parser.ry +593 -0
- data/lib/rdoc/rd.rb +100 -0
- data/lib/rdoc/rdoc.rb +208 -115
- data/lib/rdoc/require.rb +1 -2
- data/lib/rdoc/ri/driver.rb +734 -239
- data/lib/rdoc/ri/formatter.rb +1 -0
- data/lib/rdoc/ri/paths.rb +91 -48
- data/lib/rdoc/ri/store.rb +3 -261
- data/lib/rdoc/ri/task.rb +71 -0
- data/lib/rdoc/ri.rb +5 -2
- data/lib/rdoc/rubygems_hook.rb +246 -0
- data/lib/rdoc/servlet.rb +451 -0
- data/lib/rdoc/single_class.rb +14 -2
- data/lib/rdoc/stats/normal.rb +19 -12
- data/lib/rdoc/stats/quiet.rb +1 -0
- data/lib/rdoc/stats/verbose.rb +1 -0
- data/lib/rdoc/stats.rb +262 -104
- data/lib/rdoc/store.rb +979 -0
- data/lib/rdoc/task.rb +84 -44
- data/lib/rdoc/text.rb +117 -72
- data/lib/rdoc/token_stream.rb +73 -4
- data/lib/rdoc/tom_doc.rb +263 -0
- data/lib/rdoc/top_level.rb +111 -261
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +127 -64
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +249 -0
- metadata +171 -291
- data/.autotest +0 -16
- data/.document +0 -5
- data/History.txt +0 -594
- data/LICENSE.txt +0 -57
- data/Manifest.txt +0 -158
- data/README.txt +0 -45
- data/RI.txt +0 -58
- data/bin/ri +0 -5
- data/lib/rdoc/gauntlet.rb +0 -52
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
- data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
- data/lib/rdoc/markup/formatter_test_case.rb +0 -689
- data/lib/rdoc/markup/inline.rb +0 -137
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
- data/lib/rdoc/ruby_lex.rb +0 -1291
- data/lib/rdoc/ruby_token.rb +0 -416
- data/test/README +0 -1
- data/test/binary.dat +0 -0
- data/test/hidden.zip.txt +0 -1
- data/test/test.ja.rdoc +0 -10
- data/test/test.ja.txt +0 -8
- data/test/test.txt +0 -1
- data/test/test_attribute_manager.rb +0 -120
- data/test/test_rdoc_alias.rb +0 -13
- data/test/test_rdoc_any_method.rb +0 -126
- data/test/test_rdoc_attr.rb +0 -61
- data/test/test_rdoc_class_module.rb +0 -233
- data/test/test_rdoc_code_object.rb +0 -165
- data/test/test_rdoc_constant.rb +0 -15
- data/test/test_rdoc_context.rb +0 -370
- data/test/test_rdoc_encoding.rb +0 -166
- data/test/test_rdoc_generator_darkfish.rb +0 -119
- data/test/test_rdoc_generator_ri.rb +0 -76
- data/test/test_rdoc_include.rb +0 -96
- data/test/test_rdoc_markup.rb +0 -37
- data/test/test_rdoc_markup_attribute_manager.rb +0 -240
- data/test/test_rdoc_markup_document.rb +0 -51
- data/test/test_rdoc_markup_paragraph.rb +0 -9
- data/test/test_rdoc_markup_parser.rb +0 -1395
- data/test/test_rdoc_markup_pre_process.rb +0 -185
- data/test/test_rdoc_markup_raw.rb +0 -27
- data/test/test_rdoc_markup_to_ansi.rb +0 -328
- data/test/test_rdoc_markup_to_bs.rb +0 -341
- data/test/test_rdoc_markup_to_html.rb +0 -335
- data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
- data/test/test_rdoc_markup_to_rdoc.rb +0 -327
- data/test/test_rdoc_method_attr.rb +0 -122
- data/test/test_rdoc_normal_class.rb +0 -17
- data/test/test_rdoc_normal_module.rb +0 -31
- data/test/test_rdoc_options.rb +0 -342
- data/test/test_rdoc_parser.rb +0 -83
- data/test/test_rdoc_parser_c.rb +0 -912
- data/test/test_rdoc_parser_ruby.rb +0 -1754
- data/test/test_rdoc_parser_simple.rb +0 -99
- data/test/test_rdoc_rdoc.rb +0 -164
- data/test/test_rdoc_require.rb +0 -25
- data/test/test_rdoc_ri_driver.rb +0 -846
- data/test/test_rdoc_ri_paths.rb +0 -43
- data/test/test_rdoc_ri_store.rb +0 -352
- data/test/test_rdoc_ruby_lex.rb +0 -23
- data/test/test_rdoc_stats.rb +0 -38
- data/test/test_rdoc_task.rb +0 -92
- data/test/test_rdoc_text.rb +0 -251
- data/test/test_rdoc_top_level.rb +0 -120
- data/test/xref_data.rb +0 -62
- data/test/xref_test_case.rb +0 -61
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
data/lib/rdoc/options.rb
CHANGED
@@ -1,9 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require 'optparse'
|
2
|
-
|
3
|
-
require 'rdoc/ri/paths'
|
3
|
+
require 'pathname'
|
4
4
|
|
5
5
|
##
|
6
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.
|
7
74
|
|
8
75
|
class RDoc::Options
|
9
76
|
|
@@ -25,9 +92,57 @@ class RDoc::Options
|
|
25
92
|
}
|
26
93
|
|
27
94
|
##
|
28
|
-
#
|
95
|
+
# RDoc options ignored (or handled specially) by --write-options
|
96
|
+
|
97
|
+
SPECIAL = %w[
|
98
|
+
coverage_report
|
99
|
+
dry_run
|
100
|
+
encoding
|
101
|
+
files
|
102
|
+
force_output
|
103
|
+
force_update
|
104
|
+
generator
|
105
|
+
generator_name
|
106
|
+
generator_options
|
107
|
+
generators
|
108
|
+
op_dir
|
109
|
+
option_parser
|
110
|
+
pipe
|
111
|
+
rdoc_include
|
112
|
+
root
|
113
|
+
static_path
|
114
|
+
stylesheet_url
|
115
|
+
template
|
116
|
+
template_dir
|
117
|
+
update_output_dir
|
118
|
+
verbosity
|
119
|
+
write_options
|
120
|
+
]
|
121
|
+
|
122
|
+
##
|
123
|
+
# Option validator for OptionParser that matches a directory that exists on
|
124
|
+
# the filesystem.
|
29
125
|
|
30
|
-
|
126
|
+
Directory = Object.new
|
127
|
+
|
128
|
+
##
|
129
|
+
# Option validator for OptionParser that matches a file or directory that
|
130
|
+
# exists on the filesystem.
|
131
|
+
|
132
|
+
Path = Object.new
|
133
|
+
|
134
|
+
##
|
135
|
+
# Option validator for OptionParser that matches a comma-separated list of
|
136
|
+
# files or directories that exist on the filesystem.
|
137
|
+
|
138
|
+
PathArray = Object.new
|
139
|
+
|
140
|
+
##
|
141
|
+
# Option validator for OptionParser that matches a template directory for an
|
142
|
+
# installed generator that lives in
|
143
|
+
# <tt>"rdoc/generator/template/#{template_name}"</tt>
|
144
|
+
|
145
|
+
Template = Object.new
|
31
146
|
|
32
147
|
##
|
33
148
|
# Character-set for HTML output. #encoding is preferred over #charset
|
@@ -40,14 +155,16 @@ class RDoc::Options
|
|
40
155
|
attr_accessor :dry_run
|
41
156
|
|
42
157
|
##
|
43
|
-
#
|
158
|
+
# The output encoding. All input files will be transcoded to this encoding.
|
159
|
+
#
|
160
|
+
# The default encoding is UTF-8. This is set via --encoding.
|
44
161
|
|
45
|
-
attr_accessor :encoding
|
162
|
+
attr_accessor :encoding
|
46
163
|
|
47
164
|
##
|
48
165
|
# Files matching this pattern will be excluded
|
49
166
|
|
50
|
-
|
167
|
+
attr_writer :exclude
|
51
168
|
|
52
169
|
##
|
53
170
|
# The list of files to be processed
|
@@ -71,10 +188,15 @@ class RDoc::Options
|
|
71
188
|
attr_accessor :formatter
|
72
189
|
|
73
190
|
##
|
74
|
-
# Description of the output generator (set with the <tt
|
191
|
+
# Description of the output generator (set with the <tt>--format</tt> option)
|
75
192
|
|
76
193
|
attr_accessor :generator
|
77
194
|
|
195
|
+
##
|
196
|
+
# For #==
|
197
|
+
|
198
|
+
attr_reader :generator_name # :nodoc:
|
199
|
+
|
78
200
|
##
|
79
201
|
# Loaded generator options. Used to prevent --help from loading the same
|
80
202
|
# options multiple times.
|
@@ -92,12 +214,28 @@ class RDoc::Options
|
|
92
214
|
|
93
215
|
attr_accessor :line_numbers
|
94
216
|
|
217
|
+
##
|
218
|
+
# The output locale.
|
219
|
+
|
220
|
+
attr_accessor :locale
|
221
|
+
|
222
|
+
##
|
223
|
+
# The directory where locale data live.
|
224
|
+
|
225
|
+
attr_accessor :locale_dir
|
226
|
+
|
95
227
|
##
|
96
228
|
# Name of the file, class or module to display in the initial index page (if
|
97
229
|
# not specified the first file we encounter is used)
|
98
230
|
|
99
231
|
attr_accessor :main_page
|
100
232
|
|
233
|
+
##
|
234
|
+
# The default markup format. The default is 'rdoc'. 'markdown', 'tomdoc'
|
235
|
+
# and 'rd' are also built-in.
|
236
|
+
|
237
|
+
attr_accessor :markup
|
238
|
+
|
101
239
|
##
|
102
240
|
# If true, only report on undocumented files
|
103
241
|
|
@@ -113,6 +251,16 @@ class RDoc::Options
|
|
113
251
|
|
114
252
|
attr_accessor :option_parser
|
115
253
|
|
254
|
+
##
|
255
|
+
# Output heading decorations?
|
256
|
+
attr_accessor :output_decoration
|
257
|
+
|
258
|
+
##
|
259
|
+
# Directory where guides, FAQ, and other pages not associated with a class
|
260
|
+
# live. You may leave this unset if these are at the root of your project.
|
261
|
+
|
262
|
+
attr_accessor :page_dir
|
263
|
+
|
116
264
|
##
|
117
265
|
# Is RDoc in pipe mode?
|
118
266
|
|
@@ -123,11 +271,23 @@ class RDoc::Options
|
|
123
271
|
|
124
272
|
attr_accessor :rdoc_include
|
125
273
|
|
274
|
+
##
|
275
|
+
# Root of the source documentation will be generated for. Set this when
|
276
|
+
# building documentation outside the source directory. Defaults to the
|
277
|
+
# current directory.
|
278
|
+
|
279
|
+
attr_accessor :root
|
280
|
+
|
126
281
|
##
|
127
282
|
# Include the '#' at the front of hyperlinked instance method names
|
128
283
|
|
129
284
|
attr_accessor :show_hash
|
130
285
|
|
286
|
+
##
|
287
|
+
# Directory to copy static files from
|
288
|
+
|
289
|
+
attr_accessor :static_path
|
290
|
+
|
131
291
|
##
|
132
292
|
# The number of columns in a tab
|
133
293
|
|
@@ -143,11 +303,21 @@ class RDoc::Options
|
|
143
303
|
|
144
304
|
attr_accessor :template_dir
|
145
305
|
|
306
|
+
##
|
307
|
+
# Additional template stylesheets
|
308
|
+
|
309
|
+
attr_accessor :template_stylesheets
|
310
|
+
|
146
311
|
##
|
147
312
|
# Documentation title
|
148
313
|
|
149
314
|
attr_accessor :title
|
150
315
|
|
316
|
+
##
|
317
|
+
# Should RDoc update the timestamps in the output dir?
|
318
|
+
|
319
|
+
attr_accessor :update_output_dir
|
320
|
+
|
151
321
|
##
|
152
322
|
# Verbosity, zero means quiet
|
153
323
|
|
@@ -159,16 +329,27 @@ class RDoc::Options
|
|
159
329
|
attr_accessor :webcvs
|
160
330
|
|
161
331
|
##
|
162
|
-
# Minimum visibility of a documented method. One of +:public+,
|
163
|
-
# +:
|
164
|
-
#
|
332
|
+
# Minimum visibility of a documented method. One of +:public+, +:protected+,
|
333
|
+
# +:private+ or +:nodoc+.
|
334
|
+
#
|
335
|
+
# The +:nodoc+ visibility ignores all directives related to visibility. The
|
336
|
+
# other visibilities may be overridden on a per-method basis with the :doc:
|
337
|
+
# directive.
|
165
338
|
|
166
|
-
|
339
|
+
attr_reader :visibility
|
167
340
|
|
168
|
-
def initialize # :nodoc:
|
169
|
-
|
341
|
+
def initialize loaded_options = nil # :nodoc:
|
342
|
+
init_ivars
|
343
|
+
override loaded_options if loaded_options
|
344
|
+
end
|
345
|
+
|
346
|
+
def init_ivars # :nodoc:
|
170
347
|
@dry_run = false
|
171
|
-
@exclude = [
|
348
|
+
@exclude = %w[
|
349
|
+
~\z \.orig\z \.rej\z \.bak\z
|
350
|
+
\.gemspec\z
|
351
|
+
]
|
352
|
+
@files = nil
|
172
353
|
@force_output = false
|
173
354
|
@force_update = true
|
174
355
|
@generator = nil
|
@@ -177,27 +358,116 @@ class RDoc::Options
|
|
177
358
|
@generators = RDoc::RDoc::GENERATORS
|
178
359
|
@hyperlink_all = false
|
179
360
|
@line_numbers = false
|
361
|
+
@locale = nil
|
362
|
+
@locale_name = nil
|
363
|
+
@locale_dir = 'locale'
|
180
364
|
@main_page = nil
|
365
|
+
@markup = 'rdoc'
|
181
366
|
@coverage_report = false
|
182
367
|
@op_dir = nil
|
368
|
+
@page_dir = nil
|
183
369
|
@pipe = false
|
370
|
+
@output_decoration = true
|
184
371
|
@rdoc_include = []
|
372
|
+
@root = Pathname(Dir.pwd)
|
185
373
|
@show_hash = false
|
186
|
-
@
|
374
|
+
@static_path = []
|
375
|
+
@stylesheet_url = nil # TODO remove in RDoc 4
|
187
376
|
@tab_width = 8
|
188
377
|
@template = nil
|
189
378
|
@template_dir = nil
|
379
|
+
@template_stylesheets = []
|
190
380
|
@title = nil
|
381
|
+
@update_output_dir = true
|
191
382
|
@verbosity = 1
|
192
383
|
@visibility = :protected
|
193
384
|
@webcvs = nil
|
385
|
+
@write_options = false
|
386
|
+
@encoding = Encoding::UTF_8
|
387
|
+
@charset = @encoding.name
|
388
|
+
end
|
194
389
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
390
|
+
def init_with map # :nodoc:
|
391
|
+
init_ivars
|
392
|
+
|
393
|
+
encoding = map['encoding']
|
394
|
+
@encoding = encoding ? Encoding.find(encoding) : encoding
|
395
|
+
|
396
|
+
@charset = map['charset']
|
397
|
+
@exclude = map['exclude']
|
398
|
+
@generator_name = map['generator_name']
|
399
|
+
@hyperlink_all = map['hyperlink_all']
|
400
|
+
@line_numbers = map['line_numbers']
|
401
|
+
@locale_name = map['locale_name']
|
402
|
+
@locale_dir = map['locale_dir']
|
403
|
+
@main_page = map['main_page']
|
404
|
+
@markup = map['markup']
|
405
|
+
@op_dir = map['op_dir']
|
406
|
+
@show_hash = map['show_hash']
|
407
|
+
@tab_width = map['tab_width']
|
408
|
+
@template_dir = map['template_dir']
|
409
|
+
@title = map['title']
|
410
|
+
@visibility = map['visibility']
|
411
|
+
@webcvs = map['webcvs']
|
412
|
+
|
413
|
+
@rdoc_include = sanitize_path map['rdoc_include']
|
414
|
+
@static_path = sanitize_path map['static_path']
|
415
|
+
end
|
416
|
+
|
417
|
+
def yaml_initialize tag, map # :nodoc:
|
418
|
+
init_with map
|
419
|
+
end
|
420
|
+
|
421
|
+
def override map # :nodoc:
|
422
|
+
if map.has_key?('encoding')
|
423
|
+
encoding = map['encoding']
|
424
|
+
@encoding = encoding ? Encoding.find(encoding) : encoding
|
200
425
|
end
|
426
|
+
|
427
|
+
@charset = map['charset'] if map.has_key?('charset')
|
428
|
+
@exclude = map['exclude'] if map.has_key?('exclude')
|
429
|
+
@generator_name = map['generator_name'] if map.has_key?('generator_name')
|
430
|
+
@hyperlink_all = map['hyperlink_all'] if map.has_key?('hyperlink_all')
|
431
|
+
@line_numbers = map['line_numbers'] if map.has_key?('line_numbers')
|
432
|
+
@locale_name = map['locale_name'] if map.has_key?('locale_name')
|
433
|
+
@locale_dir = map['locale_dir'] if map.has_key?('locale_dir')
|
434
|
+
@main_page = map['main_page'] if map.has_key?('main_page')
|
435
|
+
@markup = map['markup'] if map.has_key?('markup')
|
436
|
+
@op_dir = map['op_dir'] if map.has_key?('op_dir')
|
437
|
+
@show_hash = map['show_hash'] if map.has_key?('show_hash')
|
438
|
+
@tab_width = map['tab_width'] if map.has_key?('tab_width')
|
439
|
+
@template_dir = map['template_dir'] if map.has_key?('template_dir')
|
440
|
+
@title = map['title'] if map.has_key?('title')
|
441
|
+
@visibility = map['visibility'] if map.has_key?('visibility')
|
442
|
+
@webcvs = map['webcvs'] if map.has_key?('webcvs')
|
443
|
+
|
444
|
+
if map.has_key?('rdoc_include')
|
445
|
+
@rdoc_include = sanitize_path map['rdoc_include']
|
446
|
+
end
|
447
|
+
if map.has_key?('static_path')
|
448
|
+
@static_path = sanitize_path map['static_path']
|
449
|
+
end
|
450
|
+
end
|
451
|
+
|
452
|
+
def == other # :nodoc:
|
453
|
+
self.class === other and
|
454
|
+
@encoding == other.encoding and
|
455
|
+
@generator_name == other.generator_name and
|
456
|
+
@hyperlink_all == other.hyperlink_all and
|
457
|
+
@line_numbers == other.line_numbers and
|
458
|
+
@locale == other.locale and
|
459
|
+
@locale_dir == other.locale_dir and
|
460
|
+
@main_page == other.main_page and
|
461
|
+
@markup == other.markup and
|
462
|
+
@op_dir == other.op_dir and
|
463
|
+
@rdoc_include == other.rdoc_include and
|
464
|
+
@show_hash == other.show_hash and
|
465
|
+
@static_path == other.static_path and
|
466
|
+
@tab_width == other.tab_width and
|
467
|
+
@template == other.template and
|
468
|
+
@title == other.title and
|
469
|
+
@visibility == other.visibility and
|
470
|
+
@webcvs == other.webcvs
|
201
471
|
end
|
202
472
|
|
203
473
|
##
|
@@ -240,6 +510,94 @@ class RDoc::Options
|
|
240
510
|
@title ||= string
|
241
511
|
end
|
242
512
|
|
513
|
+
##
|
514
|
+
# For dumping YAML
|
515
|
+
|
516
|
+
def encode_with coder # :nodoc:
|
517
|
+
encoding = @encoding ? @encoding.name : nil
|
518
|
+
|
519
|
+
coder.add 'encoding', encoding
|
520
|
+
coder.add 'static_path', sanitize_path(@static_path)
|
521
|
+
coder.add 'rdoc_include', sanitize_path(@rdoc_include)
|
522
|
+
|
523
|
+
ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
|
524
|
+
ivars -= SPECIAL
|
525
|
+
|
526
|
+
ivars.sort.each do |ivar|
|
527
|
+
coder.add ivar, instance_variable_get("@#{ivar}")
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
##
|
532
|
+
# Create a regexp for #exclude
|
533
|
+
|
534
|
+
def exclude
|
535
|
+
if @exclude.nil? or Regexp === @exclude then
|
536
|
+
# done, #finish is being re-run
|
537
|
+
@exclude
|
538
|
+
elsif @exclude.empty? then
|
539
|
+
nil
|
540
|
+
else
|
541
|
+
Regexp.new(@exclude.join("|"))
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
##
|
546
|
+
# Completes any unfinished option setup business such as filtering for
|
547
|
+
# existent files, creating a regexp for #exclude and setting a default
|
548
|
+
# #template.
|
549
|
+
|
550
|
+
def finish
|
551
|
+
@op_dir ||= 'doc'
|
552
|
+
|
553
|
+
@rdoc_include << "." if @rdoc_include.empty?
|
554
|
+
root = @root.to_s
|
555
|
+
@rdoc_include << root unless @rdoc_include.include?(root)
|
556
|
+
|
557
|
+
@exclude = self.exclude
|
558
|
+
|
559
|
+
finish_page_dir
|
560
|
+
|
561
|
+
check_files
|
562
|
+
|
563
|
+
# If no template was specified, use the default template for the output
|
564
|
+
# formatter
|
565
|
+
|
566
|
+
unless @template then
|
567
|
+
@template = @generator_name
|
568
|
+
@template_dir = template_dir_for @template
|
569
|
+
end
|
570
|
+
|
571
|
+
if @locale_name
|
572
|
+
@locale = RDoc::I18n::Locale[@locale_name]
|
573
|
+
@locale.load(@locale_dir)
|
574
|
+
else
|
575
|
+
@locale = nil
|
576
|
+
end
|
577
|
+
|
578
|
+
self
|
579
|
+
end
|
580
|
+
|
581
|
+
##
|
582
|
+
# Fixes the page_dir to be relative to the root_dir and adds the page_dir to
|
583
|
+
# the files list.
|
584
|
+
|
585
|
+
def finish_page_dir
|
586
|
+
return unless @page_dir
|
587
|
+
|
588
|
+
@files << @page_dir.to_s
|
589
|
+
|
590
|
+
page_dir = nil
|
591
|
+
begin
|
592
|
+
page_dir = @page_dir.expand_path.relative_path_from @root
|
593
|
+
rescue ArgumentError
|
594
|
+
# On Windows, sometimes crosses different drive letters.
|
595
|
+
page_dir = @page_dir.expand_path
|
596
|
+
end
|
597
|
+
|
598
|
+
@page_dir = page_dir
|
599
|
+
end
|
600
|
+
|
243
601
|
##
|
244
602
|
# Returns a properly-space list of generators and their descriptions.
|
245
603
|
|
@@ -267,9 +625,9 @@ class RDoc::Options
|
|
267
625
|
end
|
268
626
|
|
269
627
|
##
|
270
|
-
#
|
628
|
+
# Parses command line options.
|
271
629
|
|
272
|
-
def parse
|
630
|
+
def parse argv
|
273
631
|
ignore_invalid = true
|
274
632
|
|
275
633
|
argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']
|
@@ -315,44 +673,86 @@ Usage: #{opt.program_name} [options] [names...]
|
|
315
673
|
end
|
316
674
|
|
317
675
|
parsers.sort.each do |parser, regexp|
|
318
|
-
opt.banner
|
676
|
+
opt.banner += " - #{parser}: #{regexp.join ', '}\n"
|
319
677
|
end
|
678
|
+
opt.banner += " - TomDoc: Only in ruby files\n"
|
320
679
|
|
321
|
-
opt.banner
|
680
|
+
opt.banner += "\n The following options are deprecated:\n\n"
|
322
681
|
|
323
682
|
name_length = DEPRECATED.keys.sort_by { |k| k.length }.last.length
|
324
683
|
|
325
684
|
DEPRECATED.sort_by { |k,| k }.each do |name, reason|
|
326
|
-
opt.banner
|
685
|
+
opt.banner += " %*1$2$s %3$s\n" % [-name_length, name, reason]
|
327
686
|
end
|
328
687
|
|
329
688
|
opt.accept Template do |template|
|
330
689
|
template_dir = template_dir_for template
|
331
690
|
|
332
691
|
unless template_dir then
|
333
|
-
|
692
|
+
$stderr.puts "could not find template #{template}"
|
334
693
|
nil
|
335
694
|
else
|
336
695
|
[template, template_dir]
|
337
696
|
end
|
338
697
|
end
|
339
698
|
|
699
|
+
opt.accept Directory do |directory|
|
700
|
+
directory = File.expand_path directory
|
701
|
+
|
702
|
+
raise OptionParser::InvalidArgument unless File.directory? directory
|
703
|
+
|
704
|
+
directory
|
705
|
+
end
|
706
|
+
|
707
|
+
opt.accept Path do |path|
|
708
|
+
path = File.expand_path path
|
709
|
+
|
710
|
+
raise OptionParser::InvalidArgument unless File.exist? path
|
711
|
+
|
712
|
+
path
|
713
|
+
end
|
714
|
+
|
715
|
+
opt.accept PathArray do |paths,|
|
716
|
+
paths = if paths then
|
717
|
+
paths.split(',').map { |d| d unless d.empty? }
|
718
|
+
end
|
719
|
+
|
720
|
+
paths.map do |path|
|
721
|
+
path = File.expand_path path
|
722
|
+
|
723
|
+
raise OptionParser::InvalidArgument unless File.exist? path
|
724
|
+
|
725
|
+
path
|
726
|
+
end
|
727
|
+
end
|
728
|
+
|
340
729
|
opt.separator nil
|
341
730
|
opt.separator "Parsing options:"
|
342
731
|
opt.separator nil
|
343
732
|
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
733
|
+
opt.on("--encoding=ENCODING", "-e", Encoding.list.map { |e| e.name },
|
734
|
+
"Specifies the output encoding. All files",
|
735
|
+
"read will be converted to this encoding.",
|
736
|
+
"The default encoding is UTF-8.",
|
737
|
+
"--encoding is preferred over --charset") do |value|
|
738
|
+
@encoding = Encoding.find value
|
739
|
+
@charset = @encoding.name # may not be valid value
|
740
|
+
end
|
741
|
+
|
742
|
+
opt.separator nil
|
743
|
+
|
744
|
+
opt.on("--locale=NAME",
|
745
|
+
"Specifies the output locale.") do |value|
|
746
|
+
@locale_name = value
|
747
|
+
end
|
352
748
|
|
353
|
-
|
749
|
+
opt.on("--locale-data-dir=DIR",
|
750
|
+
"Specifies the directory where locale data live.") do |value|
|
751
|
+
@locale_dir = value
|
354
752
|
end
|
355
753
|
|
754
|
+
opt.separator nil
|
755
|
+
|
356
756
|
opt.on("--all", "-a",
|
357
757
|
"Synonym for --visibility=private.") do |value|
|
358
758
|
@visibility = :private
|
@@ -387,33 +787,69 @@ Usage: #{opt.program_name} [options] [names...]
|
|
387
787
|
|
388
788
|
opt.on("--[no-]force-update", "-U",
|
389
789
|
"Forces rdoc to scan all sources even if",
|
390
|
-
"newer than the flag file.") do |value|
|
790
|
+
"no files are newer than the flag file.") do |value|
|
391
791
|
@force_update = value
|
392
792
|
end
|
393
793
|
|
394
794
|
opt.separator nil
|
395
795
|
|
396
|
-
opt.on("--pipe",
|
796
|
+
opt.on("--pipe", "-p",
|
397
797
|
"Convert RDoc on stdin to HTML") do
|
398
798
|
@pipe = true
|
399
799
|
end
|
400
800
|
|
401
801
|
opt.separator nil
|
402
802
|
|
403
|
-
opt.on("--tab-width=WIDTH", "-w",
|
803
|
+
opt.on("--tab-width=WIDTH", "-w", Integer,
|
404
804
|
"Set the width of tab characters.") do |value|
|
805
|
+
raise OptionParser::InvalidArgument,
|
806
|
+
"#{value} is an invalid tab width" if value <= 0
|
405
807
|
@tab_width = value
|
406
808
|
end
|
407
809
|
|
408
810
|
opt.separator nil
|
409
811
|
|
410
|
-
opt.on("--visibility=VISIBILITY", "-V", RDoc::VISIBILITIES,
|
812
|
+
opt.on("--visibility=VISIBILITY", "-V", RDoc::VISIBILITIES + [:nodoc],
|
411
813
|
"Minimum visibility to document a method.",
|
412
|
-
"One of 'public', 'protected' (the default)",
|
413
|
-
"or '
|
814
|
+
"One of 'public', 'protected' (the default),",
|
815
|
+
"'private' or 'nodoc' (show everything)") do |value|
|
414
816
|
@visibility = value
|
415
817
|
end
|
416
818
|
|
819
|
+
opt.separator nil
|
820
|
+
|
821
|
+
markup_formats = RDoc::Text::MARKUP_FORMAT.keys.sort
|
822
|
+
|
823
|
+
opt.on("--markup=MARKUP", markup_formats,
|
824
|
+
"The markup format for the named files.",
|
825
|
+
"The default is rdoc. Valid values are:",
|
826
|
+
markup_formats.join(', ')) do |value|
|
827
|
+
@markup = value
|
828
|
+
end
|
829
|
+
|
830
|
+
opt.separator nil
|
831
|
+
|
832
|
+
opt.on("--root=ROOT", Directory,
|
833
|
+
"Root of the source tree documentation",
|
834
|
+
"will be generated for. Set this when",
|
835
|
+
"building documentation outside the",
|
836
|
+
"source directory. Default is the",
|
837
|
+
"current directory.") do |root|
|
838
|
+
@root = Pathname(root)
|
839
|
+
end
|
840
|
+
|
841
|
+
opt.separator nil
|
842
|
+
|
843
|
+
opt.on("--page-dir=DIR", Directory,
|
844
|
+
"Directory where guides, your FAQ or",
|
845
|
+
"other pages not associated with a class",
|
846
|
+
"live. Set this when you don't store",
|
847
|
+
"such files at your project root.",
|
848
|
+
"NOTE: Do not use the same file name in",
|
849
|
+
"the page dir and the root of your project") do |page_dir|
|
850
|
+
@page_dir = Pathname(page_dir)
|
851
|
+
end
|
852
|
+
|
417
853
|
opt.separator nil
|
418
854
|
opt.separator "Common generator options:"
|
419
855
|
opt.separator nil
|
@@ -440,7 +876,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
440
876
|
|
441
877
|
opt.separator nil
|
442
878
|
|
443
|
-
opt.on("--include=DIRECTORIES", "-i",
|
879
|
+
opt.on("--include=DIRECTORIES", "-i", PathArray,
|
444
880
|
"Set (or add to) the list of directories to",
|
445
881
|
"be searched when satisfying :include:",
|
446
882
|
"requests. Can be used more than once.") do |value|
|
@@ -449,9 +885,11 @@ Usage: #{opt.program_name} [options] [names...]
|
|
449
885
|
|
450
886
|
opt.separator nil
|
451
887
|
|
452
|
-
opt.on("--[no-]coverage-report", "--[no-]dcov", "-C",
|
888
|
+
opt.on("--[no-]coverage-report=[LEVEL]", "--[no-]dcov", "-C", Integer,
|
453
889
|
"Prints a report on undocumented items.",
|
454
890
|
"Does not generate files.") do |value|
|
891
|
+
value = 0 if value.nil? # Integer converts -C to nil
|
892
|
+
|
455
893
|
@coverage_report = value
|
456
894
|
@force_update = true if value
|
457
895
|
end
|
@@ -530,6 +968,14 @@ Usage: #{opt.program_name} [options] [names...]
|
|
530
968
|
|
531
969
|
opt.separator nil
|
532
970
|
|
971
|
+
opt.on("--template-stylesheets=FILES", PathArray,
|
972
|
+
"Set (or add to) the list of files to",
|
973
|
+
"include with the html template.") do |value|
|
974
|
+
@template_stylesheets << value
|
975
|
+
end
|
976
|
+
|
977
|
+
opt.separator nil
|
978
|
+
|
533
979
|
opt.on("--title=TITLE", "-t",
|
534
980
|
"Set TITLE as the title for HTML output.") do |value|
|
535
981
|
@title = value
|
@@ -537,6 +983,18 @@ Usage: #{opt.program_name} [options] [names...]
|
|
537
983
|
|
538
984
|
opt.separator nil
|
539
985
|
|
986
|
+
opt.on("--copy-files=PATH", Path,
|
987
|
+
"Specify a file or directory to copy static",
|
988
|
+
"files from.",
|
989
|
+
"If a file is given it will be copied into",
|
990
|
+
"the output dir. If a directory is given the",
|
991
|
+
"entire directory will be copied.",
|
992
|
+
"You can use this multiple times") do |value|
|
993
|
+
@static_path << value
|
994
|
+
end
|
995
|
+
|
996
|
+
opt.separator nil
|
997
|
+
|
540
998
|
opt.on("--webcvs=URL", "-W",
|
541
999
|
"Specify a URL for linking to a web frontend",
|
542
1000
|
"to CVS. If the URL contains a '\%s', the",
|
@@ -573,7 +1031,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
573
1031
|
check_generator
|
574
1032
|
|
575
1033
|
@generator_name = "ri"
|
576
|
-
@op_dir = RDoc::RI::Paths
|
1034
|
+
@op_dir = RDoc::RI::Paths.site_dir
|
577
1035
|
setup_generator
|
578
1036
|
end
|
579
1037
|
|
@@ -581,34 +1039,60 @@ Usage: #{opt.program_name} [options] [names...]
|
|
581
1039
|
opt.separator "Generic options:"
|
582
1040
|
opt.separator nil
|
583
1041
|
|
1042
|
+
opt.on("--write-options",
|
1043
|
+
"Write .rdoc_options to the current",
|
1044
|
+
"directory with the given options. Not all",
|
1045
|
+
"options will be used. See RDoc::Options",
|
1046
|
+
"for details.") do |value|
|
1047
|
+
@write_options = true
|
1048
|
+
end
|
1049
|
+
|
1050
|
+
opt.separator nil
|
1051
|
+
|
584
1052
|
opt.on("--[no-]dry-run",
|
585
1053
|
"Don't write any files") do |value|
|
586
1054
|
@dry_run = value
|
587
1055
|
end
|
588
1056
|
|
1057
|
+
opt.separator nil
|
1058
|
+
|
589
1059
|
opt.on("-D", "--[no-]debug",
|
590
1060
|
"Displays lots on internal stuff.") do |value|
|
591
1061
|
$DEBUG_RDOC = value
|
592
1062
|
end
|
593
1063
|
|
1064
|
+
opt.separator nil
|
1065
|
+
|
594
1066
|
opt.on("--[no-]ignore-invalid",
|
595
1067
|
"Ignore invalid options and continue",
|
596
1068
|
"(default true).") do |value|
|
597
1069
|
ignore_invalid = value
|
598
1070
|
end
|
599
1071
|
|
1072
|
+
opt.separator nil
|
1073
|
+
|
600
1074
|
opt.on("--quiet", "-q",
|
601
1075
|
"Don't show progress as we parse.") do |value|
|
602
1076
|
@verbosity = 0
|
603
1077
|
end
|
604
1078
|
|
605
|
-
opt.
|
1079
|
+
opt.separator nil
|
1080
|
+
|
1081
|
+
opt.on("--verbose", "-V",
|
606
1082
|
"Display extra progress as RDoc parses") do |value|
|
607
1083
|
@verbosity = 2
|
608
1084
|
end
|
609
1085
|
|
610
|
-
opt.
|
611
|
-
|
1086
|
+
opt.separator nil
|
1087
|
+
|
1088
|
+
opt.on("--version", "-v", "print the version") do
|
1089
|
+
puts opt.version
|
1090
|
+
exit
|
1091
|
+
end
|
1092
|
+
|
1093
|
+
opt.separator nil
|
1094
|
+
|
1095
|
+
opt.on("--help", "-h", "Display this help") do
|
612
1096
|
RDoc::RDoc::GENERATORS.each_key do |generator|
|
613
1097
|
setup_generator generator
|
614
1098
|
end
|
@@ -628,7 +1112,7 @@ Usage: #{opt.program_name} [options] [names...]
|
|
628
1112
|
|
629
1113
|
begin
|
630
1114
|
opts.parse! argv
|
631
|
-
rescue OptionParser::
|
1115
|
+
rescue OptionParser::ParseError => e
|
632
1116
|
if DEPRECATED[e.args.first] then
|
633
1117
|
deprecated << e.args.first
|
634
1118
|
elsif %w[--format --ri -r --ri-site -R].include? e.args.first then
|
@@ -652,43 +1136,37 @@ Usage: #{opt.program_name} [options] [names...]
|
|
652
1136
|
|
653
1137
|
unless quiet then
|
654
1138
|
deprecated.each do |opt|
|
655
|
-
$stderr.puts 'option '
|
1139
|
+
$stderr.puts 'option ' + opt + ' is deprecated: ' + DEPRECATED[opt]
|
656
1140
|
end
|
1141
|
+
end
|
657
1142
|
|
658
|
-
|
659
|
-
|
1143
|
+
unless invalid.empty? then
|
1144
|
+
invalid = "invalid options: #{invalid.join ', '}"
|
660
1145
|
|
661
|
-
|
1146
|
+
if ignore_invalid then
|
1147
|
+
unless quiet then
|
662
1148
|
$stderr.puts invalid
|
663
1149
|
$stderr.puts '(invalid options are ignored)'
|
664
|
-
|
1150
|
+
end
|
1151
|
+
else
|
1152
|
+
unless quiet then
|
665
1153
|
$stderr.puts opts
|
666
|
-
$stderr.puts invalid
|
667
|
-
exit 1
|
668
1154
|
end
|
1155
|
+
$stderr.puts invalid
|
1156
|
+
exit 1
|
669
1157
|
end
|
670
1158
|
end
|
671
1159
|
|
672
|
-
@op_dir ||= 'doc'
|
673
1160
|
@files = argv.dup
|
674
1161
|
|
675
|
-
|
1162
|
+
finish
|
676
1163
|
|
677
|
-
if @
|
678
|
-
|
679
|
-
|
680
|
-
@exclude = Regexp.new(@exclude.join("|"))
|
1164
|
+
if @write_options then
|
1165
|
+
write_options
|
1166
|
+
exit
|
681
1167
|
end
|
682
1168
|
|
683
|
-
|
684
|
-
|
685
|
-
# If no template was specified, use the default template for the output
|
686
|
-
# formatter
|
687
|
-
|
688
|
-
unless @template then
|
689
|
-
@template = @generator_name
|
690
|
-
@template_dir = template_dir_for @template
|
691
|
-
end
|
1169
|
+
self
|
692
1170
|
end
|
693
1171
|
|
694
1172
|
##
|
@@ -705,6 +1183,29 @@ Usage: #{opt.program_name} [options] [names...]
|
|
705
1183
|
@verbosity = bool ? 0 : 1
|
706
1184
|
end
|
707
1185
|
|
1186
|
+
##
|
1187
|
+
# Removes directories from +path+ that are outside the current directory
|
1188
|
+
|
1189
|
+
def sanitize_path path
|
1190
|
+
require 'pathname'
|
1191
|
+
dot = Pathname.new('.').expand_path
|
1192
|
+
|
1193
|
+
path.reject do |item|
|
1194
|
+
path = Pathname.new(item).expand_path
|
1195
|
+
is_reject = nil
|
1196
|
+
relative = nil
|
1197
|
+
begin
|
1198
|
+
relative = path.relative_path_from(dot).to_s
|
1199
|
+
rescue ArgumentError
|
1200
|
+
# On Windows, sometimes crosses different drive letters.
|
1201
|
+
is_reject = true
|
1202
|
+
else
|
1203
|
+
is_reject = relative.start_with? '..'
|
1204
|
+
end
|
1205
|
+
is_reject
|
1206
|
+
end
|
1207
|
+
end
|
1208
|
+
|
708
1209
|
##
|
709
1210
|
# Set up an output generator for the named +generator_name+.
|
710
1211
|
#
|
@@ -725,7 +1226,10 @@ Usage: #{opt.program_name} [options] [names...]
|
|
725
1226
|
@generator_name = generator_name
|
726
1227
|
@generator_options << @generator
|
727
1228
|
|
728
|
-
|
1229
|
+
if @generator.respond_to? :setup_options then
|
1230
|
+
@option_parser ||= OptionParser.new
|
1231
|
+
@generator.setup_options self
|
1232
|
+
end
|
729
1233
|
end
|
730
1234
|
|
731
1235
|
##
|
@@ -741,5 +1245,41 @@ Usage: #{opt.program_name} [options] [names...]
|
|
741
1245
|
end
|
742
1246
|
end
|
743
1247
|
|
744
|
-
|
1248
|
+
# Sets the minimum visibility of a documented method.
|
1249
|
+
#
|
1250
|
+
# Accepts +:public+, +:protected+, +:private+, +:nodoc+, or +:all+.
|
1251
|
+
#
|
1252
|
+
# When +:all+ is passed, visibility is set to +:private+, similarly to
|
1253
|
+
# RDOCOPT="--all", see #visibility for more information.
|
1254
|
+
|
1255
|
+
def visibility= visibility
|
1256
|
+
case visibility
|
1257
|
+
when :all
|
1258
|
+
@visibility = :private
|
1259
|
+
else
|
1260
|
+
@visibility = visibility
|
1261
|
+
end
|
1262
|
+
end
|
745
1263
|
|
1264
|
+
##
|
1265
|
+
# Displays a warning using Kernel#warn if we're being verbose
|
1266
|
+
|
1267
|
+
def warn message
|
1268
|
+
super message if @verbosity > 1
|
1269
|
+
end
|
1270
|
+
|
1271
|
+
##
|
1272
|
+
# Writes the YAML file .rdoc_options to the current directory containing the
|
1273
|
+
# parsed options.
|
1274
|
+
|
1275
|
+
def write_options
|
1276
|
+
RDoc.load_yaml
|
1277
|
+
|
1278
|
+
File.open '.rdoc_options', 'w' do |io|
|
1279
|
+
io.set_encoding Encoding::UTF_8
|
1280
|
+
|
1281
|
+
YAML.dump self, io
|
1282
|
+
end
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
end
|