mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
It actually works now, but it's ugly.
This commit is contained in:
parent
2266faec5f
commit
c662da1621
@ -30,6 +30,7 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import cgi
|
||||||
import imp
|
import imp
|
||||||
import sys
|
import sys
|
||||||
import os.path
|
import os.path
|
||||||
@ -51,7 +52,7 @@ def makePluginDocumentation(filename):
|
|||||||
pluginName = filename.split('.')[0]
|
pluginName = filename.split('.')[0]
|
||||||
moduleInfo = imp.find_module(pluginName)
|
moduleInfo = imp.find_module(pluginName)
|
||||||
## try:
|
## try:
|
||||||
module = imp.load_module(filename, *moduleInfo)
|
module = imp.load_module(pluginName, *moduleInfo)
|
||||||
## except ImportError, e:
|
## except ImportError, e:
|
||||||
## print >>sys.stderr, "Plugin %s could not be imported:" % filename
|
## print >>sys.stderr, "Plugin %s could not be imported:" % filename
|
||||||
## print >>sys.stderr, e
|
## print >>sys.stderr, e
|
||||||
@ -64,9 +65,9 @@ def makePluginDocumentation(filename):
|
|||||||
fd = file('plugindocs/%s.html' % pluginName, 'w')
|
fd = file('plugindocs/%s.html' % pluginName, 'w')
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent("""
|
||||||
<html><title>Documentation for the %s plugin for Supybot</title>
|
<html><title>Documentation for the %s plugin for Supybot</title>
|
||||||
<body>
|
<body>%s<br><br>
|
||||||
<table><tr><td>Command</td><td>Args</td><td>Detailed Help</td></tr>
|
<table><tr><td>Command</td><td>Args</td><td>Detailed Help</td></tr>
|
||||||
""") % pluginName)
|
""") % (pluginName, cgi.escape(module.__doc__)))
|
||||||
for attr in dir(plugin):
|
for attr in dir(plugin):
|
||||||
if plugin.isCommand(attr):
|
if plugin.isCommand(attr):
|
||||||
method = getattr(plugin, attr)
|
method = getattr(plugin, attr)
|
||||||
@ -80,18 +81,20 @@ def makePluginDocumentation(filename):
|
|||||||
morehelp = ' '.join(doclines)
|
morehelp = ' '.join(doclines)
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent("""
|
||||||
<tr><td>%s</td><td>%s</td><td>%s</td></tr>
|
<tr><td>%s</td><td>%s</td><td>%s</td></tr>
|
||||||
""") % (attr, help, morehelp))
|
""") % (attr, cgi.escape(help), cgi.escape(morehelp)))
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent("""
|
||||||
</table>
|
</table>
|
||||||
"""))
|
"""))
|
||||||
if hasattr(module, 'example'):
|
if hasattr(module, 'example'):
|
||||||
|
s = module.example.encode('string-escape')
|
||||||
|
s = s.replace('\\n', '\n')
|
||||||
fd.write(textwrap.dedent("""
|
fd.write(textwrap.dedent("""
|
||||||
<p>Here's an example session with this plugin:
|
<p>Here's an example session with this plugin:
|
||||||
<pre>
|
<pre>
|
||||||
%s
|
%s
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
""") % module.example)
|
""") % cgi.escape(s))
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user