From 484bb71b3ab40f4aa9df5498a4b127344db9b0a6 Mon Sep 17 00:00:00 2001 From: James Vega Date: Thu, 20 Nov 2003 00:03:26 +0000 Subject: [PATCH] supybot.css is in supybot-www now. Major overhaul to docs generator --- docs/plugins/supybot.css | 41 -------- tools/generate-plugin-documentation.py | 135 ++++++++++++++----------- 2 files changed, 76 insertions(+), 100 deletions(-) delete mode 100644 docs/plugins/supybot.css diff --git a/docs/plugins/supybot.css b/docs/plugins/supybot.css deleted file mode 100644 index e42698f61..000000000 --- a/docs/plugins/supybot.css +++ /dev/null @@ -1,41 +0,0 @@ -body { - background:white; -} - -table { - border: 2px solid lightsteelblue; - border-collapse: collapse; -} - -tr#headers { - text-align:left; - font-weight:bold; -} - -td { - padding: 0px 3px 0px 3px; - border: 1px solid lightsteelblue; - white-space: nowrap; -} - -pre { - border:1px solid lightsteelblue; - border-bottom:3px solid lightsteelblue; - padding:3px; - background:floralwhite; -} - -.detail { - white-space:normal; -} - -.treven { - background:aliceblue; -} - -.trodd { - background:white; -} -.underline { - text-decoration:underline; -} diff --git a/tools/generate-plugin-documentation.py b/tools/generate-plugin-documentation.py index 4d60d52e6..07d6908be 100755 --- a/tools/generate-plugin-documentation.py +++ b/tools/generate-plugin-documentation.py @@ -50,61 +50,88 @@ import callbacks commandDict = {} firstChars = {} -def prepIndex(): - directory = os.path.join('docs', 'plugins') - if not os.path.exists(directory): - os.mkdir(directory) - fd = file(os.path.join(directory, 'index.html'), 'w') - fd.write(textwrap.dedent(""" +def genHeader(title, meta=''): + return """ - Supybot plugin documentation - + %s + + %s
-

Supybot Plugin Documentation Index

- Plugin (Command list)

- """)) + """ % (title, meta) + +def genFooter(): + return """ +
+

+ Valid HTML 4.01! + + Valid CSS! + + SourceForge.net Logo +
+ + + """ + +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(""" + %s +
Supybot Plugin Documentation Index
+
+ """ % genHeader('Supybot Plugin Documentation'))) fd.close() def makePluginDocumentation(pluginWindow): global commandDict global firstChars - trClasses = { 'treven':'trodd', 'trodd':'treven' } - trClass = 'treven' + trClasses = { 'even':'odd', 'odd':'even' } + trClass = 'even' (pluginName, module, plugin) = pluginWindow[1] print 'Generating documentation for %s.py' % pluginName prev = pluginWindow[0][0] or 'index' next = pluginWindow[2][0] or 'index' + # can't use string.capitalize() because it lowercases every character + # except the first. must create our own capitalized names + cpluginName = '%s%s' % (pluginName[0].upper(), pluginName[1:]) + cprev = '%s%s' % (prev[0].upper(), prev[1:]) + cnext = '%s%s' % (next[0].upper(), next[1:]) directory = os.path.join('docs', 'plugins') if not os.path.exists(directory): os.mkdir(directory) - id = file(os.path.join(directory, 'index.html'), 'a') + id = file(os.path.join(directory, 'plugins.html'), 'a') id.write(textwrap.dedent(""" %s - """ % (pluginName, pluginName.capitalize()))) + """ % (pluginName, cpluginName))) fd = file(os.path.join(directory,'%s.html' % pluginName), 'w') - fd.write(textwrap.dedent(""" - - - - - Documentation for the %s plugin for Supybot - + title = 'Documentation for the %s plugin for Supybot' % pluginName + meta = """ -
-

%s



+ """ % (next, prev) + fd.write(textwrap.dedent(""" + %s +
%s

- """) % (pluginName, next, prev, 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)) + id.write('(%s)
\n' % ', '.join(attrs)) for attr in attrs: if attr in commandDict: commandDict[attr].append(pluginName) @@ -143,14 +170,13 @@ def makePluginDocumentation(pluginWindow): """) % cgi.escape(s)) fd.write(textwrap.dedent(""" -
-
- <- %s | Index | %s -> -
- - - """ % (prev, prev.capitalize(), next, next.capitalize()))) +
+
+ <- %s | Plugin Index | + Home | Command Index + | %s -> + %s + """ % (prev, cprev, next, cnext, genFooter()))) fd.close() id.close() @@ -158,12 +184,8 @@ def finishIndex(): directory = os.path.join('docs', 'plugins') if not os.path.exists(directory): os.mkdir(directory) - fd = file(os.path.join(directory, 'index.html'), 'a') - fd.write(textwrap.dedent(""" -
- - - """)) + fd = file(os.path.join(directory, 'plugins.html'), 'a') + fd.write(textwrap.dedent(genFooter())) fd.close() def makeCommandsIndex(): @@ -174,17 +196,12 @@ def makeCommandsIndex(): 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(""" - - - - - Supybot Commands Index - -
-

Supybot Commands Index

- """)) + %s +
%s

+
+ """ % (genHeader(title), title))) commands = [c for c in commandDict.iterkeys()] commands.sort() for i in ascii_lowercase: @@ -193,23 +210,23 @@ def makeCommandsIndex(): else: fd.write('%s ' % i.capitalize()) firstChars.clear() - fd.write('\n

Command (Plugins)
') + fd.write('
\n
') for command in commands: c = command[0] if c not in firstChars: + if firstChars: + fd.write('\n

') + fd.write('\n
') firstChars[c] = '' - fd.write('

%s

\n' % + fd.write('
%s
\n' % (c, c, c.capitalize())) plugins = commandDict[command] plugins.sort() - fd.write('%s (%s)
\n' % (command, + fd.write('%s (%s)
\n' % (command, ', '.join(['%s' % (p,command,p) for p in plugins]))) - fd.write(textwrap.dedent(""" -
- - - """)) + fd.write('\n') + fd.write(textwrap.dedent(genFooter())) fd.close() def genPlugins():
CommandArgs Detailed Help