mirror of https://github.com/Mikaela/Limnoria.git
supybot.css is in supybot-www now. Major overhaul to docs generator
This commit is contained in:
parent
a1780908bd
commit
484bb71b3a
|
@ -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;
|
|
||||||
}
|
|
|
@ -50,61 +50,88 @@ import callbacks
|
||||||
commandDict = {}
|
commandDict = {}
|
||||||
firstChars = {}
|
firstChars = {}
|
||||||
|
|
||||||
def prepIndex():
|
def genHeader(title, meta=''):
|
||||||
directory = os.path.join('docs', 'plugins')
|
return """
|
||||||
if not os.path.exists(directory):
|
|
||||||
os.mkdir(directory)
|
|
||||||
fd = file(os.path.join(directory, 'index.html'), 'w')
|
|
||||||
fd.write(textwrap.dedent("""
|
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
"http://www.w3.org/TR/html4/strict.dtd">
|
||||||
<html lang="en-us">
|
<html lang="en-us">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
<title>Supybot plugin documentation</title>
|
<title>%s</title>
|
||||||
<link rel="stylesheet" type="text/css" href="supybot.css">
|
<link rel="stylesheet" type="text/css" href="http://supybot.sourceforge.net/css/supybot.css">
|
||||||
|
%s
|
||||||
<body><div>
|
<body><div>
|
||||||
<h2>Supybot Plugin Documentation Index</h2>
|
""" % (title, meta)
|
||||||
<strong>Plugin</strong> (Command list)<br><br>
|
|
||||||
"""))
|
def genFooter():
|
||||||
|
return """
|
||||||
|
</div>
|
||||||
|
<div style="text-align: center"><br /><!-- Buttons -->
|
||||||
|
<a href="http://validator.w3.org/check/referer"><img
|
||||||
|
src="http://www.w3.org/Icons/valid-html401"
|
||||||
|
alt="Valid HTML 4.01!" height="31" width="88" /></a>
|
||||||
|
|
||||||
|
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img
|
||||||
|
src="http://jigsaw.w3.org/css-validator/images/vcss"
|
||||||
|
alt="Valid CSS!" /></a>
|
||||||
|
|
||||||
|
<a href="http://sourceforge.net"><img
|
||||||
|
src="http://sourceforge.net/sflogo.php?group_id=58965&type=1"
|
||||||
|
width="88" height="31" alt="SourceForge.net Logo" /></a>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
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
|
||||||
|
<div class="maintitle">Supybot Plugin Documentation Index</div>
|
||||||
|
<br />
|
||||||
|
""" % genHeader('Supybot Plugin Documentation')))
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
def makePluginDocumentation(pluginWindow):
|
def makePluginDocumentation(pluginWindow):
|
||||||
global commandDict
|
global commandDict
|
||||||
global firstChars
|
global firstChars
|
||||||
trClasses = { 'treven':'trodd', 'trodd':'treven' }
|
trClasses = { 'even':'odd', 'odd':'even' }
|
||||||
trClass = 'treven'
|
trClass = 'even'
|
||||||
(pluginName, module, plugin) = pluginWindow[1]
|
(pluginName, module, plugin) = pluginWindow[1]
|
||||||
print 'Generating documentation for %s.py' % pluginName
|
print 'Generating documentation for %s.py' % pluginName
|
||||||
prev = pluginWindow[0][0] or 'index'
|
prev = pluginWindow[0][0] or 'index'
|
||||||
next = pluginWindow[2][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')
|
directory = os.path.join('docs', 'plugins')
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
os.mkdir(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("""
|
id.write(textwrap.dedent("""
|
||||||
<strong><a href="%s.html">%s</a></strong>
|
<strong><a href="%s.html">%s</a></strong>
|
||||||
""" % (pluginName, pluginName.capitalize())))
|
""" % (pluginName, cpluginName)))
|
||||||
fd = file(os.path.join(directory,'%s.html' % pluginName), 'w')
|
fd = file(os.path.join(directory,'%s.html' % pluginName), 'w')
|
||||||
fd.write(textwrap.dedent("""
|
title = 'Documentation for the %s plugin for Supybot' % pluginName
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
meta = """
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
|
||||||
<html lang="en-us">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Documentation for the %s plugin for Supybot</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="supybot.css">
|
|
||||||
<link rel="home" title="Plugin Documentation Index" href="index.html">
|
<link rel="home" title="Plugin Documentation Index" href="index.html">
|
||||||
<link rel="next" href="%s.html">
|
<link rel="next" href="%s.html">
|
||||||
<link rel="previous" href="%s.html">
|
<link rel="previous" href="%s.html">
|
||||||
<body><div>
|
""" % (next, prev)
|
||||||
<h2>%s</h2><br><br><table>
|
fd.write(textwrap.dedent("""
|
||||||
|
%s
|
||||||
|
<div class="plugintitle">%s</div><br /><table>
|
||||||
<tr id="headers"><td>Command</td><td>Args</td><td>
|
<tr id="headers"><td>Command</td><td>Args</td><td>
|
||||||
Detailed Help</td></tr>
|
Detailed Help</td></tr>
|
||||||
""") % (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
|
attrs = [x for x in dir(plugin) if plugin.isCommand(x) and not
|
||||||
x.startswith('_')]
|
x.startswith('_')]
|
||||||
id.write('(%s)<br>\n' % ', '.join(attrs))
|
id.write('(%s)<br />\n' % ', '.join(attrs))
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
if attr in commandDict:
|
if attr in commandDict:
|
||||||
commandDict[attr].append(pluginName)
|
commandDict[attr].append(pluginName)
|
||||||
|
@ -143,14 +170,13 @@ def makePluginDocumentation(pluginWindow):
|
||||||
""") % cgi.escape(s))
|
""") % cgi.escape(s))
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent("""
|
||||||
</div>
|
</div>
|
||||||
<div style="text-align:center">
|
<div style="text-align: center;">
|
||||||
<br>
|
<br />
|
||||||
<a href="%s.html"><- %s</a> | <a href="index.html">Index</a> | <a
|
<a href="%s.html"><- %s</a> | <a href="plugins.html">Plugin Index</a> |
|
||||||
href="%s.html">%s -></a>
|
<a href="../index.html">Home</a> | <a href="commands.html">Command Index
|
||||||
</div>
|
</a> | <a href="%s.html">%s -></a>
|
||||||
</body>
|
%s
|
||||||
</html>
|
""" % (prev, cprev, next, cnext, genFooter())))
|
||||||
""" % (prev, prev.capitalize(), next, next.capitalize())))
|
|
||||||
fd.close()
|
fd.close()
|
||||||
id.close()
|
id.close()
|
||||||
|
|
||||||
|
@ -158,12 +184,8 @@ def finishIndex():
|
||||||
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)
|
||||||
fd = file(os.path.join(directory, 'index.html'), 'a')
|
fd = file(os.path.join(directory, 'plugins.html'), 'a')
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent(genFooter()))
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""))
|
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
def makeCommandsIndex():
|
def makeCommandsIndex():
|
||||||
|
@ -174,17 +196,12 @@ def makeCommandsIndex():
|
||||||
if not os.path.exists(directory):
|
if not os.path.exists(directory):
|
||||||
os.mkdir(directory)
|
os.mkdir(directory)
|
||||||
fd = file(os.path.join(directory, 'commands.html'), 'w')
|
fd = file(os.path.join(directory, 'commands.html'), 'w')
|
||||||
|
title = 'Supybot Commands Index'
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent("""
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
%s
|
||||||
"http://www.w3.org/TR/html4/strict.dtd">
|
<div class="maintitle">%s</div><br />
|
||||||
<html lang="en-us">
|
<div class="whitebox" style="text-align: center;">
|
||||||
<head>
|
""" % (genHeader(title), title)))
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
||||||
<title>Supybot Commands Index</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="supybot.css">
|
|
||||||
<body><div>
|
|
||||||
<h2>Supybot Commands Index</h2>
|
|
||||||
"""))
|
|
||||||
commands = [c for c in commandDict.iterkeys()]
|
commands = [c for c in commandDict.iterkeys()]
|
||||||
commands.sort()
|
commands.sort()
|
||||||
for i in ascii_lowercase:
|
for i in ascii_lowercase:
|
||||||
|
@ -193,23 +210,23 @@ def makeCommandsIndex():
|
||||||
else:
|
else:
|
||||||
fd.write('%s ' % i.capitalize())
|
fd.write('%s ' % i.capitalize())
|
||||||
firstChars.clear()
|
firstChars.clear()
|
||||||
fd.write('\n<br><br><strong>Command</strong> (Plugins)<br>')
|
fd.write('</div>\n<br />')
|
||||||
for command in commands:
|
for command in commands:
|
||||||
c = command[0]
|
c = command[0]
|
||||||
if c not in firstChars:
|
if c not in firstChars:
|
||||||
|
if firstChars:
|
||||||
|
fd.write('\n</div><br />')
|
||||||
|
fd.write('\n<div class="whitebox">')
|
||||||
firstChars[c] = ''
|
firstChars[c] = ''
|
||||||
fd.write('<h2 name="%s" id="%s" class="underline">%s</h2>\n' %
|
fd.write('<div name="%s" id="%s" class="letter">%s</div>\n' %
|
||||||
(c, c, c.capitalize()))
|
(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">%s</a>' % (p,command,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('\n</div>')
|
||||||
</div>
|
fd.write(textwrap.dedent(genFooter()))
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""))
|
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
def genPlugins():
|
def genPlugins():
|
||||||
|
|
Loading…
Reference in New Issue