use faster method to get short_description from DOCUMENTATION (#42705)

* use faster method to get short_description from DOCUMENTATION

* fixed pep8 whitespace

* fixed blank line
This commit is contained in:
Eric Rinish 2018-07-27 17:27:44 -04:00 committed by Brian Coca
parent 350dbaf457
commit 551501f326
3 changed files with 58 additions and 5 deletions

View file

@ -25,7 +25,7 @@ from collections import MutableMapping, MutableSet, MutableSequence
from ansible.errors import AnsibleError, AnsibleAssertionError
from ansible.module_utils.six import string_types
from ansible.module_utils._text import to_native
from ansible.parsing.plugin_docs import read_docstring
from ansible.parsing.plugin_docs import read_docstring, read_docstub
from ansible.parsing.yaml.loader import AnsibleLoader
try:
@ -120,3 +120,16 @@ def get_docstring(filename, fragment_loader, verbose=False, ignore_errors=False)
add_fragments(data['doc'], filename, fragment_loader=fragment_loader)
return data['doc'], data['plainexamples'], data['returndocs'], data['metadata']
def get_docstub(filename, fragment_loader, verbose=False, ignore_errors=False):
"""
When only short_description is needed, load a stub of the full DOCUMENTATION string to speed up operation.
"""
data = read_docstub(filename, verbose=verbose, ignore_errors=ignore_errors)
if data.get('doc', False):
add_fragments(data['doc'], filename, fragment_loader=fragment_loader)
return data['doc'], data['plainexamples'], data['returndocs'], data['metadata']