Jason R. Coombs avatar Jason R. Coombs committed 2e640c5

A better implementation of the help template. Fixes #27 (for real this time).

Comments (0)

Files changed (3)

 		cmd, _, cmd_args = message.partition(' ')
 		return cmd_args
 
+	@property
+	def alias_names(self):
+		return [alias.name for alias in self.aliases]
+
 class AliasHandler(CommandHandler):
 	class_priority = 2
 

pmxbot/web/templates/help.html

 
 <h3>Commands</h3>
 <table style="border: none;">
-{% for name, doc, aliases in commands %}
-	<tr><td class="left" style="font-weight: bold; font-family: fixed-width; ">{{ name }}
-	{% if aliases %}
-		{{ aliases }}
-	{% endif %}
-	</td><td>{{ doc }}</td></tr>
+{% for command in commands %}
+	<tr><td class="left" style="font-weight: bold; font-family: fixed-width; ">{{ command.name }}
+	{% if command.alias_names %}
+		{{ command.alias_names }}
+    {% endif %}
+	</td><td>{{ command.doc }}</td></tr>
 {% endfor %}
 </table>
 
 <h3>Triggers</h3>
 <table style="border: none;">
-{% for name, doc in contains %}
-	<tr><td class="left" style="font-weight: bold; font-family: fixed-width; ">{{ name }}</td>
-	<td>{{ doc|default("") }}</td></tr>
+{% for command in contains %}
+	<tr><td class="left" style="font-weight: bold; font-family: fixed-width; ">{{ command.name }}</td>
+	<td>{{ command.doc }}</td></tr>
 {% endfor %}
 </table>
 

pmxbot/web/viewer.py

 		by_name = lambda handler: handler.name
 		for handler in sorted(pmxbot.core.Handler._registry, key=by_name):
 			if type(handler) is pmxbot.core.CommandHandler:
-				commands.append((handler.name, handler.doc, handler.aliases))
+				commands.append(handler)
 			elif isinstance(handler, pmxbot.core.ContainsHandler):
-				contains.append((handler.name, handler.doc))
+				contains.append(handler)
 		context['commands'] = commands
 		context['contains'] = contains
 		return context
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.