Fix extending non-dict types from doc fragments

pull/10914/head
Toshio Kuratomi 10 years ago
parent b19d426f0b
commit cbde1c5ec0

@ -23,6 +23,8 @@ import ast
import yaml import yaml
import traceback import traceback
from collections import MutableMapping, MutableSet, MutableSequence
from ansible import utils from ansible import utils
# modules that are ok that they do not have documentation strings # 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): if not doc.has_key(key):
doc[key] = value doc[key] = value
else: else:
if isinstance(doc[key], MutableMapping):
doc[key].update(value) 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): if 'EXAMPLES' in (t.id for t in child.targets):
plainexamples = child.value.s[1:] # Skip first empty line plainexamples = child.value.s[1:] # Skip first empty line

Loading…
Cancel
Save