Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
abf84e4e
提交
abf84e4e
authored
10月 08, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc works fine
上级
129bf3cb
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
149 行增加
和
71 行删除
+149
-71
gen_typelist.py
__transit/scripts/gen_typelist.py
+0
-31
conf.py
doc/conf.py
+1
-1
ext.py
doc/ext.py
+51
-6
docgen.py
scripts/docgen.py
+11
-1
gen_oplist.py
scripts/gen_oplist.py
+46
-31
gen_typelist.py
scripts/gen_typelist.py
+39
-0
basic.py
theano/tensor/basic.py
+1
-1
没有找到文件。
__transit/scripts/gen_typelist.py
deleted
100644 → 0
浏览文件 @
129bf3cb
from
gen_oplist
import
print_title
,
print_hline
if
__name__
==
'__main__'
:
print_title
(
"Type List"
,
"~"
,
"~"
)
print
"*THIS PAGE IS A PLACEHOLDER: WRITEME*"
print
""
print_hline
()
print
""
print
".. contents::"
print
""
print_title
(
"Type Classes"
,
'='
)
print
"- scalar.Scalar
\n
"
print
"- tensor.Tensor
\n
"
print
"- sparse.Sparse
\n
"
print_title
(
"Type Instances"
,
'='
)
print
"- scalar.int8
\n
"
print
"- tensor.lvector
\n
"
print
"- sparse.??
\n
"
print
""
for
line
in
open
(
"doc/header.txt"
):
print
line
[:
-
1
]
doc/conf.py
浏览文件 @
abf84e4e
...
@@ -36,7 +36,7 @@ master_doc = 'index'
...
@@ -36,7 +36,7 @@ master_doc = 'index'
# General substitutions.
# General substitutions.
project
=
'theano'
project
=
'theano'
copyright
=
'2008,
Olivier Breuleux, James Bergstra
'
copyright
=
'2008,
LISA lab
'
# The default replacements for |version| and |release|, also used in various
# The default replacements for |version| and |release|, also used in various
# other places throughout the built documents.
# other places throughout the built documents.
...
...
doc/ext.py
浏览文件 @
abf84e4e
import
re
import
os
import
os
from
docutils
import
nodes
from
docutils
import
nodes
,
utils
from
docutils.parsers.rst
import
roles
import
epydoc.docwriter.xlink
as
xlink
import
epydoc.docwriter.xlink
as
xlink
def
role_fn
(
name
,
rawtext
,
text
,
lineno
,
inliner
,
def
role_fn
(
name
,
rawtext
,
text
,
lineno
,
inliner
,
...
@@ -9,14 +11,57 @@ def role_fn(name, rawtext, text, lineno, inliner,
...
@@ -9,14 +11,57 @@ def role_fn(name, rawtext, text, lineno, inliner,
return
[
node
],
[]
return
[
node
],
[]
_TARGET_RE
=
re
.
compile
(
r'^(.*?)\s*<(?:URI:|URL:)?([^<>]+)>$'
)
def
create_api_role
(
name
,
problematic
):
"""
Create and register a new role to create links for an API documentation.
Create a role called `name`, which will use the URL resolver registered as
``name`` in `api_register` to create a link for an object.
:Parameters:
`name` : `str`
name of the role to create.
`problematic` : `bool`
if True, the registered role will create problematic nodes in
case of failed references. If False, a warning will be raised
anyway, but the output will appear as an ordinary literal.
"""
def
resolve_api_name
(
n
,
rawtext
,
text
,
lineno
,
inliner
,
options
=
{},
content
=
[]):
# Check if there's separate text & targets
m
=
_TARGET_RE
.
match
(
text
)
if
m
:
text
,
target
=
m
.
groups
()
else
:
target
=
text
# node in monotype font
text
=
utils
.
unescape
(
text
)
node
=
nodes
.
literal
(
rawtext
,
text
,
**
options
)
# Get the resolver from the register and create an url from it.
try
:
url
=
xlink
.
api_register
[
name
]
.
get_url
(
target
)
except
IndexError
,
exc
:
msg
=
inliner
.
reporter
.
warning
(
str
(
exc
),
line
=
lineno
)
if
problematic
:
prb
=
inliner
.
problematic
(
rawtext
,
text
,
msg
)
return
[
prb
],
[
msg
]
else
:
return
[
node
],
[]
if
url
is
not
None
:
node
=
nodes
.
reference
(
rawtext
,
''
,
node
,
refuri
=
url
,
**
options
)
return
[
node
],
[]
roles
.
register_local_role
(
name
,
resolve_api_name
)
def
setup
(
app
):
def
setup
(
app
):
help
(
xlink
)
#role = xlink.create_api_role('api', True)
#print role
xlink
.
register_api
(
'api'
,
xlink
.
DocUrlGenerator
())
xlink
.
set_api_file
(
'api'
,
os
.
path
.
join
(
app
.
outdir
,
'api'
,
'api-objects.txt'
))
xlink
.
set_api_file
(
'api'
,
os
.
path
.
join
(
app
.
outdir
,
'api'
,
'api-objects.txt'
))
xlink
.
set_api_root
(
'api'
,
os
.
path
.
join
(
app
.
outdir
,
'api'
,
''
))
xlink
.
set_api_root
(
'api'
,
os
.
path
.
join
(
app
.
outdir
,
'api'
,
''
))
xlink
.
create_api_role
(
'api'
,
True
)
#xlink.create_api_role('api', True)
create_api_role
(
'api'
,
True
)
app
.
add_role
(
"wiki"
,
role_fn
)
app
.
add_role
(
"wiki"
,
role_fn
)
scripts/docgen.py
浏览文件 @
abf84e4e
...
@@ -59,6 +59,16 @@ if __name__ == '__main__':
...
@@ -59,6 +59,16 @@ if __name__ == '__main__':
throot
=
"/"
.
join
(
sys
.
path
[
0
]
.
split
(
"/"
)[:
-
1
])
throot
=
"/"
.
join
(
sys
.
path
[
0
]
.
split
(
"/"
)[:
-
1
])
import
gen_oplist
print
'Generating oplist...'
gen_oplist
.
print_file
(
open
(
'
%
s/doc/doc/oplist.txt'
%
throot
,
'w'
))
print
'oplist done!'
import
gen_typelist
print
'Generating typelist...'
gen_typelist
.
print_file
(
open
(
'
%
s/doc/doc/typelist.txt'
%
throot
,
'w'
))
print
'typelist done!'
os
.
chdir
(
throot
)
os
.
chdir
(
throot
)
def
mkdir
(
path
):
def
mkdir
(
path
):
...
@@ -81,6 +91,6 @@ if __name__ == '__main__':
...
@@ -81,6 +91,6 @@ if __name__ == '__main__':
if
len
(
sys
.
argv
)
==
1
or
sys
.
argv
[
1
]
!=
'epydoc'
:
if
len
(
sys
.
argv
)
==
1
or
sys
.
argv
[
1
]
!=
'epydoc'
:
import
sphinx
import
sphinx
sys
.
path
[
0
:
0
]
=
[
os
.
path
.
realpath
(
'doc'
)]
sys
.
path
[
0
:
0
]
=
[
os
.
path
.
realpath
(
'doc'
)]
sphinx
.
main
([
''
,
'doc'
,
'html'
])
sphinx
.
main
([
''
,
'
-E'
,
'
doc'
,
'html'
])
__transit/
scripts/gen_oplist.py
→
scripts/gen_oplist.py
浏览文件 @
abf84e4e
"""script to generate doc/oplist.txt, which compiles to :doc:`oplist`. """
"""script to generate doc/oplist.txt, which compiles to :doc:`oplist`. """
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
sys
import
sys
,
os
theano_path
=
os
.
path
.
realpath
(
"
%
s/.."
%
sys
.
path
[
0
])
sys
.
path
[
0
:
0
]
=
[
theano_path
]
from
theano
import
gof
from
theano
import
gof
def
print_title
(
title_string
,
under_char
,
over_char
=
''
):
def
print_title
(
file
,
title_string
,
under_char
,
over_char
=
''
):
l
=
len
(
title_string
)
l
=
len
(
title_string
)
if
over_char
:
if
over_char
:
print
over_char
*
l
print
>>
file
,
over_char
*
l
print
title_string
print
>>
file
,
title_string
if
under_char
:
if
under_char
:
print
under_char
*
l
print
>>
file
,
under_char
*
l
print
""
print
>>
file
,
""
def
print_hline
():
def
print_hline
(
file
):
print
'-'
*
80
print
>>
file
,
'-'
*
80
class
Entry
:
class
Entry
:
"""Structure for generating the oplist file"""
"""Structure for generating the oplist file"""
...
@@ -31,7 +34,7 @@ class Entry:
...
@@ -31,7 +34,7 @@ class Entry:
self
.
name
=
name
self
.
name
=
name
self
.
module
=
symbol
.
__module__
#current_module.__name__ # symbol.__module__
self
.
module
=
symbol
.
__module__
#current_module.__name__ # symbol.__module__
self
.
docstring
=
symbol
.
__doc__
self
.
docstring
=
symbol
.
__doc__
self
.
tags
=
[
'
module:
%
s'
%
current_module
.
__name__
]
+
getattr
(
symbol
,
'__oplist_tags'
,
[])
self
.
tags
=
[
'
%
s'
%
current_module
.
__name__
]
+
getattr
(
symbol
,
'__oplist_tags'
,
[])
def
mini_desc
(
self
,
maxlen
=
50
):
def
mini_desc
(
self
,
maxlen
=
50
):
"""Return a short description of the op"""
"""Return a short description of the op"""
...
@@ -73,7 +76,7 @@ class Entry:
...
@@ -73,7 +76,7 @@ class Entry:
else
:
else
:
return
"
%
s ..."
%
chomp
(
self
.
docstring
[:
maxlen
-
minmax
])
return
"
%
s ..."
%
chomp
(
self
.
docstring
[:
maxlen
-
minmax
])
apilink
=
property
(
lambda
self
:
":api:`
%
s
.
%
s`"
%
(
self
.
module
,
self
.
name
))
apilink
=
property
(
lambda
self
:
":api:`
%
s
<
%
s.
%
s>`"
%
(
self
.
name
,
self
.
module
,
self
.
name
))
"""Return the ReST link into the epydoc of this symbol"""
"""Return the ReST link into the epydoc of this symbol"""
class
EntryOp
(
Entry
):
class
EntryOp
(
Entry
):
...
@@ -126,51 +129,63 @@ def search_entries(module_list, ops = None, constructors = None, seen = None):
...
@@ -126,51 +129,63 @@ def search_entries(module_list, ops = None, constructors = None, seen = None):
return
ops
,
constructors
return
ops
,
constructors
def
print_entries
(
ops
,
constructors
):
def
print_entries
(
file
,
ops
,
constructors
):
tags
=
{}
tags
=
{}
for
o
in
ops
+
constructors
:
for
o
in
ops
+
constructors
:
for
t
in
o
.
tags
:
for
t
in
o
.
tags
:
tags
.
setdefault
(
t
,
[])
.
append
(
o
)
tags
.
setdefault
(
t
,
[])
.
append
(
o
)
for
t
in
tags
:
for
t
in
tags
:
print_title
(
t
,
'='
)
print_title
(
file
,
t
,
'='
)
tagged_ops
=
[
op
for
op
in
tags
[
t
]
if
isinstance
(
op
,
EntryOp
)]
tagged_ops
=
[
op
for
op
in
tags
[
t
]
if
isinstance
(
op
,
EntryOp
)]
if
len
(
tagged_ops
):
if
len
(
tagged_ops
):
print_title
(
'Op Classes'
,
'-'
)
print_title
(
file
,
'Op Classes'
,
'-'
)
for
op
in
tagged_ops
:
for
op
in
tagged_ops
:
print
"-
%
s"
%
op
.
apilink
print
>>
file
,
"-
%
s"
%
op
.
apilink
print
"
%
s"
%
op
.
mini_desc
()
print
>>
file
,
"
%
s"
%
op
.
mini_desc
()
print
""
print
>>
file
,
""
tagged_ops
=
[
op
for
op
in
tags
[
t
]
if
isinstance
(
op
,
EntryConstructor
)]
tagged_ops
=
[
op
for
op
in
tags
[
t
]
if
isinstance
(
op
,
EntryConstructor
)]
if
len
(
tagged_ops
):
if
len
(
tagged_ops
):
print_title
(
'Op Constructors'
,
'-'
)
print_title
(
file
,
'Op Constructors'
,
'-'
)
for
op
in
tagged_ops
:
for
op
in
tagged_ops
:
print
"-
%
s"
%
op
.
apilink
print
>>
file
,
"-
%
s"
%
op
.
apilink
print
"
%
s"
%
op
.
mini_desc
()
print
>>
file
,
"
%
s"
%
op
.
mini_desc
()
print
""
print
>>
file
,
""
if
__name__
==
"__main__"
:
def
print_file
(
file
):
"""Generate the op list"""
import
theano
print_title
(
"Op List"
,
"~"
,
"~"
)
print_title
(
file
,
"Op List"
,
"~"
,
"~"
)
print
"""
print
>>
file
,
"""
This page lists the `Op Classes` and `constructors` that are provided by the Theano library.
This page lists the `Op Classes` and `constructors` that are provided by the Theano library.
`Op Classes` drive from :api:`Op`, whereas `constructors` are typically `Op Class` instances, but may be true Python functions.
`Op Classes` drive from :api:`Op`, whereas `constructors` are typically `Op Class` instances, but may be true Python functions.
In the future, this list may distinguish `constructors` that are Op instances from true Python functions.
In the future, this list may distinguish `constructors` that are Op instances from true Python functions.
"""
"""
print_hline
()
print_hline
(
file
)
print
""
print
>>
file
,
""
print
".. contents:: "
print
>>
file
,
".. contents:: "
print
""
print
>>
file
,
""
ops
,
constructors
=
search_entries
([
theano
])
ops
,
constructors
=
search_entries
([
theano
])
print_entries
(
ops
,
constructors
)
print_entries
(
file
,
ops
,
constructors
)
print
>>
file
,
""
import
theano
if
__name__
==
"__main__"
:
"""Generate the op list"""
if
len
(
sys
.
argv
)
>=
2
:
file
=
open
(
sys
.
argv
[
1
],
'w'
)
else
:
file
=
sys
.
stdout
print_file
(
file
)
print
""
scripts/gen_typelist.py
0 → 100644
浏览文件 @
abf84e4e
from
gen_oplist
import
print_title
,
print_hline
def
print_file
(
file
):
print_title
(
file
,
"Type List"
,
"~"
,
"~"
)
print
>>
file
,
"*THIS PAGE IS A PLACEHOLDER: WRITEME*"
print
>>
file
,
""
print_hline
(
file
)
print
>>
file
,
""
print
>>
file
,
".. contents::"
print
>>
file
,
""
print_title
(
file
,
"Type Classes"
,
'='
)
print
>>
file
,
"- scalar.Scalar
\n
"
print
>>
file
,
"- tensor.Tensor
\n
"
print
>>
file
,
"- sparse.Sparse
\n
"
print_title
(
file
,
"Type Instances"
,
'='
)
print
>>
file
,
"- scalar.int8
\n
"
print
>>
file
,
"- tensor.lvector
\n
"
print
>>
file
,
"- sparse.??
\n
"
print
>>
file
,
""
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
>=
2
:
file
=
open
(
sys
.
argv
[
1
],
'w'
)
else
:
file
=
sys
.
stdout
print_file
(
file
)
theano/tensor/basic.py
浏览文件 @
abf84e4e
...
@@ -567,7 +567,7 @@ def _redefine(real_symbol_value, module='tensor'):
...
@@ -567,7 +567,7 @@ def _redefine(real_symbol_value, module='tensor'):
This is useful to trick epydoc into doing what we want. It's a hack.
This is useful to trick epydoc into doing what we want. It's a hack.
"""
"""
real_symbol_value
.
__module__
=
'tensor'
real_symbol_value
.
__module__
=
'tensor
.basic
'
def
decorator
(
f
):
def
decorator
(
f
):
return
real_symbol_value
return
real_symbol_value
return
decorator
return
decorator
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论