diff options
author | Jan Cholasta <jcholast@redhat.com> | 2016-05-12 13:41:09 +0200 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2016-06-03 09:00:34 +0200 |
commit | 0a984afd8170b349b0745fb89168d363dfa28ffa (patch) | |
tree | 8b4b1cd2c33fef6b06f96e84e9f52d71bdd2390c /makeapi | |
parent | 327d95296a5b28179469c20ec5f98dba3c333017 (diff) | |
download | freeipa-0a984afd8170b349b0745fb89168d363dfa28ffa.tar.gz freeipa-0a984afd8170b349b0745fb89168d363dfa28ffa.tar.xz freeipa-0a984afd8170b349b0745fb89168d363dfa28ffa.zip |
help, makeapi: allow setting command topic explicitly
Help topic can now be specified in the 'topic' class attribute of command
plugins. Default value is the name of the module where the command is
defined.
This allows defining a command outside of the topic module.
https://fedorahosted.org/freeipa/ticket/4739
Reviewed-By: David Kupka <dkupka@redhat.com>
Diffstat (limited to 'makeapi')
-rwxr-xr-x | makeapi | 62 |
1 files changed, 34 insertions, 28 deletions
@@ -25,6 +25,7 @@ from __future__ import print_function +import importlib import sys import os import re @@ -149,7 +150,7 @@ def validate_doc(): rval = 0 # Used to track if we've processed a module already - modules = {} + topics = {} # Initialize error counters n_missing_cmd_doc = 0 @@ -165,35 +166,40 @@ def validate_doc(): if getattr(cmd, 'NO_CLI', False): continue - # Have we processed this module yet? - if not modules.setdefault(cmd.module, 0): - # First time seeing this module, validate the module contents - mod = sys.modules[cmd.module] - - # See if there is a module topic, if so validate it - topic = getattr(mod, 'topic', None) - if topic is not None: - if not is_i18n(topic[1]): + if cmd.topic is not None: + # Have we processed this module yet? + if not topics.setdefault(cmd.topic, 0): + # First time seeing this module, validate the module contents + module = 'ipalib.plugins.%s' % cmd.topic + try: + mod = sys.modules[module] + except KeyError: + mod = importlib.import_module(module) + + # See if there is a module topic, if so validate it + topic = getattr(mod, 'topic', None) + if topic is not None: + if not is_i18n(topic[1]): + src_file = inspect.getsourcefile(cmd_class) + n_missing_mod_i18n += 1 + print("%s: topic in module \"%s\" is not " + "internationalized" % (src_file, module)) + + # Does the module have documentation? + if mod.__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__): src_file = inspect.getsourcefile(cmd_class) n_missing_mod_i18n += 1 - print("%s: topic in module \"%s\" is not internationalized" % \ - (src_file, cmd.module)) - - # Does the module have documentation? - if mod.__doc__ is None: - src_file = inspect.getsourcefile(mod) - n_missing_mod_doc += 1 - print("%s: module \"%s\" has no doc" % \ - (src_file, cmd.module)) - # Yes the module has doc, but is it internationalized? - elif not is_i18n(mod.__doc__): - src_file = inspect.getsourcefile(cmd_class) - n_missing_mod_i18n += 1 - print("%s: module \"%s\" doc is not internationalized" % \ - (src_file, cmd.module)) - - # Increment the count of how many commands in this module - modules[cmd.module] = modules[cmd.module] + 1 + print("%s: module \"%s\" doc is not internationalized" % + (src_file, module)) + + # Increment the count of how many commands in this module + topics[cmd.topic] = topics[cmd.topic] + 1 # Does the command have documentation? if cmd.__doc__ is None: |