Fix encoding issue when parsing plugin examples

This caused a non-fatal traceback when building, for example, the module
documentation for the debug module.
pull/39873/head
Toshio Kuratomi 7 years ago
parent 2397ca1a7e
commit 3e64036684

@ -0,0 +1,3 @@
---
bugfixes:
- Fix an encoding issue when parsing the examples from a plugins' documentation

@ -8,6 +8,7 @@ __metaclass__ = type
import ast import ast
import yaml import yaml
from ansible.module_utils._text import to_text
from ansible.parsing.metadata import extract_metadata from ansible.parsing.metadata import extract_metadata
from ansible.parsing.yaml.loader import AnsibleLoader from ansible.parsing.yaml.loader import AnsibleLoader
@ -61,7 +62,7 @@ def read_docstring(filename, verbose=True, ignore_errors=True):
data[varkey] = AnsibleLoader(child.value.s, file_name=filename).get_single_data() data[varkey] = AnsibleLoader(child.value.s, file_name=filename).get_single_data()
else: else:
# not yaml, should be a simple string # not yaml, should be a simple string
data[varkey] = child.value.s data[varkey] = to_text(child.value.s)
display.debug('assigned :%s' % varkey) display.debug('assigned :%s' % varkey)
# Metadata is per-file and a dict rather than per-plugin/function and yaml # Metadata is per-file and a dict rather than per-plugin/function and yaml

Loading…
Cancel
Save