Mercurial > hg > MakeItSo
changeset 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 | d28cde6c942e |
children | 8db34885ebe4 |
files | makeitso/cli.py makeitso/python.py makeitso/template.py |
diffstat | 3 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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)
--- 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)