Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
abfcb126
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
5
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
abfcb126
编写于
4月 03, 2020
作者:
T
tianshuo78520a
提交者:
GitHub
4月 03, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make the gen_doc script support paddle api version 2.0 (#1944)
* change gen_doc * change gen_doc
上级
3abbcb00
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
19 deletion
+13
-19
doc/fluid/api/gen_doc.py
doc/fluid/api/gen_doc.py
+11
-7
doc/fluid/api/gen_doc.sh
doc/fluid/api/gen_doc.sh
+2
-12
未找到文件。
doc/fluid/api/gen_doc.py
浏览文件 @
abfcb126
...
@@ -19,6 +19,7 @@ import types
...
@@ -19,6 +19,7 @@ import types
import
os
import
os
import
contextlib
import
contextlib
import
paddle.fluid
as
fluid
import
paddle.fluid
as
fluid
import
paddle.tensor
as
tensor
def
parse_arg
():
def
parse_arg
():
parser
=
argparse
.
ArgumentParser
()
parser
=
argparse
.
ArgumentParser
()
...
@@ -29,8 +30,11 @@ def parse_arg():
...
@@ -29,8 +30,11 @@ def parse_arg():
'--module_prefix'
,
type
=
str
,
help
=
'Generate the prefix of module'
)
'--module_prefix'
,
type
=
str
,
help
=
'Generate the prefix of module'
)
parser
.
add_argument
(
parser
.
add_argument
(
'--output'
,
type
=
str
,
help
=
'Output file or output directory for output rst'
)
'--output'
,
type
=
str
,
help
=
'Output file or output directory for output rst'
)
parser
.
add_argument
(
'--output_name'
,
type
=
str
,
help
=
'Output file or output directory for output rst'
)
parser
.
add_argument
(
parser
.
add_argument
(
'--to_multiple_files'
,
type
=
bool
,
default
=
False
,
help
=
'Whether to separate to multiple files'
)
'--to_multiple_files'
,
type
=
bool
,
default
=
False
,
help
=
'Whether to separate to multiple files'
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
def
print_item
(
self
,
name
):
def
print_item
(
self
,
name
):
...
@@ -140,7 +144,7 @@ class DocGenerator(object):
...
@@ -140,7 +144,7 @@ class DocGenerator(object):
self
.
stream
.
write
(
".. _api_{0}_{1}:
\n\n
"
.
format
(
"_"
.
join
(
self
.
stream
.
write
(
".. _api_{0}_{1}:
\n\n
"
.
format
(
"_"
.
join
(
self
.
module_prefix
.
split
(
"."
)),
name
))
self
.
module_prefix
.
split
(
"."
)),
name
))
def
generate_doc
(
module_name
,
module_prefix
,
output
,
to_multiple_files
):
def
generate_doc
(
module_name
,
module_prefix
,
output
,
output_name
,
to_multiple_files
):
if
module_name
==
""
:
if
module_name
==
""
:
module_name
=
None
module_name
=
None
...
@@ -150,22 +154,22 @@ def generate_doc(module_name, module_prefix, output, to_multiple_files):
...
@@ -150,22 +154,22 @@ def generate_doc(module_name, module_prefix, output, to_multiple_files):
gen
=
DocGenerator
()
gen
=
DocGenerator
()
if
module_name
is
None
:
if
module_name
is
None
:
gen
.
module
=
fluid
gen
.
module
=
eval
(
output_name
)
gen
.
module_name
=
'fluid'
gen
.
module_name
=
str
(
output_name
)
else
:
else
:
gen
.
module
=
fluid
gen
.
module
=
eval
(
output_name
)
for
each_module_name
in
module_name
.
split
(
'.'
):
for
each_module_name
in
module_name
.
split
(
'.'
):
if
not
hasattr
(
gen
.
module
,
each_module_name
):
if
not
hasattr
(
gen
.
module
,
each_module_name
):
raise
ValueError
(
"Cannot find fluid.{0}"
.
format
(
module_name
))
raise
ValueError
(
"Cannot find fluid.{0}"
.
format
(
module_name
))
else
:
else
:
gen
.
module
=
getattr
(
gen
.
module
,
each_module_name
)
gen
.
module
=
getattr
(
gen
.
module
,
each_module_name
)
gen
.
module_name
=
"fluid
."
+
module_name
gen
.
module_name
=
output_name
+
"
."
+
module_name
if
module_prefix
is
None
:
if
module_prefix
is
None
:
gen
.
module_prefix
=
gen
.
module_name
gen
.
module_prefix
=
gen
.
module_name
else
:
else
:
gen
.
module_prefix
=
"fluid
."
+
module_prefix
gen
.
module_prefix
=
output_name
+
"
."
+
module_prefix
dirname
=
output
if
to_multiple_files
else
os
.
path
.
dirname
(
output
)
dirname
=
output
if
to_multiple_files
else
os
.
path
.
dirname
(
output
)
if
len
(
dirname
)
>
0
and
(
not
os
.
path
.
exists
(
dirname
)
or
not
os
.
path
.
isdir
(
dirname
)):
if
len
(
dirname
)
>
0
and
(
not
os
.
path
.
exists
(
dirname
)
or
not
os
.
path
.
isdir
(
dirname
)):
...
@@ -199,7 +203,7 @@ def generate_doc(module_name, module_prefix, output, to_multiple_files):
...
@@ -199,7 +203,7 @@ def generate_doc(module_name, module_prefix, output, to_multiple_files):
def
main
():
def
main
():
args
=
parse_arg
()
args
=
parse_arg
()
generate_doc
(
args
.
module_name
,
args
.
module_prefix
,
args
.
output
,
args
.
to_multiple_files
)
generate_doc
(
args
.
module_name
,
args
.
module_prefix
,
args
.
output
,
args
.
output_name
,
args
.
to_multiple_files
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
doc/fluid/api/gen_doc.sh
浏览文件 @
abfcb126
#!/bin/bash
#!/bin/bash
#for module in nn
#do
# python gen_doc.py --module_name layers.${module} --module_prefix layers --output layers/${module} --to_multiple_files True
#done
#for module in control_flow nn io ops tensor learning_rate_scheduler detection metric_op
#do
# python gen_doc.py --module_name layers.${module} --module_prefix layers --output layers/${module}.rst
#done
for
module
in
layers dataset clip metrics executor initializer io nets optimizer profiler regularizer transpiler backward profiler unique_name dygraph
for
module
in
layers dataset clip metrics executor initializer io nets optimizer profiler regularizer transpiler backward profiler unique_name dygraph
do
do
python gen_doc.py
--module_name
${
module
}
--module_prefix
${
module
}
--output
${
module
}
--to_multiple_files
True
python gen_doc.py
--module_name
${
module
}
--module_prefix
${
module
}
--output
${
module
}
--
output_name
fluid
--
to_multiple_files
True
python gen_module_index.py
${
module
}
fluid.
${
module
}
python gen_module_index.py
${
module
}
fluid.
${
module
}
done
done
python gen_doc.py
--module_name
""
--module_prefix
""
--output
fluid
--to_multiple_files
True
python gen_doc.py
--module_name
""
--module_prefix
""
--output
fluid
--
output_name
fluid
--
to_multiple_files
True
python gen_module_index.py fluid fluid
python gen_module_index.py fluid fluid
python gen_index.py
python gen_index.py
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录