diff makeitso/template.py @ 122:b2152efec89a

get the description from the docstring if applicable
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 19 Jan 2011 18:24:58 -0800
parents c3b8ce33d3ad
children cfd4f1e91090
line wrap: on
line diff
--- a/makeitso/template.py	Wed Jan 19 18:18:47 2011 -0800
+++ b/makeitso/template.py	Wed Jan 19 18:24:58 2011 -0800
@@ -13,6 +13,7 @@
         return False
 Undefined = Undefined() # singleton
 
+
 class Variable(object):
     """variable object for MakeItSo templates"""
     
@@ -125,6 +126,14 @@
             assert os.path.exists(path), "%s does not exist" % path
             self._templates.append(path)
 
+    @classmethod
+    def get_description(cls):
+        if hasattr(cls, 'description'):
+            if cls.description:
+                return cls.description
+        if hasattr(cls, '__doc__'):
+            return cls.__doc__
+
     def get_variables(self, **variables):
         # XXX could do this in the ctor
         vars = ContentTemplate.get_variables(self, **variables)