@ -1267,6 +1267,51 @@ class DocCLI(CLI, RoleMixin):
text . append ( " %s %s : " % ( opt_indent , subkey ) )
DocCLI . add_fields ( text , subdata , limit , opt_indent + ' ' , return_values , opt_indent )
@staticmethod
def _add_seealso ( text , seealsos , limit , opt_indent ) :
for item in seealsos :
if ' module ' in item :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( ' Module %s ' % item [ ' module ' ] ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
description = item . get ( ' description ' )
if description is None and item [ ' module ' ] . startswith ( ' ansible.builtin. ' ) :
description = ' The official documentation on the %s module. ' % item [ ' module ' ]
if description is not None :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( description ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
if item [ ' module ' ] . startswith ( ' ansible.builtin. ' ) :
relative_url = ' collections/ %s _module.html ' % item [ ' module ' ] . replace ( ' . ' , ' / ' , 2 )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( get_versioned_doclink ( relative_url ) ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent ) )
elif ' plugin ' in item and ' plugin_type ' in item :
plugin_suffix = ' plugin ' if item [ ' plugin_type ' ] not in ( ' module ' , ' role ' ) else ' '
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( ' %s %s %s ' % ( item [ ' plugin_type ' ] . title ( ) , plugin_suffix , item [ ' plugin ' ] ) ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
description = item . get ( ' description ' )
if description is None and item [ ' plugin ' ] . startswith ( ' ansible.builtin. ' ) :
description = ' The official documentation on the %s %s %s . ' % ( item [ ' plugin ' ] , item [ ' plugin_type ' ] , plugin_suffix )
if description is not None :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( description ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
if item [ ' plugin ' ] . startswith ( ' ansible.builtin. ' ) :
relative_url = ' collections/ %s _ %s .html ' % ( item [ ' plugin ' ] . replace ( ' . ' , ' / ' , 2 ) , item [ ' plugin_type ' ] )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( get_versioned_doclink ( relative_url ) ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent ) )
elif ' name ' in item and ' link ' in item and ' description ' in item :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' name ' ] ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' description ' ] ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' link ' ] ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
elif ' ref ' in item and ' description ' in item :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( ' Ansible documentation [ %s ] ' % item [ ' ref ' ] ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' description ' ] ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( get_versioned_doclink ( ' /#stq= %s &stp=1 ' % item [ ' ref ' ] ) ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
def get_role_man_text ( self , role , role_json ) :
''' Generate text for the supplied role suitable for display.
@ -1294,6 +1339,10 @@ class DocCLI(CLI, RoleMixin):
text . append ( " ENTRY POINT: %s %s " % ( _format ( entry_point , " BOLD " ) , desc ) )
text . append ( ' ' )
if ' version_added ' in doc :
version_added = doc . pop ( ' version_added ' )
text . append ( _format ( " ADDED IN: " , ' bold ' ) + " %s \n " % DocCLI . _format_version_added ( version_added ) )
if doc . get ( ' description ' ) :
if isinstance ( doc [ ' description ' ] , list ) :
desc = " " . join ( doc [ ' description ' ] )
@ -1324,6 +1373,26 @@ class DocCLI(CLI, RoleMixin):
text . append ( DocCLI . _indent_lines ( DocCLI . _dump_yaml ( doc [ ' attributes ' ] [ k ] ) , opt_indent ) )
del doc [ ' attributes ' ]
if doc . get ( ' notes ' , False ) :
text . append ( " " )
text . append ( _format ( " NOTES: " , ' bold ' ) )
for note in doc [ ' notes ' ] :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( note ) , limit - 6 ,
initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
del doc [ ' notes ' ]
if doc . get ( ' seealso ' , False ) :
text . append ( " " )
text . append ( _format ( " SEE ALSO: " , ' bold ' ) )
DocCLI . _add_seealso ( text , doc [ ' seealso ' ] , limit = limit , opt_indent = opt_indent )
del doc [ ' seealso ' ]
if doc . get ( ' requirements ' , False ) :
text . append ( ' ' )
req = " , " . join ( doc . pop ( ' requirements ' ) )
text . append ( _format ( " REQUIREMENTS: " , ' bold ' ) + " %s \n " % DocCLI . warp_fill ( DocCLI . tty_ify ( req ) , limit - 16 , initial_indent = " " ,
subsequent_indent = opt_indent ) )
# generic elements we will handle identically
for k in ( ' author ' , ) :
if k not in doc :
@ -1409,49 +1478,7 @@ class DocCLI(CLI, RoleMixin):
if doc . get ( ' seealso ' , False ) :
text . append ( " " )
text . append ( _format ( " SEE ALSO: " , ' bold ' ) )
for item in doc [ ' seealso ' ] :
if ' module ' in item :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( ' Module %s ' % item [ ' module ' ] ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
description = item . get ( ' description ' )
if description is None and item [ ' module ' ] . startswith ( ' ansible.builtin. ' ) :
description = ' The official documentation on the %s module. ' % item [ ' module ' ]
if description is not None :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( description ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
if item [ ' module ' ] . startswith ( ' ansible.builtin. ' ) :
relative_url = ' collections/ %s _module.html ' % item [ ' module ' ] . replace ( ' . ' , ' / ' , 2 )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( get_versioned_doclink ( relative_url ) ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent ) )
elif ' plugin ' in item and ' plugin_type ' in item :
plugin_suffix = ' plugin ' if item [ ' plugin_type ' ] not in ( ' module ' , ' role ' ) else ' '
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( ' %s %s %s ' % ( item [ ' plugin_type ' ] . title ( ) , plugin_suffix , item [ ' plugin ' ] ) ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
description = item . get ( ' description ' )
if description is None and item [ ' plugin ' ] . startswith ( ' ansible.builtin. ' ) :
description = ' The official documentation on the %s %s %s . ' % ( item [ ' plugin ' ] , item [ ' plugin_type ' ] , plugin_suffix )
if description is not None :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( description ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
if item [ ' plugin ' ] . startswith ( ' ansible.builtin. ' ) :
relative_url = ' collections/ %s _ %s .html ' % ( item [ ' plugin ' ] . replace ( ' . ' , ' / ' , 2 ) , item [ ' plugin_type ' ] )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( get_versioned_doclink ( relative_url ) ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent ) )
elif ' name ' in item and ' link ' in item and ' description ' in item :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' name ' ] ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' description ' ] ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' link ' ] ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
elif ' ref ' in item and ' description ' in item :
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( ' Ansible documentation [ %s ] ' % item [ ' ref ' ] ) ,
limit - 6 , initial_indent = opt_indent [ : - 2 ] + " * " , subsequent_indent = opt_indent ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( item [ ' description ' ] ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
text . append ( DocCLI . warp_fill ( DocCLI . tty_ify ( get_versioned_doclink ( ' /#stq= %s &stp=1 ' % item [ ' ref ' ] ) ) ,
limit - 6 , initial_indent = opt_indent + ' ' , subsequent_indent = opt_indent + ' ' ) )
DocCLI . _add_seealso ( text , doc [ ' seealso ' ] , limit = limit , opt_indent = opt_indent )
del doc [ ' seealso ' ]
if doc . get ( ' requirements ' , False ) :