1818from awscli .testutils import mock , unittest , FileCreator
1919from awscli .clidocs import OperationDocumentEventHandler , \
2020 CLIDocumentEventHandler , TopicListerDocumentEventHandler , \
21- TopicDocumentEventHandler , GlobalOptionsDocumenter
21+ TopicDocumentEventHandler , GlobalOptionsDocumenter , \
22+ ServiceDocumentEventHandler
2223from awscli .bcdoc .restdoc import ReSTDocument
2324from awscli .help import ServiceHelpCommand , TopicListerCommand , \
2425 TopicHelpCommand , HelpCommand
@@ -195,7 +196,7 @@ def test_breadcrumbs_html(self):
195196 doc_handler .doc_breadcrumbs (help_cmd )
196197 self .assertEqual (
197198 help_cmd .doc .getvalue ().decode ('utf-8' ),
198- '[ :ref:`aws <cli:aws>` ]'
199+ '[ :ref:`aws <cli:aws>` ]\n \n '
199200 )
200201
201202 def test_breadcrumbs_service_command_html (self ):
@@ -208,7 +209,7 @@ def test_breadcrumbs_service_command_html(self):
208209 doc_handler .doc_breadcrumbs (help_cmd )
209210 self .assertEqual (
210211 help_cmd .doc .getvalue ().decode ('utf-8' ),
211- '[ :ref:`aws <cli:aws>` ]'
212+ '[ :ref:`aws <cli:aws>` ]\n \n '
212213 )
213214
214215 def test_breadcrumbs_operation_command_html (self ):
@@ -221,7 +222,7 @@ def test_breadcrumbs_operation_command_html(self):
221222 doc_handler .doc_breadcrumbs (help_cmd )
222223 self .assertEqual (
223224 help_cmd .doc .getvalue ().decode ('utf-8' ),
224- '[ :ref:`aws <cli:aws>` . :ref:`ec2 <cli:aws ec2>` ]'
225+ '[ :ref:`aws <cli:aws>` . :ref:`ec2 <cli:aws ec2>` ]\n \n '
225226 )
226227
227228 def test_breadcrumbs_wait_command_html (self ):
@@ -235,7 +236,7 @@ def test_breadcrumbs_wait_command_html(self):
235236 self .assertEqual (
236237 help_cmd .doc .getvalue ().decode ('utf-8' ),
237238 ('[ :ref:`aws <cli:aws>` . :ref:`s3api <cli:aws s3api>`'
238- ' . :ref:`wait <cli:aws s3api wait>` ]' )
239+ ' . :ref:`wait <cli:aws s3api wait>` ]\n \n ' )
239240 )
240241
241242 def test_documents_json_header_shape (self ):
@@ -444,6 +445,32 @@ def test_tagged_union_comes_after_docstring_output(self):
444445 rendered = help_command .doc .getvalue ().decode ('utf-8' )
445446 self .assertRegex (rendered , r'FooBar[\s\S]*Tagged Union' )
446447
448+ def test_meta_description_operation_command_html (self ):
449+ help_cmd = ServiceHelpCommand (
450+ self .session , self .obj , self .command_table , self .arg_table ,
451+ self .name , 'ec2.run-instances'
452+ )
453+ help_cmd .doc .target = 'html'
454+ doc_handler = OperationDocumentEventHandler (help_cmd )
455+ doc_handler .doc_meta_description (help_cmd )
456+
457+ meta_description = help_cmd .doc .getvalue ().decode ('utf-8' )
458+ self .assertIn (".. meta::\n :description: " , meta_description )
459+ self .assertIn ('to run the ec2 run-instances command' , meta_description )
460+
461+ def test_meta_description_service_html (self ):
462+ help_cmd = ServiceHelpCommand (
463+ self .session , self .obj , self .command_table , self .arg_table ,
464+ self .name , 'ec2'
465+ )
466+ help_cmd .doc .target = 'html'
467+ doc_handler = ServiceDocumentEventHandler (help_cmd )
468+ doc_handler .doc_meta_description (help_cmd )
469+
470+ meta_description = help_cmd .doc .getvalue ().decode ('utf-8' )
471+ self .assertIn (".. meta::\n :description: Learn about the AWS CLI " , meta_description )
472+ self .assertIn (' ec2 commands' , meta_description )
473+
447474
448475class TestTopicDocumentEventHandlerBase (unittest .TestCase ):
449476 def setUp (self ):
0 commit comments