WebDoc: Add plugin description and fix crash if a command has no description (as Factoids.learn).
parent
fec7cb8529
commit
c3736cb967
|
@ -71,6 +71,8 @@ DEFAULT_TEMPLATES = {
|
||||||
|
|
||||||
<h1>%(plugin)s</h1>
|
<h1>%(plugin)s</h1>
|
||||||
|
|
||||||
|
<p>%(description)s</p>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Command</th>
|
<th>Command</th>
|
||||||
|
@ -112,12 +114,18 @@ class WebDocServerCallback(httpserver.SupyHTTPServerCallback):
|
||||||
response = 200
|
response = 200
|
||||||
callback = cbs[name]
|
callback = cbs[name]
|
||||||
commands = callback.listCommands()
|
commands = callback.listCommands()
|
||||||
|
description = callback.__doc__
|
||||||
|
if not description or description.startswith('Add the help for'):
|
||||||
|
description = ''
|
||||||
if commands:
|
if commands:
|
||||||
commands.sort()
|
commands.sort()
|
||||||
def formatter(command):
|
def formatter(command):
|
||||||
command = list(map(callbacks.canonicalName,
|
command = list(map(callbacks.canonicalName,
|
||||||
command.split(' ')))
|
command.split(' ')))
|
||||||
doc = callback.getCommandMethod(command).__doc__
|
doc = callback.getCommandMethod(command).__doc__
|
||||||
|
if not doc:
|
||||||
|
return '<tr><td>%s</td><td> </td></tr>' % \
|
||||||
|
' '.join(command)
|
||||||
doclines = doc.splitlines()
|
doclines = doc.splitlines()
|
||||||
s = cgi.escape('%s %s' % (name, doclines.pop(0)))
|
s = cgi.escape('%s %s' % (name, doclines.pop(0)))
|
||||||
if doclines:
|
if doclines:
|
||||||
|
@ -131,6 +139,7 @@ class WebDocServerCallback(httpserver.SupyHTTPServerCallback):
|
||||||
output = httpserver.get_template('webdoc/plugin.html') % {
|
output = httpserver.get_template('webdoc/plugin.html') % {
|
||||||
'plugin': name,
|
'plugin': name,
|
||||||
'table': table,
|
'table': table,
|
||||||
|
'description': description
|
||||||
}
|
}
|
||||||
|
|
||||||
self.send_response(response)
|
self.send_response(response)
|
||||||
|
|
Loading…
Reference in New Issue