docscribe 1.4.2 → 1.5.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.
- checksums.yaml +4 -4
- data/README.md +465 -130
- data/lib/docscribe/cli/check_for_comments.rb +183 -0
- data/lib/docscribe/cli/config_builder.rb +107 -53
- data/lib/docscribe/cli/formatters/json.rb +294 -0
- data/lib/docscribe/cli/formatters/sarif.rb +235 -0
- data/lib/docscribe/cli/formatters/text.rb +208 -0
- data/lib/docscribe/cli/formatters.rb +26 -0
- data/lib/docscribe/cli/generate.rb +45 -45
- data/lib/docscribe/cli/init.rb +14 -6
- data/lib/docscribe/cli/options.rb +190 -88
- data/lib/docscribe/cli/rbs_gen.rb +529 -0
- data/lib/docscribe/cli/run.rb +210 -152
- data/lib/docscribe/cli/sigs.rb +366 -0
- data/lib/docscribe/cli/update_types.rb +103 -0
- data/lib/docscribe/cli.rb +21 -13
- data/lib/docscribe/config/defaults.rb +5 -1
- data/lib/docscribe/config/emit.rb +17 -0
- data/lib/docscribe/config/filtering.rb +18 -25
- data/lib/docscribe/config/loader.rb +15 -11
- data/lib/docscribe/config/plugin.rb +1 -1
- data/lib/docscribe/config/rbs.rb +41 -9
- data/lib/docscribe/config/sorbet.rb +9 -12
- data/lib/docscribe/config/sorting.rb +1 -1
- data/lib/docscribe/config/template.rb +9 -1
- data/lib/docscribe/config/utils.rb +11 -9
- data/lib/docscribe/config.rb +2 -4
- data/lib/docscribe/infer/ast_walk.rb +1 -1
- data/lib/docscribe/infer/literals.rb +6 -11
- data/lib/docscribe/infer/names.rb +2 -3
- data/lib/docscribe/infer/params.rb +15 -17
- data/lib/docscribe/infer/raises.rb +3 -5
- data/lib/docscribe/infer/returns.rb +542 -140
- data/lib/docscribe/infer.rb +22 -23
- data/lib/docscribe/inline_rewriter/collector.rb +159 -164
- data/lib/docscribe/inline_rewriter/doc_block.rb +145 -115
- data/lib/docscribe/inline_rewriter/doc_builder.rb +1026 -723
- data/lib/docscribe/inline_rewriter/source_helpers.rb +49 -49
- data/lib/docscribe/inline_rewriter/tag_sorter.rb +82 -85
- data/lib/docscribe/inline_rewriter.rb +495 -492
- data/lib/docscribe/parsing.rb +29 -10
- data/lib/docscribe/plugin/base/collector_plugin.rb +2 -1
- data/lib/docscribe/plugin/base/tag_plugin.rb +0 -1
- data/lib/docscribe/plugin/context.rb +28 -18
- data/lib/docscribe/plugin/registry.rb +26 -27
- data/lib/docscribe/plugin/tag.rb +9 -14
- data/lib/docscribe/plugin.rb +17 -16
- data/lib/docscribe/types/provider_chain.rb +4 -2
- data/lib/docscribe/types/rbs/collection_loader.rb +2 -2
- data/lib/docscribe/types/rbs/provider.rb +60 -44
- data/lib/docscribe/types/rbs/type_formatter.rb +224 -83
- data/lib/docscribe/types/signature.rb +22 -42
- data/lib/docscribe/types/sorbet/base_provider.rb +24 -19
- data/lib/docscribe/types/sorbet/rbi_provider.rb +3 -3
- data/lib/docscribe/types/sorbet/source_provider.rb +3 -2
- data/lib/docscribe/types/yard/formatter.rb +100 -0
- data/lib/docscribe/types/yard/parser.rb +240 -0
- data/lib/docscribe/types/yard/types.rb +52 -0
- data/lib/docscribe/version.rb +1 -1
- metadata +33 -1
|
@@ -12,6 +12,8 @@ module Docscribe
|
|
|
12
12
|
strategy: :safe, # :safe, :aggressive
|
|
13
13
|
verbose: false,
|
|
14
14
|
explain: false,
|
|
15
|
+
quiet: false,
|
|
16
|
+
format: :text,
|
|
15
17
|
config: nil,
|
|
16
18
|
include: [], #: Array[String]
|
|
17
19
|
exclude: [], #: Array[String]
|
|
@@ -21,13 +23,22 @@ module Docscribe
|
|
|
21
23
|
sig_dirs: [], #: Array[String]
|
|
22
24
|
sorbet: false,
|
|
23
25
|
rbi_dirs: [], #: Array[String]
|
|
24
|
-
rbs_collection: false
|
|
26
|
+
rbs_collection: false,
|
|
27
|
+
keep_descriptions: false,
|
|
28
|
+
no_boilerplate: false,
|
|
29
|
+
progress: false
|
|
25
30
|
}.freeze
|
|
26
31
|
|
|
27
32
|
module_function
|
|
28
33
|
|
|
29
34
|
BANNER = <<~TEXT
|
|
30
35
|
Usage: docscribe [options] [files...]
|
|
36
|
+
docscribe init [options]
|
|
37
|
+
docscribe generate <type> <name> [options]
|
|
38
|
+
docscribe sigs [options] [files...]
|
|
39
|
+
docscribe rbs [options] [files...]
|
|
40
|
+
docscribe update_types [directory]
|
|
41
|
+
docscribe check_for_comments [paths...]
|
|
31
42
|
|
|
32
43
|
Default behavior:
|
|
33
44
|
Inspect files and report what safe doc updates would be applied.
|
|
@@ -58,7 +69,11 @@ module Docscribe
|
|
|
58
69
|
|
|
59
70
|
Output:
|
|
60
71
|
--verbose Print per-file actions
|
|
61
|
-
|
|
72
|
+
--progress Show progress [N/total] per file
|
|
73
|
+
-e, --explain Show detailed reasons for changes (default)
|
|
74
|
+
-q, --quiet Only show status, no details
|
|
75
|
+
--format FORMAT Output format: text (default), json, or sarif
|
|
76
|
+
|
|
62
77
|
|
|
63
78
|
Other:
|
|
64
79
|
-v, --version Print version and exit
|
|
@@ -76,9 +91,9 @@ module Docscribe
|
|
|
76
91
|
# Filtering, config, verbosity, and external type options are applied
|
|
77
92
|
# orthogonally.
|
|
78
93
|
#
|
|
79
|
-
# @note module_function:
|
|
94
|
+
# @note module_function: defines #parse! (visibility: private)
|
|
80
95
|
# @param [Array<String>] argv raw CLI arguments
|
|
81
|
-
# @return [
|
|
96
|
+
# @return [Docscribe::CLI::Formatters::opts] normalized runtime options
|
|
82
97
|
def parse!(argv)
|
|
83
98
|
options = Marshal.load(Marshal.dump(DEFAULT))
|
|
84
99
|
autocorrect = { mode: nil }
|
|
@@ -90,9 +105,9 @@ module Docscribe
|
|
|
90
105
|
|
|
91
106
|
# Build the OptionParser instance and register all CLI option groups.
|
|
92
107
|
#
|
|
93
|
-
# @note module_function:
|
|
94
|
-
# @param [Hash] options mutable parsed options hash
|
|
95
|
-
# @param [Hash
|
|
108
|
+
# @note module_function: defines #build_option_parser (visibility: private)
|
|
109
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
110
|
+
# @param [Hash<Symbol, Symbol, nil>] autocorrect mutable container for autocorrect mode
|
|
96
111
|
# @return [OptionParser]
|
|
97
112
|
def build_option_parser(options, autocorrect)
|
|
98
113
|
OptionParser.new do |opts|
|
|
@@ -106,10 +121,11 @@ module Docscribe
|
|
|
106
121
|
end
|
|
107
122
|
end
|
|
108
123
|
|
|
109
|
-
#
|
|
110
|
-
#
|
|
111
|
-
# @
|
|
112
|
-
# @param [
|
|
124
|
+
# Define autocorrect options
|
|
125
|
+
#
|
|
126
|
+
# @note module_function: defines #define_autocorrect_options (visibility: private)
|
|
127
|
+
# @param [OptionParser] opts the option parser to configure
|
|
128
|
+
# @param [Hash<Symbol, Symbol, nil>] autocorrect mutable container for autocorrect mode (:safe, :aggressive, nil)
|
|
113
129
|
# @return [void]
|
|
114
130
|
def define_autocorrect_options(opts, autocorrect)
|
|
115
131
|
opts.on('-a', '--autocorrect', 'Apply safe doc updates in place') do
|
|
@@ -121,20 +137,22 @@ module Docscribe
|
|
|
121
137
|
end
|
|
122
138
|
end
|
|
123
139
|
|
|
124
|
-
#
|
|
125
|
-
#
|
|
126
|
-
# @
|
|
127
|
-
# @param [
|
|
140
|
+
# Define input options
|
|
141
|
+
#
|
|
142
|
+
# @note module_function: defines #define_input_options (visibility: private)
|
|
143
|
+
# @param [OptionParser] opts the option parser to configure
|
|
144
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
128
145
|
# @return [void]
|
|
129
146
|
def define_input_options(opts, options)
|
|
130
147
|
define_stdin_option(opts, options)
|
|
131
148
|
define_config_option(opts, options)
|
|
132
149
|
end
|
|
133
150
|
|
|
134
|
-
#
|
|
135
|
-
#
|
|
136
|
-
# @
|
|
137
|
-
# @param [
|
|
151
|
+
# Define stdin option
|
|
152
|
+
#
|
|
153
|
+
# @note module_function: defines #define_stdin_option (visibility: private)
|
|
154
|
+
# @param [OptionParser] opts the option parser to configure
|
|
155
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
138
156
|
# @return [void]
|
|
139
157
|
def define_stdin_option(opts, options)
|
|
140
158
|
opts.on('--stdin', 'Read code from STDIN and print rewritten output') do
|
|
@@ -142,10 +160,11 @@ module Docscribe
|
|
|
142
160
|
end
|
|
143
161
|
end
|
|
144
162
|
|
|
145
|
-
#
|
|
146
|
-
#
|
|
147
|
-
# @
|
|
148
|
-
# @param [
|
|
163
|
+
# Define config option
|
|
164
|
+
#
|
|
165
|
+
# @note module_function: defines #define_config_option (visibility: private)
|
|
166
|
+
# @param [OptionParser] opts the option parser to configure
|
|
167
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
149
168
|
# @return [void]
|
|
150
169
|
def define_config_option(opts, options)
|
|
151
170
|
opts.on('-C', '--config PATH', 'Path to config YAML (default: docscribe.yml)') do |v|
|
|
@@ -153,10 +172,11 @@ module Docscribe
|
|
|
153
172
|
end
|
|
154
173
|
end
|
|
155
174
|
|
|
156
|
-
#
|
|
157
|
-
#
|
|
158
|
-
# @
|
|
159
|
-
# @param [
|
|
175
|
+
# Define type options
|
|
176
|
+
#
|
|
177
|
+
# @note module_function: defines #define_type_options (visibility: private)
|
|
178
|
+
# @param [OptionParser] opts the option parser to configure
|
|
179
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
160
180
|
# @return [void]
|
|
161
181
|
def define_type_options(opts, options)
|
|
162
182
|
define_rbs_option(opts, options)
|
|
@@ -166,10 +186,11 @@ module Docscribe
|
|
|
166
186
|
define_rbs_collection_option(opts, options)
|
|
167
187
|
end
|
|
168
188
|
|
|
169
|
-
#
|
|
170
|
-
#
|
|
171
|
-
# @
|
|
172
|
-
# @param [
|
|
189
|
+
# Define rbs option
|
|
190
|
+
#
|
|
191
|
+
# @note module_function: defines #define_rbs_option (visibility: private)
|
|
192
|
+
# @param [OptionParser] opts the option parser to configure
|
|
193
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
173
194
|
# @return [void]
|
|
174
195
|
def define_rbs_option(opts, options)
|
|
175
196
|
opts.on('--rbs', 'Use RBS signatures for @param/@return when available (falls back to inference)') do
|
|
@@ -177,10 +198,11 @@ module Docscribe
|
|
|
177
198
|
end
|
|
178
199
|
end
|
|
179
200
|
|
|
180
|
-
#
|
|
181
|
-
#
|
|
182
|
-
# @
|
|
183
|
-
# @param [
|
|
201
|
+
# Define sig dir option
|
|
202
|
+
#
|
|
203
|
+
# @note module_function: defines #define_sig_dir_option (visibility: private)
|
|
204
|
+
# @param [OptionParser] opts the option parser to configure
|
|
205
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
184
206
|
# @return [void]
|
|
185
207
|
def define_sig_dir_option(opts, options)
|
|
186
208
|
opts.on('--sig-dir DIR', 'Add an RBS signature directory (repeatable). Implies --rbs.') do |v|
|
|
@@ -189,10 +211,11 @@ module Docscribe
|
|
|
189
211
|
end
|
|
190
212
|
end
|
|
191
213
|
|
|
192
|
-
#
|
|
193
|
-
#
|
|
194
|
-
# @
|
|
195
|
-
# @param [
|
|
214
|
+
# Define sorbet option
|
|
215
|
+
#
|
|
216
|
+
# @note module_function: defines #define_sorbet_option (visibility: private)
|
|
217
|
+
# @param [OptionParser] opts the option parser to configure
|
|
218
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
196
219
|
# @return [void]
|
|
197
220
|
def define_sorbet_option(opts, options)
|
|
198
221
|
opts.on('--sorbet', 'Use Sorbet signatures from inline sigs / RBI files when available') do
|
|
@@ -200,10 +223,11 @@ module Docscribe
|
|
|
200
223
|
end
|
|
201
224
|
end
|
|
202
225
|
|
|
203
|
-
#
|
|
204
|
-
#
|
|
205
|
-
# @
|
|
206
|
-
# @param [
|
|
226
|
+
# Define rbi dir option
|
|
227
|
+
#
|
|
228
|
+
# @note module_function: defines #define_rbi_dir_option (visibility: private)
|
|
229
|
+
# @param [OptionParser] opts the option parser to configure
|
|
230
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
207
231
|
# @return [void]
|
|
208
232
|
def define_rbi_dir_option(opts, options)
|
|
209
233
|
opts.on('--rbi-dir DIR', 'Add a Sorbet RBI directory (repeatable). Implies --sorbet.') do |v|
|
|
@@ -212,10 +236,11 @@ module Docscribe
|
|
|
212
236
|
end
|
|
213
237
|
end
|
|
214
238
|
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
# @
|
|
218
|
-
# @param [
|
|
239
|
+
# Define rbs collection option
|
|
240
|
+
#
|
|
241
|
+
# @note module_function: defines #define_rbs_collection_option (visibility: private)
|
|
242
|
+
# @param [OptionParser] opts the option parser to configure
|
|
243
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
219
244
|
# @return [void]
|
|
220
245
|
def define_rbs_collection_option(opts, options)
|
|
221
246
|
opts.on('--rbs-collection', 'Auto-discover RBS collection from rbs_collection.lock.yaml. Implies --rbs.') do
|
|
@@ -224,10 +249,11 @@ module Docscribe
|
|
|
224
249
|
end
|
|
225
250
|
end
|
|
226
251
|
|
|
227
|
-
#
|
|
228
|
-
#
|
|
229
|
-
# @
|
|
230
|
-
# @param [
|
|
252
|
+
# Define filter options
|
|
253
|
+
#
|
|
254
|
+
# @note module_function: defines #define_filter_options (visibility: private)
|
|
255
|
+
# @param [OptionParser] opts the option parser to configure
|
|
256
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
231
257
|
# @return [void]
|
|
232
258
|
def define_filter_options(opts, options)
|
|
233
259
|
define_include_option(opts, options)
|
|
@@ -236,10 +262,11 @@ module Docscribe
|
|
|
236
262
|
define_exclude_file_option(opts, options)
|
|
237
263
|
end
|
|
238
264
|
|
|
239
|
-
#
|
|
240
|
-
#
|
|
241
|
-
# @
|
|
242
|
-
# @param [
|
|
265
|
+
# Define include option
|
|
266
|
+
#
|
|
267
|
+
# @note module_function: defines #define_include_option (visibility: private)
|
|
268
|
+
# @param [OptionParser] opts the option parser to configure
|
|
269
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
243
270
|
# @return [void]
|
|
244
271
|
def define_include_option(opts, options)
|
|
245
272
|
opts.on('--include PATTERN', 'Include PATTERN (method id or file path; glob or /regex/)') do |v|
|
|
@@ -247,10 +274,11 @@ module Docscribe
|
|
|
247
274
|
end
|
|
248
275
|
end
|
|
249
276
|
|
|
250
|
-
#
|
|
251
|
-
#
|
|
252
|
-
# @
|
|
253
|
-
# @param [
|
|
277
|
+
# Define exclude option
|
|
278
|
+
#
|
|
279
|
+
# @note module_function: defines #define_exclude_option (visibility: private)
|
|
280
|
+
# @param [OptionParser] opts the option parser to configure
|
|
281
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
254
282
|
# @return [void]
|
|
255
283
|
def define_exclude_option(opts, options)
|
|
256
284
|
opts.on('--exclude PATTERN',
|
|
@@ -259,10 +287,11 @@ module Docscribe
|
|
|
259
287
|
end
|
|
260
288
|
end
|
|
261
289
|
|
|
262
|
-
#
|
|
263
|
-
#
|
|
264
|
-
# @
|
|
265
|
-
# @param [
|
|
290
|
+
# Define include file option
|
|
291
|
+
#
|
|
292
|
+
# @note module_function: defines #define_include_file_option (visibility: private)
|
|
293
|
+
# @param [OptionParser] opts the option parser to configure
|
|
294
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
266
295
|
# @return [void]
|
|
267
296
|
def define_include_file_option(opts, options)
|
|
268
297
|
opts.on('--include-file PATTERN', 'Only process files matching PATTERN (glob or /regex/)') do |v|
|
|
@@ -270,10 +299,11 @@ module Docscribe
|
|
|
270
299
|
end
|
|
271
300
|
end
|
|
272
301
|
|
|
273
|
-
#
|
|
274
|
-
#
|
|
275
|
-
# @
|
|
276
|
-
# @param [
|
|
302
|
+
# Define exclude file option
|
|
303
|
+
#
|
|
304
|
+
# @note module_function: defines #define_exclude_file_option (visibility: private)
|
|
305
|
+
# @param [OptionParser] opts the option parser to configure
|
|
306
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
277
307
|
# @return [void]
|
|
278
308
|
def define_exclude_file_option(opts, options)
|
|
279
309
|
opts.on('--exclude-file PATTERN', 'Skip files matching PATTERN (glob or /regex/). Exclude wins.') do |v|
|
|
@@ -281,31 +311,52 @@ module Docscribe
|
|
|
281
311
|
end
|
|
282
312
|
end
|
|
283
313
|
|
|
284
|
-
#
|
|
285
|
-
#
|
|
286
|
-
# @
|
|
287
|
-
# @param [
|
|
314
|
+
# Define output options
|
|
315
|
+
#
|
|
316
|
+
# @note module_function: defines #define_output_options (visibility: private)
|
|
317
|
+
# @param [OptionParser] opts the option parser to configure
|
|
318
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
288
319
|
# @return [void]
|
|
289
320
|
def define_output_options(opts, options)
|
|
290
321
|
define_verbose_option(opts, options)
|
|
322
|
+
define_progress_option(opts, options)
|
|
291
323
|
define_explain_option(opts, options)
|
|
324
|
+
define_quiet_option(opts, options)
|
|
325
|
+
define_format_option(opts, options)
|
|
326
|
+
define_keep_descriptions_option(opts, options)
|
|
327
|
+
define_no_boilerplate_option(opts, options)
|
|
292
328
|
end
|
|
293
329
|
|
|
294
|
-
#
|
|
295
|
-
#
|
|
296
|
-
# @
|
|
297
|
-
# @param [
|
|
330
|
+
# Define verbose option
|
|
331
|
+
#
|
|
332
|
+
# @note module_function: defines #define_verbose_option (visibility: private)
|
|
333
|
+
# @param [OptionParser] opts the option parser to configure
|
|
334
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
298
335
|
# @return [void]
|
|
299
336
|
def define_verbose_option(opts, options)
|
|
300
337
|
opts.on('--verbose', 'Print per-file actions') do
|
|
301
338
|
options[:verbose] = true
|
|
339
|
+
options[:progress] = true
|
|
302
340
|
end
|
|
303
341
|
end
|
|
304
342
|
|
|
305
|
-
#
|
|
306
|
-
#
|
|
307
|
-
# @
|
|
308
|
-
# @param [
|
|
343
|
+
# Define progress option
|
|
344
|
+
#
|
|
345
|
+
# @note module_function: defines #define_progress_option (visibility: private)
|
|
346
|
+
# @param [OptionParser] opts the option parser to configure
|
|
347
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
348
|
+
# @return [void]
|
|
349
|
+
def define_progress_option(opts, options)
|
|
350
|
+
opts.on('--progress', 'Show progress [N/total] per file') do
|
|
351
|
+
options[:progress] = true
|
|
352
|
+
end
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
# Define explain option
|
|
356
|
+
#
|
|
357
|
+
# @note module_function: defines #define_explain_option (visibility: private)
|
|
358
|
+
# @param [OptionParser] opts the option parser to configure
|
|
359
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
309
360
|
# @return [void]
|
|
310
361
|
def define_explain_option(opts, options)
|
|
311
362
|
opts.on('-e', '--explain', 'Show detailed reasons for changes') do
|
|
@@ -313,9 +364,61 @@ module Docscribe
|
|
|
313
364
|
end
|
|
314
365
|
end
|
|
315
366
|
|
|
316
|
-
#
|
|
317
|
-
#
|
|
318
|
-
# @
|
|
367
|
+
# Define quiet option
|
|
368
|
+
#
|
|
369
|
+
# @note module_function: defines #define_quiet_option (visibility: private)
|
|
370
|
+
# @param [OptionParser] opts the option parser to configure
|
|
371
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
372
|
+
# @return [void]
|
|
373
|
+
def define_quiet_option(opts, options)
|
|
374
|
+
opts.on('-q', '--quiet', 'Only show status, no details') do
|
|
375
|
+
options[:quiet] = true
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Define format option
|
|
380
|
+
#
|
|
381
|
+
# @note module_function: defines #define_format_option (visibility: private)
|
|
382
|
+
# @param [OptionParser] opts the option parser to configure
|
|
383
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
384
|
+
# @return [void]
|
|
385
|
+
def define_format_option(opts, options)
|
|
386
|
+
opts.on('--format FORMAT', %i[text json sarif], # steep:ignore
|
|
387
|
+
'Output format: text (default), json, or sarif') do |v|
|
|
388
|
+
options[:format] = v
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
# Define keep descriptions option
|
|
393
|
+
#
|
|
394
|
+
# @note module_function: defines #define_keep_descriptions_option (visibility: private)
|
|
395
|
+
# @param [OptionParser] opts the option parser to configure
|
|
396
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
397
|
+
# @return [void]
|
|
398
|
+
def define_keep_descriptions_option(opts, options)
|
|
399
|
+
opts.on('-k', '--keep-descriptions',
|
|
400
|
+
'Preserve existing @param/@return descriptions in aggressive mode') do
|
|
401
|
+
options[:keep_descriptions] = true
|
|
402
|
+
end
|
|
403
|
+
end
|
|
404
|
+
|
|
405
|
+
# Define no boilerplate option
|
|
406
|
+
#
|
|
407
|
+
# @note module_function: defines #define_no_boilerplate_option (visibility: private)
|
|
408
|
+
# @param [OptionParser] opts the option parser to configure
|
|
409
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
410
|
+
# @return [void]
|
|
411
|
+
def define_no_boilerplate_option(opts, options)
|
|
412
|
+
opts.on('-B', '--no-boilerplate',
|
|
413
|
+
"Don't insert template text when generating documentation") do
|
|
414
|
+
options[:no_boilerplate] = true
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
# Define misc options
|
|
419
|
+
#
|
|
420
|
+
# @note module_function: defines #define_misc_options (visibility: private)
|
|
421
|
+
# @param [OptionParser] opts the option parser to configure
|
|
319
422
|
# @return [void]
|
|
320
423
|
def define_misc_options(opts)
|
|
321
424
|
opts.on('-v', '--version', 'Print version and exit') do
|
|
@@ -332,9 +435,8 @@ module Docscribe
|
|
|
332
435
|
|
|
333
436
|
# Set the runtime mode and strategy after all options have been parsed.
|
|
334
437
|
#
|
|
335
|
-
# @note module_function:
|
|
336
|
-
# @
|
|
337
|
-
# @param [Hash] options mutable parsed options hash
|
|
438
|
+
# @note module_function: defines #resolve_mode_and_strategy! (visibility: private)
|
|
439
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
338
440
|
# @param [Symbol, nil] autocorrect_mode autocorrect mode selected (:safe, :aggressive, or nil)
|
|
339
441
|
# @return [void]
|
|
340
442
|
def resolve_mode_and_strategy!(options, autocorrect_mode)
|
|
@@ -355,8 +457,8 @@ module Docscribe
|
|
|
355
457
|
# Regex-looking patterns (`/…/`) are treated as method-id filters.
|
|
356
458
|
# File-like patterns are routed into `*_file`.
|
|
357
459
|
#
|
|
358
|
-
# @note module_function:
|
|
359
|
-
# @param [Hash] options mutable parsed options hash
|
|
460
|
+
# @note module_function: defines #route_include_exclude (visibility: private)
|
|
461
|
+
# @param [Hash<Symbol, Object>] options mutable parsed options hash
|
|
360
462
|
# @param [Symbol] kind either :include or :exclude
|
|
361
463
|
# @param [String] value raw pattern from the CLI
|
|
362
464
|
# @return [void]
|
|
@@ -373,7 +475,7 @@ module Docscribe
|
|
|
373
475
|
# Regex syntax (`/.../`) is intentionally treated as a method-id pattern,
|
|
374
476
|
# not a file pattern.
|
|
375
477
|
#
|
|
376
|
-
# @note module_function:
|
|
478
|
+
# @note module_function: defines #looks_like_file_pattern? (visibility: private)
|
|
377
479
|
# @param [String] pat pattern passed via CLI
|
|
378
480
|
# @return [Boolean]
|
|
379
481
|
def looks_like_file_pattern?(pat)
|