@@ -210,6 +210,7 @@ def doc_option(self, arg_name, help_command, **kwargs):
210
210
self ._add_tagged_union_note (argument .argument_model , doc )
211
211
if hasattr (argument , 'argument_model' ):
212
212
self ._document_enums (argument .argument_model , doc )
213
+ self ._document_constraints (argument .argument_model , doc )
213
214
self ._document_nested_structure (argument .argument_model , doc )
214
215
doc .style .dedent ()
215
216
doc .style .new_paragraph ()
@@ -289,6 +290,8 @@ def _do_doc_member(self, doc, member_name, member_shape, stack):
289
290
doc .include_doc_string (docs )
290
291
if is_tagged_union_type (member_shape ):
291
292
self ._add_tagged_union_note (member_shape , doc )
293
+ self ._document_enums (member_shape , doc )
294
+ self ._document_constraints (member_shape , doc )
292
295
doc .style .new_paragraph ()
293
296
member_type_name = member_shape .type_name
294
297
if member_type_name == 'structure' :
@@ -327,6 +330,23 @@ def _add_tagged_union_note(self, shape, doc):
327
330
doc .writeln (msg )
328
331
doc .style .end_note ()
329
332
333
+ def _document_constraints (self , model , doc ):
334
+ """Documents parameter value constraints"""
335
+ if not hasattr (model , 'metadata' ):
336
+ return
337
+ constraints = ['min' , 'max' , 'pattern' ]
338
+ if not any (
339
+ [constraint in model .metadata for constraint in constraints ]
340
+ ):
341
+ return
342
+ doc .style .new_paragraph ()
343
+ doc .write ('Constraints:' )
344
+ doc .style .start_ul ()
345
+ for constraint in constraints :
346
+ if (val := model .metadata .get (constraint )) is not None :
347
+ doc .style .li (f'{ constraint } : ``{ val } ``' )
348
+ doc .style .end_ul ()
349
+
330
350
331
351
class ProviderDocumentEventHandler (CLIDocumentEventHandler ):
332
352
def doc_breadcrumbs (self , help_command , event_name , ** kwargs ):
@@ -609,10 +629,6 @@ def doc_option_example(self, arg_name, help_command, event_name, **kwargs):
609
629
member , include_enum_values = False
610
630
)
611
631
doc .write ('%s %s ...' % (example_type , example_type ))
612
- if isinstance (member , StringShape ) and member .enum :
613
- # If we have enum values, we can tell the user
614
- # exactly what valid values they can provide.
615
- self ._write_valid_enums (doc , member .enum )
616
632
doc .style .end_codeblock ()
617
633
doc .style .new_paragraph ()
618
634
elif cli_argument .cli_type_name not in SCALAR_TYPES :
@@ -623,13 +639,6 @@ def doc_option_example(self, arg_name, help_command, event_name, **kwargs):
623
639
doc .style .end_codeblock ()
624
640
doc .style .new_paragraph ()
625
641
626
- def _write_valid_enums (self , doc , enum_values ):
627
- doc .style .new_paragraph ()
628
- doc .write ("Where valid values are:\n " )
629
- for value in enum_values :
630
- doc .write (" %s\n " % value )
631
- doc .write ("\n " )
632
-
633
642
def doc_output (self , help_command , event_name , ** kwargs ):
634
643
doc = help_command .doc
635
644
doc .style .h2 ('Output' )
0 commit comments