From e1e5fd3fd2a9e37d29f139fa6bbe40ec64911396 Mon Sep 17 00:00:00 2001 From: Lennart Fricke Date: Fri, 28 Nov 2014 16:21:02 +0100 Subject: [PATCH] Add very fault tolerant docscraping using numpydoc in ArtistInspector --- lib/matplotlib/artist.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/matplotlib/artist.py b/lib/matplotlib/artist.py index af9155c40dd6..c218fb8db697 100644 --- a/lib/matplotlib/artist.py +++ b/lib/matplotlib/artist.py @@ -953,6 +953,19 @@ def get_valid_values(self, attr): match = self._get_valid_values_regex.search(docstring) if match is not None: return match.group(1).replace('\n', ' ') + else: + try: + from numpydoc.docscrape import FunctionDoc + from inspect import getargspec + npdoc = FunctionDoc(func) + sig = getargspec(func) + params = npdoc._parsed_data["Parameters"] + if params: + param1 = npdoc._parsed_data["Parameters"][0] + if param1[0] == sig[0][1] or param1[0] == sig[0][1]: + return param1[1] + except ImportError, KeyError: + pass return 'unknown' def _get_setters_and_targets(self):