From ad440d79578ee90881b4240281078ca06cd681fb Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Fri, 5 Feb 2016 16:52:22 -0500 Subject: [PATCH] have show-options load the generator config file Add an option to the show-options directive to read existing configuration files for the sample config generator instead of making the author provide the list of namespaces inline. Change-Id: I0ec46cc7aa820ae592d8e4e7b56ee98f0c5cbfb4 Signed-off-by: Doug Hellmann --- doc/source/sphinxext.rst | 8 ++++++++ oslo_config/sphinxext.py | 22 +++++++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/doc/source/sphinxext.rst b/doc/source/sphinxext.rst index e40dea98..5e9a1a55 100644 --- a/doc/source/sphinxext.rst +++ b/doc/source/sphinxext.rst @@ -29,6 +29,14 @@ two roles. oslo.config oslo.log + To use an existing configuration file for the sample configuration + generator, use the ``config-file`` option instead of specifying the + namespaces inline. + :: + + .. show-options:: + :config-file: etc/oslo-config-generator/glance-api.conf + .. rst:role:: option Link to an option. diff --git a/oslo_config/sphinxext.py b/oslo_config/sphinxext.py index dd3d5358..fe302f17 100644 --- a/oslo_config/sphinxext.py +++ b/oslo_config/sphinxext.py @@ -68,6 +68,7 @@ class ShowOptionsDirective(rst.Directive): option_spec = { 'split-namespaces': directives.flag, + 'config-file': directives.unchanged, } has_content = True @@ -90,11 +91,22 @@ class ShowOptionsDirective(rst.Directive): split_namespaces = 'split-namespaces' in self.options - namespaces = [ - c.strip() - for c in self.content - if c.strip() - ] + config_file = self.options.get('config-file') + if config_file: + app.info('loading config file %s' % config_file) + conf = cfg.ConfigOpts() + conf.register_opts(generator._generator_opts) + conf( + args=['--config-file', config_file], + project='oslo.config.sphinxext', + ) + namespaces = conf.namespace[:] + else: + namespaces = [ + c.strip() + for c in self.content + if c.strip() + ] opts = generator._list_opts(namespaces)