Class: RDoc::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/sdoc/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

:nodoc:



8
9
10
11
12
# File 'lib/sdoc/options.rb', line 8

def initialize # :nodoc:
  rdoc_initialize
  @open_source = false
  @generator = RDoc::Generator::SHtml
end

Instance Attribute Details

#open_sourceObject

Should source be included?



4
5
6
# File 'lib/sdoc/options.rb', line 4

def open_source
  @open_source
end

Instance Method Details

#parse(argv) ⇒ Object

Parse command line options. (Copied from RDoc)



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# File 'lib/sdoc/options.rb', line 16

def parse(argv)
  opts = OptionParser.new do |opt|
    opt.program_name = File.basename $0
    opt.version = RDoc::VERSION
    opt.release = nil
    opt.summary_indent = ' ' * 4
    opt.banner = "Usage: \#{opt.program_name} [options] [names...]\n\nFiles are parsed, and the information they contain collected, before any\noutput is produced. This allows cross references between all files to be\nresolved. If a name is a directory, it is traversed. If no names are\nspecified, all Ruby files in the current directory (and subdirectories) are\nprocessed.\n\nHow RDoc generates output depends on the output formatter being used, and on\nthe options you give.\n\n- Darkfish creates frameless HTML output by Michael Granger.\n\n- ri creates ri data files\n    EOF\n\n    opt.separator nil\n    opt.separator \"Parsing Options:\"\n    opt.separator nil\n\n    opt.on(\"--all\", \"-a\",\n           \"Include all methods (not just public) in\",\n           \"the output.\") do |value|\n      @show_all = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--exclude=PATTERN\", \"-x\", Regexp,\n           \"Do not process files or directories\",\n           \"matching PATTERN.\") do |value|\n      @exclude << value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--extension=NEW=OLD\", \"-E\",\n           \"Treat files ending with .new as if they\",\n           \"ended with .old. Using '-E cgi=rb' will\",\n           \"cause xxx.cgi to be parsed as a Ruby file.\") do |value|\n      new, old = value.split(/=/, 2)\n\n      unless new and old then\n        raise OptionParser::InvalidArgument, \"Invalid parameter to '-E'\"\n      end\n\n      unless RDoc::ParserFactory.alias_extension old, new then\n        raise OptionParser::InvalidArgument, \"Unknown extension .\#{old} to -E\"\n      end\n    end\n\n    opt.separator nil\n\n    opt.on(\"--force-update\", \"-U\",\n           \"Forces rdoc to scan all sources even if\",\n           \"newer than the flag file.\") do |value|\n      @force_update = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--pipe\",\n           \"Convert RDoc on stdin to HTML\") do\n      @pipe = true\n    end\n\n    opt.separator nil\n\n    opt.on(\"--threads=THREADS\", Integer,\n           \"Number of threads to parse with.\") do |threads|\n      @threads = threads\n    end\n\n    opt.separator nil\n    opt.separator \"Generator Options:\"\n    opt.separator nil\n\n    opt.on(\"--charset=CHARSET\", \"-c\",\n           \"Specifies the output HTML character-set.\") do |value|\n      @charset = value\n    end\n\n    opt.separator nil\n\n    generator_text = @generators.keys.map { |name| \"  \#{name}\" }.sort\n\n    opt.on(\"--fmt=FORMAT\", \"--format=FORMAT\", \"-f\", @generators.keys,\n           \"Set the output formatter.  One of:\", *generator_text) do |value|\n      @generator_name = value.downcase\n      setup_generator\n    end\n\n    opt.separator nil\n\n    opt.on(\"--include=DIRECTORIES\", \"-i\", Array,\n           \"Set (or add to) the list of directories to\",\n           \"be searched when satisfying :include:\",\n           \"requests. Can be used more than once.\") do |value|\n      @rdoc_include.concat value.map { |dir| dir.strip }\n    end\n\n    opt.separator nil\n\n    opt.on(\"--line-numbers\", \"-N\",\n           \"Include line numbers in the source code.\") do |value|\n      @include_line_numbers = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--main=NAME\", \"-m\",\n           \"NAME will be the initial page displayed.\") do |value|\n      @main_page = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--output=DIR\", \"--op\", \"-o\",\n           \"Set the output directory.\") do |value|\n      @op_dir = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--show-hash\", \"-H\",\n           \"A name of the form #name in a comment is a\",\n           \"possible hyperlink to an instance method\",\n           \"name. When displayed, the '#' is removed\",\n           \"unless this option is specified.\") do |value|\n      @show_hash = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--open-source\", \"-s\",\n           \"Include source code to your documentation\") do |value|\n      @open_source = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--tab-width=WIDTH\", \"-w\", OptionParser::DecimalInteger,\n           \"Set the width of tab characters.\") do |value|\n      @tab_width = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--template=NAME\", \"-T\",\n           \"Set the template used when generating\",\n           \"output.\") do |value|\n      @template = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--title=TITLE\", \"-t\",\n           \"Set TITLE as the title for HTML output.\") do |value|\n      @title = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--webcvs=URL\", \"-W\",\n           \"Specify a URL for linking to a web frontend\",\n           \"to CVS. If the URL contains a '\\%s', the\",\n           \"name of the current file will be\",\n           \"substituted; if the URL doesn't contain a\",\n           \"'\\%s', the filename will be appended to it.\") do |value|\n      @webcvs = value\n    end\n\n    opt.separator nil\n    opt.separator \"Diagram Options:\"\n    opt.separator nil\n\n    image_formats = %w[gif png jpg jpeg]\n    opt.on(\"--image-format=FORMAT\", \"-I\", image_formats,\n           \"Sets output image format for diagrams. Can\",\n           \"be \#{image_formats.join ', '}. If this option\",\n           \"is omitted, png is used. Requires\",\n           \"diagrams.\") do |value|\n      @image_format = value\n    end\n\n    opt.separator nil\n\n    opt.on(\"--diagram\", \"-d\",\n           \"Generate diagrams showing modules and\",\n           \"classes. You need dot V1.8.6 or later to\",\n           \"use the --diagram option correctly. Dot is\",\n           \"available from http://graphviz.org\") do |value|\n      check_diagram\n      @diagram = true\n    end\n\n    opt.separator nil\n\n    opt.on(\"--fileboxes\", \"-F\",\n           \"Classes are put in boxes which represents\",\n           \"files, where these classes reside. Classes\",\n           \"shared between more than one file are\",\n           \"shown with list of files that are sharing\",\n           \"them. Silently discarded if --diagram is\",\n           \"not given.\") do |value|\n      @fileboxes = value\n    end\n\n    opt.separator nil\n    opt.separator \"ri Generator Options:\"\n    opt.separator nil\n\n    opt.on(\"--ri\", \"-r\",\n           \"Generate output for use by `ri`. The files\",\n           \"are stored in the '.rdoc' directory under\",\n           \"your home directory unless overridden by a\",\n           \"subsequent --op parameter, so no special\",\n           \"privileges are needed.\") do |value|\n      @generator_name = \"ri\"\n      @op_dir = RDoc::RI::Paths::HOMEDIR\n      setup_generator\n    end\n\n    opt.separator nil\n\n    opt.on(\"--ri-site\", \"-R\",\n           \"Generate output for use by `ri`. The files\",\n           \"are stored in a site-wide directory,\",\n           \"making them accessible to others, so\",\n           \"special privileges are needed.\") do |value|\n      @generator_name = \"ri\"\n      @op_dir = RDoc::RI::Paths::SITEDIR\n      setup_generator\n    end\n\n    opt.separator nil\n\n    opt.on(\"--merge\", \"-M\",\n           \"When creating ri output, merge previously\",\n           \"processed classes into previously\",\n           \"documented classes of the same name.\") do |value|\n      @merge = value\n    end\n\n    opt.separator nil\n    opt.separator \"Generic Options:\"\n    opt.separator nil\n\n    opt.on(\"--debug\", \"-D\",\n           \"Displays lots on internal stuff.\") do |value|\n      $DEBUG_RDOC = value\n    end\n\n    opt.on(\"--quiet\", \"-q\",\n           \"Don't show progress as we parse.\") do |value|\n      @verbosity = 0\n    end\n\n    opt.on(\"--verbose\", \"-v\",\n           \"Display extra progress as we parse.\") do |value|\n      @verbosity = 2\n    end\n\n    opt.separator nil\n    opt.separator 'Deprecated options - these warn when set'\n    opt.separator nil\n\n    opt.on(\"--inline-source\", \"-S\") do |value|\n      warn \"--inline-source will be removed from RDoc on or after August 2009\"\n    end\n\n    opt.on(\"--promiscuous\", \"-p\") do |value|\n      warn \"--promiscuous will be removed from RDoc on or after August 2009\"\n    end\n\n    opt.separator nil\n  end\n\n  argv.insert(0, *ENV['RDOCOPT'].split) if ENV['RDOCOPT']\n\n  opts.parse! argv\n\n  @files = argv.dup\n\n  @rdoc_include << \".\" if @rdoc_include.empty?\n\n  if @exclude.empty? then\n    @exclude = nil\n  else\n    @exclude = Regexp.new(@exclude.join(\"|\"))\n  end\n\n  check_files\n\n  # If no template was specified, use the default template for the output\n  # formatter\n\n  @template ||= @generator_name\n\nrescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e\n  puts opts\n  puts\n  puts e\n  exit 1\nend\n"

#rdoc_initializeObject



6
# File 'lib/sdoc/options.rb', line 6

alias_method :rdoc_initialize, :initialize