From b8c6b3795afb69e7fdd23bf3c19aaf34077dbcfd Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 20 Nov 2003 00:46:31 +0000 Subject: [PATCH] Minor stylistic updates; also made plugins.html and commands.html go to docs/ and link to docs/plugins/__.html --- tools/generate-plugin-documentation.py | 70 +++++++++++--------------- 1 file changed, 30 insertions(+), 40 deletions(-) diff --git a/tools/generate-plugin-documentation.py b/tools/generate-plugin-documentation.py index 07d6908be..c4fd90f41 100755 --- a/tools/generate-plugin-documentation.py +++ b/tools/generate-plugin-documentation.py @@ -58,7 +58,8 @@ def genHeader(title, meta=''): %s - + %s
""" % (title, meta) @@ -87,12 +88,12 @@ def prepIndex(): directory = os.path.join('docs', 'plugins') if not os.path.exists(directory): os.mkdir(directory) - fd = file(os.path.join(directory, 'plugins.html'), 'w') - fd.write(textwrap.dedent(""" + fd = file(os.path.join('docs', 'plugins.html'), 'w') + fd.write(textwrap.dedent(''' %s
Supybot Plugin Documentation Index

- """ % genHeader('Supybot Plugin Documentation'))) + ''' % genHeader('Supybot Plugin Documentation'))) fd.close() def makePluginDocumentation(pluginWindow): @@ -112,23 +113,22 @@ def makePluginDocumentation(pluginWindow): directory = os.path.join('docs', 'plugins') if not os.path.exists(directory): os.mkdir(directory) - id = file(os.path.join(directory, 'plugins.html'), 'a') - id.write(textwrap.dedent(""" - %s - """ % (pluginName, cpluginName))) + id = file(os.path.join('docs', 'plugins.html'), 'a') + id.write('%s\n' % + (pluginName, cpluginName)) fd = file(os.path.join(directory,'%s.html' % pluginName), 'w') title = 'Documentation for the %s plugin for Supybot' % pluginName - meta = """ + meta = ''' - - - """ % (next, prev) - fd.write(textwrap.dedent(""" + + + ''' % (next, prev) + fd.write(textwrap.dedent(''' %s
%s

- """) % (genHeader(title, meta), cgi.escape(module.__doc__ or ""))) + ''' % (genHeader(title, meta), cgi.escape(module.__doc__ or "")))) attrs = [x for x in dir(plugin) if plugin.isCommand(x) and not x.startswith('_')] id.write('(%s)
\n' % ', '.join(attrs)) @@ -151,37 +151,26 @@ def makePluginDocumentation(pluginWindow): help = cgi.escape(help) morehelp = cgi.escape(morehelp) trClass = trClasses[trClass] - fd.write(textwrap.dedent(""" + fd.write(textwrap.dedent(''' - """) % (trClass, attr, attr, attr, help, morehelp)) - fd.write(textwrap.dedent(""" -
CommandArgs Detailed Help
%s%s %s
- """)) - if hasattr(module, 'example'): - s = module.example.encode('string-escape') - s = s.replace('\\n', '\n') - s = s.replace("\\'", "'") - fd.write(textwrap.dedent(""" -

Here's an example session with this plugin:

-
-        %s
-        
- """) % cgi.escape(s)) - fd.write(textwrap.dedent(""" + ''' % (trClass, attr, attr, attr, help, morehelp))) + fd.write('\n') + fd.write(textwrap.dedent('''

- <- %s | Plugin Index | + <- %s | + Plugin Index | Home | Command Index - | %s -> + | %s -> %s - """ % (prev, cprev, next, cnext, genFooter()))) + ''' % (prev, cprev, next, cnext, genFooter()))) fd.close() id.close() def finishIndex(): - directory = os.path.join('docs', 'plugins') + directory = 'docs' if not os.path.exists(directory): os.mkdir(directory) fd = file(os.path.join(directory, 'plugins.html'), 'a') @@ -192,16 +181,16 @@ def makeCommandsIndex(): from string import ascii_lowercase global commandDict global firstChars - directory = os.path.join('docs', 'plugins') + directory = 'docs' if not os.path.exists(directory): os.mkdir(directory) fd = file(os.path.join(directory, 'commands.html'), 'w') title = 'Supybot Commands Index' - fd.write(textwrap.dedent(""" + fd.write(textwrap.dedent(''' %s
%s

- """ % (genHeader(title), title))) + ''' % (genHeader(title), title))) commands = [c for c in commandDict.iterkeys()] commands.sort() for i in ascii_lowercase: @@ -211,6 +200,7 @@ def makeCommandsIndex(): fd.write('%s ' % i.capitalize()) firstChars.clear() fd.write('
\n
') + pluginLink = '%s' for command in commands: c = command[0] if c not in firstChars: @@ -222,9 +212,9 @@ def makeCommandsIndex(): (c, c, c.capitalize())) plugins = commandDict[command] plugins.sort() - fd.write('%s (%s)
\n' % (command, - ', '.join(['%s' % (p,command,p) - for p in plugins]))) + fd.write('%s (%s)
\n' % + (command, + ', '.join([pluginLink % (p,command,p) for p in plugins]))) fd.write('\n
') fd.write(textwrap.dedent(genFooter())) fd.close()