summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fried <openstack@fried.cc>2019-10-31 18:40:44 -0500
committerEric Fried <openstack@fried.cc>2019-11-14 12:09:22 -0600
commit8e4ae2b86c9a4a9f475b5fe6cbd5250be4737812 (patch)
treeb3625cfe4da9400f95c71237f31c41adad25d1e8
parent9c561ef6c3e8f1de6b1ff8ce11fd660573f631c9 (diff)
downloadcliff-8e4ae2b86c9a4a9f475b5fe6cbd5250be4737812.tar.gz
Add autoprogram_cliff_app_dist_name config opt
This allows consumers to let cliff know who they are, so the autoprogram-sphinx directive doesn't produce messages like This command is provided by the $me plugin. Change-Id: I2d5a527910ddc64f83d0cba39c584b8b05a299b7
-rw-r--r--cliff/command.py6
-rw-r--r--cliff/sphinxext.py4
-rw-r--r--doc/source/user/sphinxext.rst8
3 files changed, 16 insertions, 2 deletions
diff --git a/cliff/command.py b/cliff/command.py
index c020edc..35f1ef7 100644
--- a/cliff/command.py
+++ b/cliff/command.py
@@ -137,8 +137,10 @@ class Command(object):
(h.obj.get_epilog() for h in self._hooks),
)
parts.extend(hook_epilogs)
- app_dist_name = _get_distribution_for_module(
- inspect.getmodule(self.app)
+ app_dist_name = getattr(
+ self, 'app_dist_name', _get_distribution_for_module(
+ inspect.getmodule(self.app)
+ )
)
dist_name = _get_distribution_for_module(inspect.getmodule(self))
if dist_name and dist_name != app_dist_name:
diff --git a/cliff/sphinxext.py b/cliff/sphinxext.py
index 8a9a2e6..265cccc 100644
--- a/cliff/sphinxext.py
+++ b/cliff/sphinxext.py
@@ -322,6 +322,9 @@ class AutoprogramCliffDirective(rst.Directive):
:returns: A list of nested docutil nodes
"""
command = command_class(None, None)
+ if not getattr(command, 'app_dist_name', None):
+ command.app_dist_name = (
+ self.env.config.autoprogram_cliff_app_dist_name)
parser = command.get_parser(command_name)
ignored_opts = ignored_opts or []
@@ -375,3 +378,4 @@ def setup(app):
app.add_directive('autoprogram-cliff', AutoprogramCliffDirective)
app.add_config_value('autoprogram_cliff_application', '', True)
app.add_config_value('autoprogram_cliff_ignored', ['--help'], True)
+ app.add_config_value('autoprogram_cliff_app_dist_name', None, True)
diff --git a/doc/source/user/sphinxext.rst b/doc/source/user/sphinxext.rst
index ae1cabe..46ac97e 100644
--- a/doc/source/user/sphinxext.rst
+++ b/doc/source/user/sphinxext.rst
@@ -125,6 +125,14 @@ Directive
.. seealso:: The ``:ignored:`` directive option.
+ `autoprogram_cliff_app_dist_name`
+ The name of the python distribution (the name used with pip, as opposed to
+ the package name used for importing) providing the commands/applications
+ being documented. Generated documentation for plugin components includes
+ a message indicating the name of the plugin. Setting this option tells
+ cliff the name of the distribution providing components natively so their
+ documentation does not include this message.
+
.. seealso::
Module `sphinxcontrib.autoprogram`