# HG changeset patch # User Jeff Hammel # Date 1295490298 28800 # Node ID b2152efec89ae1d1e0fbc38ecf211556f1225cd3 # Parent d28cde6c942e539dc2e9f233a8c55c3fdb897be6 get the description from the docstring if applicable diff -r d28cde6c942e -r b2152efec89a makeitso/cli.py --- a/makeitso/cli.py Wed Jan 19 18:18:47 2011 -0800 +++ b/makeitso/cli.py Wed Jan 19 18:24:58 2011 -0800 @@ -16,7 +16,7 @@ return a command line parser for the template """ usage = getattr(self, 'usage', '%prog [options] output') - description = getattr(self.template_class, 'description', None) + description = self.template_class.get_description() parser = OptionParser(usage=usage, description=description) # add the variables as options diff -r d28cde6c942e -r b2152efec89a makeitso/python.py --- a/makeitso/python.py Wed Jan 19 18:18:47 2011 -0800 +++ b/makeitso/python.py Wed Jan 19 18:24:58 2011 -0800 @@ -91,6 +91,7 @@ """ CLI front end for the python package template """ + usage = '%prog [options] project' def main(args=sys.argv[1:]): cli = PythonPackageCLI(PythonPackageTemplate) diff -r d28cde6c942e -r b2152efec89a makeitso/template.py --- 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)