supybot-plugin-doc: Recursively document *all* groups

Not just groups that are values themselves.
This commit is contained in:
Valentin Lorentz 2021-04-22 00:26:30 +02:00
parent c7d85e73d7
commit e16c10ff77

View File

@ -159,13 +159,17 @@ class PluginDoc(object):
self.appendLine('No configuration for this plugin')
else:
for confValues in self.genConfig(confs, 0):
(name, isChan, isNet, help, default, indent) = confValues
self.lines.append('.. _conf-%s:\n' % name)
(name, kind, help, default, indent) = confValues
self.appendLine('.. _conf-%s:' % name, indent - 1)
self.lines.append('\n')
self.appendLine('%s' % name, indent - 1)
if default:
self.appendLine(
('This config variable defaults to %s, '
'is%s network-specific, and is %s channel-specific.')
% (default, isNet, isChan), indent)
('This config variable defaults to %s, %s')
% (default, kind), indent)
else:
self.appendLine('This %s' % kind, indent)
if help:
self.lines.append('')
self.appendLine(help, indent)
self.lines.append('')
@ -209,12 +213,14 @@ class PluginDoc(object):
self.appendLine('No configuration for this plugin', 2)
else:
for confValues in self.genConfig(confs, 2):
(name, isChan, isNet, help, default, indent) = confValues
(name, kind, help, default, indent) = confValues
self.appendLine('* %s' % name, indent - 1)
if default:
self.appendLine(
('This config variable defaults to %s, '
'is%s network-specific, and is %s channel-specific.')
% (default, isNet, isChan), indent)
('This config variable defaults to %s, %s')
% (default, kind), indent)
else:
self.appendLine('This %s' % kind, indent)
self.appendLine(help, indent)
return '\n'.join(self.lines) + '\n'
@ -223,11 +229,9 @@ class PluginDoc(object):
if not confVars:
return
for (c, v) in confVars:
if not isinstance(v, registry.Value):
# Don't log groups
continue
name = v._name
indent = origindent + 1
if isinstance(v, registry.Value):
try:
default = utils.str.dqrepr(str(v))
help = v.help()
@ -236,7 +240,15 @@ class PluginDoc(object):
else:
cv = '' if v._channelValue else ' not'
nv = '' if v._networkValue else ' not'
yield (name, cv, nv, help, default, indent)
kind = (
'is%s network-specific, and is %s channel-specific.'
% (nv, cv)
)
else:
help = ''
default = ''
kind = 'is a group of:'
yield (name, kind, help, default, indent)
for confValues in self.genConfig(v, indent):
yield confValues