A few more refinements to the documentation

This commit is contained in:
James Vega 2003-11-18 05:11:35 +00:00
parent 20674eaece
commit f66c567355
2 changed files with 25 additions and 13 deletions

View File

@ -36,3 +36,6 @@ pre {
.trodd { .trodd {
background:white; background:white;
} }
.underline {
text-decoration:underline;
}

View File

@ -48,6 +48,7 @@ import debug
import callbacks import callbacks
commandDict = {} commandDict = {}
firstChars = {}
def prepIndex(): def prepIndex():
directory = os.path.join('docs', 'plugins') directory = os.path.join('docs', 'plugins')
@ -70,6 +71,7 @@ def prepIndex():
def makePluginDocumentation(pluginWindow): def makePluginDocumentation(pluginWindow):
global commandDict global commandDict
global firstChars
trClasses = { 'treven':'trodd', 'trodd':'treven' } trClasses = { 'treven':'trodd', 'trodd':'treven' }
trClass = 'treven' trClass = 'treven'
(pluginName, module, plugin) = pluginWindow[1] (pluginName, module, plugin) = pluginWindow[1]
@ -108,6 +110,8 @@ def makePluginDocumentation(pluginWindow):
commandDict[attr].append(pluginName) commandDict[attr].append(pluginName)
else: else:
commandDict[attr] = [pluginName] commandDict[attr] = [pluginName]
if attr[0] not in firstChars:
firstChars[attr[0]] = ''
method = getattr(plugin, attr) method = getattr(plugin, attr)
if hasattr(method, '__doc__'): if hasattr(method, '__doc__'):
doclines = method.__doc__.splitlines() doclines = method.__doc__.splitlines()
@ -121,9 +125,9 @@ def makePluginDocumentation(pluginWindow):
morehelp = cgi.escape(morehelp) morehelp = cgi.escape(morehelp)
trClass = trClasses[trClass] trClass = trClasses[trClass]
fd.write(textwrap.dedent(""" fd.write(textwrap.dedent("""
<tr class="%s"><td>%s</td><td>%s</td><td class="detail">%s <tr class="%s" name="%s" id="%s"><td>%s</td><td>%s</td>
</td></tr> <td class="detail">%s</td></tr>
""") % (trClass, attr, help, morehelp)) """) % (trClass, attr, attr, attr, help, morehelp))
fd.write(textwrap.dedent(""" fd.write(textwrap.dedent("""
</table> </table>
""")) """))
@ -163,7 +167,9 @@ def finishIndex():
fd.close() fd.close()
def makeCommandsIndex(): def makeCommandsIndex():
from string import ascii_lowercase
global commandDict global commandDict
global firstChars
directory = os.path.join('docs', 'plugins') directory = os.path.join('docs', 'plugins')
if not os.path.exists(directory): if not os.path.exists(directory):
os.mkdir(directory) os.mkdir(directory)
@ -178,23 +184,26 @@ def makeCommandsIndex():
<link rel="stylesheet" type="text/css" href="supybot.css"> <link rel="stylesheet" type="text/css" href="supybot.css">
<body><div> <body><div>
<h2>Supybot Commands Index</h2> <h2>Supybot Commands Index</h2>
<strong>Command</strong> (Plugins)<br>
""")) """))
commands = [c for c in commandDict.iterkeys()] commands = [c for c in commandDict.iterkeys()]
commands.sort() commands.sort()
alphas = [] for i in ascii_lowercase:
for command in commands: if i in firstChars:
char = command[0] fd.write('<a href="#%s">%s</a> ' % (i, i.capitalize()))
if char in alphas:
pass
else: else:
alphas.append(char) fd.write('%s ' % i.capitalize())
fd.write('<h2 id="%s" style="text-decoration:underline">%s'\ firstChars.clear()
'</h2>\n' % (char, char.capitalize())) fd.write('\n<br><br><strong>Command</strong> (Plugins)<br>')
for command in commands:
c = command[0]
if c not in firstChars:
firstChars[c] = ''
fd.write('<h2 name="%s" id="%s" class="underline">%s</h2>\n' %
(c, c, c.capitalize()))
plugins = commandDict[command] plugins = commandDict[command]
plugins.sort() plugins.sort()
fd.write('<strong>%s</strong> (%s)<br>\n' % (command, fd.write('<strong>%s</strong> (%s)<br>\n' % (command,
', '.join(['<a href="%s.html">%s</a>' % (p, p) ', '.join(['<a href="%s.html#%s">%s</a>' % (p,command,p)
for p in plugins]))) for p in plugins])))
fd.write(textwrap.dedent(""" fd.write(textwrap.dedent("""
</div> </div>