From 848664f646bf087df59778434daa6feae1e71c74 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Fri, 27 Apr 2018 21:58:18 +0000 Subject: [PATCH] Add skip filter to config-table directive Some driver docs have different options in the table for different configuration types. This adds the ability to skip named properties to be able to control which options get included in the table output. Change-Id: I3c6e31bc11eaec5326314b6eb7e0184429f347bf --- doc/ext/driver_opts.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/ext/driver_opts.py b/doc/ext/driver_opts.py index 4e6f0c6470c..8754384163f 100644 --- a/doc/ext/driver_opts.py +++ b/doc/ext/driver_opts.py @@ -30,16 +30,19 @@ class ConfigTableDirective(rst.Directive): option_spec = { 'table-title': directives.unchanged, 'config-target': directives.unchanged, + 'exclude-list': directives.unchanged, } has_content = True - def _doc_module(self, module): + def _doc_module(self, module, filters): """Extract config options from module.""" options = [] try: mod = importlib.import_module(module) for prop in dir(mod): + if prop in filters: + continue thing = getattr(mod, prop) if isinstance(thing, cfg.Opt): # An individual config option @@ -84,6 +87,10 @@ class ConfigTableDirective(rst.Directive): 'table-title', 'Description of {} configuration options'.format(target)) + # See if there are option sets that need to be ignored + exclude = self.options.get('exclude-list', '') + exclude_list = [e.strip() for e in exclude.split(',') if e.strip()] + result.append('.. _{}:'.format(title.replace(' ', '-')), source) result.append('', source) result.append('.. list-table:: {}'.format(title), source) @@ -95,7 +102,7 @@ class ConfigTableDirective(rst.Directive): options = [] for module in modules: - retval = self._doc_module(module) + retval = self._doc_module(module, exclude_list) if retval: options.extend(retval) else: