Merge "Add autoprogram_cliff_app_dist_name config opt"

This commit is contained in:
Zuul 2019-12-18 13:47:59 +00:00 committed by Gerrit Code Review
commit 009b13b2df
3 changed files with 16 additions and 2 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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`