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