Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add api doc std #8927

Merged
merged 3 commits into from
Mar 14, 2018
Merged

Add api doc std #8927

merged 3 commits into from
Mar 14, 2018

Conversation

ranqiu92
Copy link
Contributor

@ranqiu92 ranqiu92 commented Mar 9, 2018

fix #8866
fix #8834

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 整体标准定义的很不错,文档描述上还需进一步完善。
  2. 需要强调api注释是使用rst格式来写,参考链接:http://sphinx-doc-zh.readthedocs.io/en/latest/rest.html


API文档各模块格式及示例如下:

### Python API Definition & Python Wrapper Location
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 49行是12行+16行,如果前面分开列了,这儿也要分开列。两者需要统一。
  • 前面使用-,这儿使用###,需要统一使用-。51行和57行的-进行缩进。改成rst文件后,这儿的格式也需要略作调整。


- 示例

#### [fluid.layers.fc](https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/fluid/layers/nn.py)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..  literalinclude:: ../../../../paddle/gserver/tests/sequenceGen.py
    :language: python
    :lines: 42-71
    :linenos:

来一一说明每行对应哪个格式。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是否要考虑 行数 发生变化的情况?感觉随着api的丰富,对应的行可能会发生变化

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于一个专门的示例py文件来说,它是不会随着api的丰富而发生变化的。

name=None,
main_program=None,
startup_program=None)
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

61-69行是说明什么呢?可以在47行加上:以fc为例来进行说明?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Python API Definition]


- 格式:

[Python API Name][Python Wrapper URL]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python Wrapper URL的示例是在哪儿?需要对每个[]内容都有示例。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line59

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Python Wrapper URL的示例 能否做成自动生成,如果做不到的话,就不要列了。后期维护会很麻烦。


[Formula]

[Symbols' Descriptions if necessary]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要对每个[]的示例进行说明,我理解85行是Function Description,86行是Formula,87行是Symbols' Descriptions,需要再强调说一下


- 示例

以dynamic_lstm为例
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全文的示例能否统一,上文是fc,这儿是dynamic_lstm,能否统一?

Copy link
Contributor Author

@ranqiu92 ranqiu92 Mar 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原本是想演示下 当返回值为多个的情况怎么写

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以进行演示,选一个好点的api示例即可。

- 示例

```
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请加示例


```python
data = fluid.layers.data(name='data', shape=[1], dtype='float32')
fc = fluid.layers.fc(input=data, size=10, act="tanh")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fc的注释不只你列出来的,可以使用rst文档的literalinclude来完整引入(上面评论中有写)。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没太明白这句话,这里fc的注释还缺什么?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://www.paddlepaddle.org/docs/develop/api/en/fluid/layers.html#fc 看注释内容非常多,你列出来的每一项都不全。

@@ -0,0 +1,203 @@
# API文档撰写
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API注释撰写标准

@@ -0,0 +1,203 @@
# API文档撰写

- [API文档模块](#API文档模块)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API注释模块

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请对应更新src/fc.py的注释和nn.py里面fc的注释。


## 完整示例

fc 的完整注释见[示例](https://github.com/PaddlePaddle/Paddle/tree/develop/doc/fluid/dev/src/fc.py)。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

链接使用相对路径,现在的路径访问不了。
[示例](src/fc.py)


- 示例

fc没有注意事项,故该模块省略不写。其他情况应明确给出,若有多条注意事项,须分条列出,以scaled\_dot\_product\_attention为例:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

其他情况指哪些情况?改成:如有注意事情应明确给出?


```
Args:
input (Tensor): The input tensor(s) of the layer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

input这个注释需要修改

  • 原来也有list类型给漏掉了。(Variable|list) – The input tensor(s) to the fully connected layer.
  • 这个tensor是几维的。
  • input和output都是Variable,variable里面是XX维的tensor


## 格式及示例

API文档各模块格式及示例如下(以下以fc为例进行说明):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

43行的括号需要改完中文括号。

- [完整示例](#完整示例)


## API注释模块
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要强调api注释文档是使用rst格式来写,有关rst格式的参考链接:http://sphinx-doc-zh.readthedocs.io/en/latest/rest.html
请组织语言。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -40,7 +40,7 @@ API文档须包含以下几个模块(排列顺序为文档撰写顺序):

## 格式及示例

API文档各模块格式及示例如下(以下以fc为例进行说明):
API文档须使用rst格式撰写,该格式详情请参考[链接](http://sphinx-doc-zh.readthedocs.io/en/latest/rest.html)。API文档各模块的内容格式及示例如下(以下以fc为例进行说明):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rst->reStructuredText

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -137,7 +137,7 @@ API文档各模块格式及示例如下(以下以fc为例进行说明):

```
Args:
input (Tensor): The input tensor(s) of the layer.
input (Variable|list of Variable): This layer's input tensor(s) which is at least 2-dimensional.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input tensor(s) of the layer, and the dimension of the input tensor(s) is at least 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks very much!

@luotao1 luotao1 merged commit ad6b59e into PaddlePaddle:develop Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discuss how to write API document 主流DL框架文档格式调研
2 participants