summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <sfinucan@redhat.com>2017-10-10 16:22:47 +0100
committerStephen Finucane <sfinucan@redhat.com>2018-01-29 15:45:59 +0000
commit857317d5804cdda8c3f4fca949bcf97ed26d7c10 (patch)
tree2a8ecc65c6d1c9dba5852cfbb55dd413d9907650
parentfa2de57c02c4ab677558f33fd9ba07382f700b39 (diff)
downloadcliff-857317d5804cdda8c3f4fca949bcf97ed26d7c10.tar.gz
sphinxext: Warn if namespace or command pattern invalid
Calling the Sphinx extension with an invalid namespace or command pattern currently results in a silent failure. Correct this oversight by raising a warning, which will cause a build failure is 'warning-is-error' is enabled. Change-Id: I63d18c86931d752c3a680e84a69df53bc04e7dfd Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
-rw-r--r--cliff/sphinxext.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/cliff/sphinxext.py b/cliff/sphinxext.py
index d8468b6..5ec3448 100644
--- a/cliff/sphinxext.py
+++ b/cliff/sphinxext.py
@@ -268,6 +268,15 @@ class AutoprogramCliffDirective(rst.Directive):
if fnmatch.fnmatch(x, command_pattern)]
else:
commands = manager.commands.keys()
+
+ if not commands:
+ msg = 'No commands found in the "{}" namespace'
+ if command_pattern:
+ msg += ' using the "{}" command name/pattern'
+ msg += ('. Are you sure this is correct and the application being '
+ 'documented is installed?')
+ raise self.warning(msg.format(self.arguments[0], command_pattern))
+
return dict((name, self._load_command(manager, name))
for name in commands)