Merge "Add skip filter to config-table directive"
This commit is contained in:
commit
ae4f3eab3d
@ -30,16 +30,19 @@ class ConfigTableDirective(rst.Directive):
|
|||||||
option_spec = {
|
option_spec = {
|
||||||
'table-title': directives.unchanged,
|
'table-title': directives.unchanged,
|
||||||
'config-target': directives.unchanged,
|
'config-target': directives.unchanged,
|
||||||
|
'exclude-list': directives.unchanged,
|
||||||
}
|
}
|
||||||
|
|
||||||
has_content = True
|
has_content = True
|
||||||
|
|
||||||
def _doc_module(self, module):
|
def _doc_module(self, module, filters):
|
||||||
"""Extract config options from module."""
|
"""Extract config options from module."""
|
||||||
options = []
|
options = []
|
||||||
try:
|
try:
|
||||||
mod = importlib.import_module(module)
|
mod = importlib.import_module(module)
|
||||||
for prop in dir(mod):
|
for prop in dir(mod):
|
||||||
|
if prop in filters:
|
||||||
|
continue
|
||||||
thing = getattr(mod, prop)
|
thing = getattr(mod, prop)
|
||||||
if isinstance(thing, cfg.Opt):
|
if isinstance(thing, cfg.Opt):
|
||||||
# An individual config option
|
# An individual config option
|
||||||
@ -84,6 +87,10 @@ class ConfigTableDirective(rst.Directive):
|
|||||||
'table-title',
|
'table-title',
|
||||||
'Description of {} configuration options'.format(target))
|
'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('.. _{}:'.format(title.replace(' ', '-')), source)
|
||||||
result.append('', source)
|
result.append('', source)
|
||||||
result.append('.. list-table:: {}'.format(title), source)
|
result.append('.. list-table:: {}'.format(title), source)
|
||||||
@ -95,7 +102,7 @@ class ConfigTableDirective(rst.Directive):
|
|||||||
|
|
||||||
options = []
|
options = []
|
||||||
for module in modules:
|
for module in modules:
|
||||||
retval = self._doc_module(module)
|
retval = self._doc_module(module, exclude_list)
|
||||||
if retval:
|
if retval:
|
||||||
options.extend(retval)
|
options.extend(retval)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user