提交 a6e974f7 authored 作者: projects@lgcm's avatar projects@lgcm

gen oplist no longer runs on import

上级 ba5d6da9
...@@ -45,52 +45,56 @@ def chomp(s): ...@@ -45,52 +45,56 @@ def chomp(s):
return "".join(r) return "".join(r)
import scalar, sparse, tensor def generate():
"""Generate the op list"""
import scalar, sparse, tensor
print_title("Theano Op List", "~") print_title("Theano Op List", "~")
print "" print ""
print ".. contents:: " print ".. contents:: "
print "" print ""
for module in [scalar, sparse, tensor]: for module in [scalar, sparse, tensor]:
print_title('module: `%s`' % module.__name__, '=') print_title('module: `%s`' % module.__name__, '=')
print_title('Op Classes', '-') print_title('Op Classes', '-')
for symbol_name in dir(module): for symbol_name in dir(module):
symbol = getattr(module, symbol_name) symbol = getattr(module, symbol_name)
if isOpClass(symbol): if isOpClass(symbol):
print "" print ""
print "- :api:`%s.%s`" % (symbol.__module__, symbol_name) print "- :api:`%s.%s`" % (symbol.__module__, symbol_name)
docstring = getattr(symbol, '__doc__', "") docstring = getattr(symbol, '__doc__', "")
if not docstring: if not docstring:
print " ", '(no doc)' print " ", '(no doc)'
elif len(docstring) < 50: elif len(docstring) < 50:
print " ", chomp(docstring) print " ", chomp(docstring)
else: else:
print " ", chomp(docstring[:40]), "..." print " ", chomp(docstring[:40]), "..."
# a little trailing whitespace # a little trailing whitespace
print "" print ""
print_title('Op Constructors', '-') print_title('Op Constructors', '-')
for symbol_name in dir(module): for symbol_name in dir(module):
symbol = getattr(module, symbol_name) symbol = getattr(module, symbol_name)
if isOpConstructor(symbol, module): if isOpConstructor(symbol, module):
print "" print ""
print "- :api:`%s.%s`" % (symbol.__module__, symbol_name) print "- :api:`%s.%s`" % (symbol.__module__, symbol_name)
docstring = getattr(symbol, '__doc__', "") docstring = getattr(symbol, '__doc__', "")
if not docstring: if not docstring:
print " ", 'No documentation' print " ", 'No documentation'
elif len(docstring) < 50: elif len(docstring) < 50:
print " ", chomp(docstring) print " ", chomp(docstring)
else: else:
print " ", chomp(docstring[:40]), "..." print " ", chomp(docstring[:40]), "..."
# a little trailing whitespace # a little trailing whitespace
print "" print ""
if __name__ == "__main__":
generate()
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论