$ cd /to/dir/EasyNLP
$ python setup.py install
$ pip install sphinx
$ pip install sphinx_rtd_themeYou need to add class or functions with docstring into the attached file.
- Google Python Style Guide link
- Google docstring Sample link
- Sample project:torch.nn.modules.conv link
- Take
easynlp.appzoo.classification.BertTextClassifyas example:
class BertTextClassify(BertPreTrainedModel):
"""
Transformer model from ```Attention Is All You Need''',
Original paper: https://arxiv.org/abs/1706.03762
Args:
num_token (int): vocab size.
num_layer (int): num of layer.
num_head (int): num of attention heads.
embedding_dim (int): embedding dimension.
attention_head_dim (int): attention head dimension.
feed_forward_dim (int): feed forward dimension.
initializer: initializer type.
activation: activation function.
dropout (float): dropout rate (0.0 to 1.0).
attention_dropout (float): dropout rate for attention layer.
Returns: None
"""For example, if you need to add a new file in easynlp/data and the file name is blackmagic.py with a BlackMagic class:
- Add
docstringto the code - In
docs/source/api/data.rst,Find a position forblackmagicand add
blackmagic
--------------------------------------
.. automodule:: easynlp.data.blackmagic
:members:
:undoc-members:
:show-inheritance:
For example, you want to add a magic directory in ez_transfer,and there is a file named blackmagic.py with a BlackMagic class:
- Add
docstringto the code - Add file
docs/source/api/magic.rstand write the following line
ez\_transfer.magic
===========================- In
docs/source/api/magic.rst,Find a position forblackmagicand add
blackmagic
--------------------------------------
.. automodule:: ez_transfer.layers.blackmagic
:members:
:undoc-members:
:show-inheritance:
$ cd docs/
$ sh build_docs.sh