.. versionadded:: Neon

    Return the docstrings for all utils modules. Optionally, specify a module
    or a function to narrow the selection.

    The strings are aggregated into a single document on the master for easy
    reading.

    Multiple modules/functions can be specified.

    CLI Example:

    .. code-block:: bash

        salt '*' sys.utils_doc
        salt '*' sys.utils_doc data stringutils
        salt '*' sys.utils_doc stringutils.to_unicode
        salt '*' sys.utils_doc data.encode data.decode

def utils_doc(*args):
    '''
    .. versionadded:: Neon

    Return the docstrings for all utils modules. Optionally, specify a module
    or a function to narrow the selection.

    The strings are aggregated into a single document on the master for easy
    reading.

    Multiple modules/functions can be specified.

    CLI Example:

    .. code-block:: bash

        salt '*' sys.utils_doc
        salt '*' sys.utils_doc data stringutils
        salt '*' sys.utils_doc stringutils.to_unicode
        salt '*' sys.utils_doc data.encode data.decode
    '''
    docs = {}
    if not args:
        for fun in __utils__:
            docs[fun] = __utils__[fun].__doc__
        return _strip_rst(docs)

    for module in args:
        _use_fnmatch = False
        if '*' in module:
            target_mod = module
            _use_fnmatch = True
        elif module:
            # allow both "sys" and "sys." to match sys, without also matching
            # sysctl
            target_mod = module + '.' if not module.endswith('.') else module
        else:
            target_mod = ''
        if _use_fnmatch:
            for fun in fnmatch.filter(__utils__, target_mod):
                docs[fun] = __utils__[fun].__doc__
        else:

            for fun in __utils__:
                if fun == module or fun.startswith(target_mod):
                    docs[fun] = __utils__[fun].__doc__
    return _strip_rst(docs)