From fe18adb25839bf191aa748f13e75bfccb10f4a57 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Mon, 16 May 2016 14:15:19 +0200 Subject: help, makeapi: do not use hardcoded plugin package name Iterate over all plugin packages defined in the API to find the given topic module. The last module found has priority. This will allow topics to be defined in client-side plugins. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka --- makeapi | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'makeapi') diff --git a/makeapi b/makeapi index ae664eca4..476b65149 100755 --- a/makeapi +++ b/makeapi @@ -171,23 +171,36 @@ def validate_doc(): while topic is not None: if not topics.setdefault(topic, 0): # First time seeing this module, validate the module contents - module = 'ipalib.plugins.%s' % topic - try: - mod = sys.modules[module] - except KeyError: - mod = importlib.import_module(module) + doc = None + next_topic = None - # See if there is a module topic, if so validate it - next_topic = getattr(mod, 'topic', None) + for package in api.packages: + module = '%s.%s' % (package.__name__, topic) + try: + mod = sys.modules[module] + except KeyError: + try: + mod = importlib.import_module(module) + except ImportError: + continue + + if mod.__doc__ is not None: + doc = mod.__doc__ + + # See if there is a module topic, if so validate it + try: + next_topic = mod.topic + except AttributeError: + pass # Does the module have documentation? - if mod.__doc__ is None: + if doc is None: src_file = inspect.getsourcefile(mod) n_missing_mod_doc += 1 print("%s: module \"%s\" has no doc" % (src_file, module)) # Yes the module has doc, but is it internationalized? - elif not is_i18n(mod.__doc__): + elif not is_i18n(doc): src_file = inspect.getsourcefile(cmd_class) n_missing_mod_i18n += 1 print("%s: module \"%s\" doc is not internationalized" % -- cgit