diff options
author | Doug Hellmann <doug@doughellmann.com> | 2018-04-26 16:59:24 -0400 |
---|---|---|
committer | Matt Riedemann <mriedem.os@gmail.com> | 2018-04-30 10:11:21 -0400 |
commit | 0e7bb2822483cd33798420a143d107b951154172 (patch) | |
tree | d46f970e408ae862af250577538d71390bd17b0e /oslo_policy/sphinxpolicygen.py | |
parent | c474b36793cbafafe0534bb89a4a33dedbb57142 (diff) | |
download | oslo-policy-0e7bb2822483cd33798420a143d107b951154172.tar.gz |
make the sphinxpolicygen extension handle multiple input/output files
Some projects have multiple policy files for different parts of their
API. Make the sample generator extension support this by letting the
policy_generator_config_file option be set to a list of tuples mapping
the config file to the output file base name, as we do in the sample
generator in oslo.config.
Change-Id: I0c7fa409a1ed0f49d65c9b90b71317066f6d3505
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Diffstat (limited to 'oslo_policy/sphinxpolicygen.py')
-rw-r--r-- | oslo_policy/sphinxpolicygen.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/oslo_policy/sphinxpolicygen.py b/oslo_policy/sphinxpolicygen.py index 113e040..427559f 100644 --- a/oslo_policy/sphinxpolicygen.py +++ b/oslo_policy/sphinxpolicygen.py @@ -28,9 +28,19 @@ def generate_sample(app): "skipping sample policy generation") return - _generate_sample(app, - app.config.policy_generator_config_file, - app.config.sample_policy_basename) + if isinstance(app.config.policy_generator_config_file, list): + for config_file, base_name in app.config.policy_generator_config_file: + if base_name is None: + base_name = _get_default_basename(config_file) + _generate_sample(app, config_file, base_name) + else: + _generate_sample(app, + app.config.policy_generator_config_file, + app.config.sample_policy_basename) + + +def _get_default_basename(config_file): + return os.path.splitext(os.path.basename(config_file))[0] def _generate_sample(app, policy_file, base_name): |