summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkennyballou <kballou@onyx.boisestate.edu>2012-10-24 16:06:09 -0600
committerkballou <kballou@onyx.boisestate.edu>2012-10-24 16:06:09 -0600
commit37531a7c2fb357d92afaea327d6a4d1cc69a4fd1 (patch)
tree22d7b12b00f6728aa889c837fd4e85102b79d58c
parent823b5b1bf0db8d9a269280b0c5a8ad1e0efae8fc (diff)
downloadxnt-37531a7c2fb357d92afaea327d6a4d1cc69a4fd1.tar.gz
xnt-37531a7c2fb357d92afaea327d6a4d1cc69a4fd1.tar.xz
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
-rw-r--r--xnt/__init__.py1
-rw-r--r--xnt/xenant.py7
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: