Minor changes.

This commit is contained in:
Jeremy Fincher 2003-10-14 03:55:04 +00:00
parent b692681e1c
commit 66d019827b

View File

@ -29,6 +29,8 @@
# POSSIBILITY OF SUCH DAMAGE. # POSSIBILITY OF SUCH DAMAGE.
### ###
import supybot
import os import os
import cgi import cgi
import imp import imp
@ -37,16 +39,13 @@ import os.path
import textwrap import textwrap
import traceback import traceback
if 'src' not in sys.path:
sys.path.insert(0, 'src')
import fix
import conf import conf
import debug
import callbacks import callbacks
def makePluginDocumentation(filename): def makePluginDocumentation(filename):
print 'Generating documentation for %s' % filename
trClasses = { 'lightyellow':'lightgreen', 'lightgreen':'lightyellow' } trClasses = { 'lightyellow':'lightgreen', 'lightgreen':'lightyellow' }
trClass = 'lightyellow' trClass = 'lightyellow'
pluginName = filename.split('.')[0] pluginName = filename.split('.')[0]
@ -55,7 +54,14 @@ def makePluginDocumentation(filename):
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)
if not hasattr(module, 'Class'):
print '%s is not a plugin.' % filename
return
try:
plugin = module.Class() plugin = module.Class()
except Exception, e:
print '%s could not be loaded: %s' % (filename, debug.exnToString(e))
return
if isinstance(plugin, callbacks.Privmsg) and not \ if isinstance(plugin, callbacks.Privmsg) and not \
isinstance(plugin, callbacks.PrivmsgRegexp): isinstance(plugin, callbacks.PrivmsgRegexp):
fd = file(os.path.join(directory,'%s.html' % pluginName), 'w') fd = file(os.path.join(directory,'%s.html' % pluginName), 'w')
@ -84,10 +90,12 @@ def makePluginDocumentation(filename):
doclines = filter(None, doclines) doclines = filter(None, doclines)
doclines = map(str.strip, doclines) doclines = map(str.strip, doclines)
morehelp = ' '.join(doclines) morehelp = ' '.join(doclines)
help = cgi.escape(help)
morehelp = cgi.escape(morehelp)
fd.write(textwrap.dedent(""" fd.write(textwrap.dedent("""
<tr class="%s"><td>%s</td><td>%s</td><td class="detail">%s <tr class="%s"><td>%s</td><td>%s</td><td class="detail">%s
</td></tr> </td></tr>
""") % (trClass, attr, cgi.escape(help), cgi.escape(morehelp))) """) % (trClass, attr, help, morehelp))
fd.write(textwrap.dedent(""" fd.write(textwrap.dedent("""
</table> </table>
""")) """))
@ -111,7 +119,7 @@ def makePluginDocumentation(filename):
if __name__ == '__main__': if __name__ == '__main__':
for directory in conf.pluginDirs: for directory in conf.pluginDirs:
for filename in os.listdir(directory): for filename in os.listdir(directory):
if filename.endswith('.py') and filename.lower() != filename: if filename.endswith('.py') and filename[0].isupper():
makePluginDocumentation(filename) makePluginDocumentation(filename)