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