mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Fix ansible-doc and docsite generation for removed modules
* Fix ansible-doc wrt removed modules * Fix listing of modules ia ansible-doc to not complain about removed modules Removed modules are marked as such in the metadata but nowhere else. Need to retrieve the metadata when a module doesn't have a doc so that we can tell if it falls under this case. * omit removed modules from json dump * Print an error that the module has been removed if attempting to run ansible-doc on that specific module * Get plugin_formatter to stop outputting removed modules
This commit is contained in:
parent
b2932a41b0
commit
0873d46617
4 changed files with 59 additions and 53 deletions
|
@ -82,41 +82,27 @@ def read_docstring(filename, verbose=True, ignore_errors=True):
|
|||
return data
|
||||
|
||||
|
||||
def read_docstub(filename, verbose=True, ignore_errors=True):
|
||||
def read_docstub(filename):
|
||||
"""
|
||||
Quickly find short_description using string methods instead of node parsing.
|
||||
This does not return a full set of documentation strings and is intended for
|
||||
operations like ansible-doc -l.
|
||||
"""
|
||||
|
||||
data = {
|
||||
'doc': None,
|
||||
'plainexamples': None,
|
||||
'returndocs': None,
|
||||
'metadata': None
|
||||
}
|
||||
t_module_data = open(filename, 'r')
|
||||
capturing = False
|
||||
doc_stub = []
|
||||
|
||||
try:
|
||||
t_module_data = open(filename, 'r')
|
||||
capturing = False
|
||||
doc_stub = []
|
||||
for line in t_module_data:
|
||||
# start capturing the stub until indentation returns
|
||||
if capturing and line[0] == ' ':
|
||||
doc_stub.append(line)
|
||||
elif capturing and line[0] != ' ':
|
||||
break
|
||||
if 'short_description:' in line:
|
||||
capturing = True
|
||||
doc_stub.append(line)
|
||||
|
||||
for line in t_module_data:
|
||||
# start capturing the stub until indentation returns
|
||||
if capturing and line[0] == ' ':
|
||||
doc_stub.append(line)
|
||||
elif capturing and line[0] != ' ':
|
||||
break
|
||||
if 'short_description:' in line:
|
||||
capturing = True
|
||||
doc_stub.append(line)
|
||||
|
||||
data['doc'] = AnsibleLoader(r"".join(doc_stub), file_name=filename).get_single_data()
|
||||
|
||||
except:
|
||||
if verbose:
|
||||
display.error("unable to parse %s" % filename)
|
||||
if not ignore_errors:
|
||||
raise
|
||||
data = AnsibleLoader(r"".join(doc_stub), file_name=filename).get_single_data()
|
||||
|
||||
return data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue