From 160b7b2fddb7b420f67fc01de0ef07c50d042916 Mon Sep 17 00:00:00 2001 From: James Vega Date: Tue, 28 Apr 2009 00:38:35 -0400 Subject: [PATCH] supybot-plugin-doc: Stub support for rendering different formats Signed-off-by: James Vega --- scripts/supybot-plugin-doc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scripts/supybot-plugin-doc b/scripts/supybot-plugin-doc index 4f137a9f6..b1788a8d4 100644 --- a/scripts/supybot-plugin-doc +++ b/scripts/supybot-plugin-doc @@ -162,13 +162,18 @@ class PluginDoc(object): def genDoc(m, options): Plugin = PluginDoc(m) print 'Generating documentation for %s...' % Plugin.name - path = os.path.join(options.outputDir, '%s.stx' % Plugin.name) + path = os.path.join(options.outputDir, '%s.%s' % (Plugin.name, + options.format)) try: fd = file(path, 'w') except EnvironmentError, e: error('Unable to open %s for writing.' % path) + f = getattr(Plugin, 'render%s' % options.format.upper(), None) + if f is None: + fd.close() + error('Unknown render format: `%s\'' % options.format) try: - fd.write(Plugin.renderSTX()) + fd.write(f()) finally: fd.close() @@ -186,6 +191,9 @@ if __name__ == '__main__': parser.add_option('-o', '--output-dir', dest='outputDir', default='.', help='Specifies the directory in which to write the ' 'documentation for the plugin.') + parser.add_option('-f', '--format', dest='format', choices=['rst', 'stx'], + default='stx', help='Specifies which output format to ' + 'use.') parser.add_option('--plugins-dir', action='append', dest='pluginsDirs', default=[], help='Looks in in the given directory for plugins and '