File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ def module_options_to_snippet_options(module_options: Any) -> List[str]:
220
220
221
221
# insert an empty option above the list of non-required options
222
222
for index , (_ , option ) in enumerate (module_options ):
223
- if not option .get ("required" ):
223
+ if not option .get ("required" ) and not args . comment_non_required :
224
224
if index != 0 :
225
225
module_options .insert (index , (None , None ))
226
226
break
@@ -230,14 +230,19 @@ def module_options_to_snippet_options(module_options: Any) -> List[str]:
230
230
if not name and not option_data :
231
231
options += ["" ]
232
232
else :
233
+ # set comment character for non-required options
234
+ if not option_data .get ("required" ) and args .comment_non_required :
235
+ comment = "#"
236
+ else :
237
+ comment = ""
233
238
# the free_form option in some modules are special
234
239
if name == "free_form" :
235
240
options += [
236
- f"\t ${{{ index } :{ name } { delimiter } { option_data_to_snippet_completion (option_data )} }}"
241
+ f"\t { comment } ${{{ index } :{ name } { delimiter } { option_data_to_snippet_completion (option_data )} }}"
237
242
]
238
243
else :
239
244
options += [
240
- f"\t { name } { delimiter } ${{{ index } :{ option_data_to_snippet_completion (option_data )} }}"
245
+ f"\t { comment } { name } { delimiter } ${{{ index } :{ option_data_to_snippet_completion (option_data )} }}"
241
246
]
242
247
243
248
return options
@@ -322,6 +327,12 @@ def get_collection_name(filepath:str) -> str:
322
327
action = "store_true" ,
323
328
default = False
324
329
)
330
+ parser .add_argument (
331
+ '--comment-non-required' ,
332
+ help = "Comment non-required options" ,
333
+ action = "store_true" ,
334
+ default = False
335
+ )
325
336
args = parser .parse_args ()
326
337
327
338
You can’t perform that action at this time.
0 commit comments