提交 2b8a74c7 authored 作者: bergstrj@lgcm's avatar bergstrj@lgcm

chomping in gen_oplist.py

上级 b69016e2
import sys
import gof import gof
import tensor import tensor
def isOp(thing): def isOp(thing):
return hasattr(thing, 'perform') return hasattr(thing, 'perform')
def chomp(s):
"""interpret and left-align a docstring"""
if 'subtensor' in s:
debug = 0
else:
debug = 0
r = []
leadspace = True
for c in s:
if leadspace and c in ' \n\t':
continue
else:
leadspace = False
if c == '\n':
if debug:
print >> sys.stderr, 'breaking'
break
if c == '\t':
c = ' ';
r.append(c)
if debug:
print >> sys.stderr, r
return "".join(r)
for module in [tensor]: for module in [tensor]:
title = 'Ops in module: `%s`' % module.__name__ title = 'Ops in module: `%s`' % module.__name__
print title print title
...@@ -21,8 +52,10 @@ for module in [tensor]: ...@@ -21,8 +52,10 @@ for module in [tensor]:
if not docstring: if not docstring:
print 'No documentation' print 'No documentation'
elif len(docstring) < 50: elif len(docstring) < 50:
print docstring print chomp(docstring)
else: else:
print docstring[:40], "..." print chomp(docstring[:40]), "..."
# a little trailing whitespace
print ""
print ""
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论