From cbde1c5ec06a710616e734b5ae83dc3bb436ff4d Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Mon, 4 May 2015 13:38:24 -0700 Subject: [PATCH] Fix extending non-dict types from doc fragments --- lib/ansible/utils/module_docs.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/ansible/utils/module_docs.py b/lib/ansible/utils/module_docs.py index ee99af2cb54..c6920571726 100644 --- a/lib/ansible/utils/module_docs.py +++ b/lib/ansible/utils/module_docs.py @@ -23,6 +23,8 @@ import ast import yaml import traceback +from collections import MutableMapping, MutableSet, MutableSequence + from ansible import utils # modules that are ok that they do not have documentation strings @@ -86,7 +88,14 @@ def get_docstring(filename, verbose=False): if not doc.has_key(key): doc[key] = value else: - doc[key].update(value) + if isinstance(doc[key], MutableMapping): + doc[key].update(value) + elif isinstance(doc[key], MutableSet): + doc[key].add(value) + elif isinstance(doc[key], MutableSequence): + doc[key] = sorted(frozenset(doc[key] + value)) + else: + raise Exception("Attempt to extend a documentation fragement of unknown type") if 'EXAMPLES' in (t.id for t in child.targets): plainexamples = child.value.s[1:] # Skip first empty line