mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
17f31a2a79
check path is directory added manpage & setup small cleanup shut up module_formatter in utils to avoid trace print on crud files in library
51 lines
1.5 KiB
Python
Executable file
51 lines
1.5 KiB
Python
Executable file
#!/usr/bin/env python
|
|
# (c) 2012, Jan-Piet Mens <jpmens () gmail.com>
|
|
#
|
|
# This file is part of Ansible
|
|
#
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
import os
|
|
import sys
|
|
import ast
|
|
import yaml
|
|
import traceback
|
|
|
|
# modules that are ok that they do not have documentation strings
|
|
BLACKLIST_MODULES = [
|
|
'async_wrapper',
|
|
]
|
|
|
|
def get_docstring(filename, verbose=False):
|
|
"""
|
|
Search for assignment of the DOCUMENTATION variable in the given file.
|
|
Parse that from YAML and return the YAML doc or None.
|
|
"""
|
|
|
|
doc = None
|
|
|
|
try:
|
|
# Thank you, Habbie, for this bit of code :-)
|
|
M = ast.parse(''.join(open(filename)))
|
|
for child in M.body:
|
|
if isinstance(child, ast.Assign):
|
|
if 'DOCUMENTATION' in (t.id for t in child.targets):
|
|
doc = yaml.load(child.value.s)
|
|
|
|
except:
|
|
if verbose == True:
|
|
traceback.print_exc()
|
|
print "unable to parse %s" % filename
|
|
return doc
|