From 37531a7c2fb357d92afaea327d6a4d1cc69a4fd1 Mon Sep 17 00:00:00 2001 From: kennyballou Date: Wed, 24 Oct 2012 16:06:09 -0600 Subject: Add printing of doc string to ``help`` target Updated ``target`` decorator to forward the doc-string of the decorated method to the returned wrapper method. xnt.xenant, when printing targets, can access the forwarded doc-string and print it as a description of the target --- xnt/__init__.py | 1 + xnt/xenant.py | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/xnt/__init__.py b/xnt/__init__.py index 37abe45..70234a0 100644 --- a/xnt/__init__.py +++ b/xnt/__init__.py @@ -6,4 +6,5 @@ def target(fn): print(fn.__name__ + ":") return fn() wrap.decorator = "target" + wrap.__doc__ = fn.__doc__ return wrap diff --git a/xnt/xenant.py b/xnt/xenant.py index 2a0de1c..fc6cbae 100644 --- a/xnt/xenant.py +++ b/xnt/xenant.py @@ -16,7 +16,7 @@ def main(): printVersion() elif arg == "help": printVersion() - print("\n\n") + print("\n") printTargets() elif arg: target = arg @@ -54,7 +54,10 @@ def printTargets(): try: fa = getattr(build, f) if fa.decorator == "target": - print(f + ":\n") + print(f + ":") + if fa.__doc__: + print(fa.__doc__) + print("\n") except AttributeError: pass except AttributeError: -- cgit v1.2.1