Tianshou/docs/contributing.rst

127 lines
2.8 KiB
ReStructuredText
Raw Normal View History

2020-06-01 09:37:30 +08:00
Contributing to Tianshou
========================
2020-03-29 10:22:03 +08:00
2020-04-11 19:29:46 +08:00
Install Develop Version
2020-06-02 08:51:14 +08:00
-----------------------
2020-03-29 10:22:03 +08:00
2020-04-11 19:29:46 +08:00
To install Tianshou in an "editable" mode, run
.. code-block:: bash
$ pip install -e ".[dev]"
2020-04-11 19:29:46 +08:00
in the main directory. This installation is removable by
.. code-block:: bash
$ python setup.py develop --uninstall
2020-04-11 19:29:46 +08:00
PEP8 Code Style Check and Code Formatter
----------------------------------------
2020-04-11 19:29:46 +08:00
Please set up pre-commit by running
.. code-block:: bash
$ pre-commit install
in the main directory. This should make sure that your contribution is properly
formatted before every commit.
We follow PEP8 python code style with flake8. To check, in the main directory, run:
2020-04-11 19:29:46 +08:00
.. code-block:: bash
$ make lint
We use isort and yapf to format all codes. To format, in the main directory, run:
.. code-block:: bash
$ make format
To check if formatted correctly, in the main directory, run:
.. code-block:: bash
$ make check-codestyle
2020-04-11 19:29:46 +08:00
Type Check
----------
We use `mypy <https://github.com/python/mypy/>`_ to check the type annotations. To check, in the main directory, run:
.. code-block:: bash
$ make mypy
2020-04-11 19:29:46 +08:00
Test Locally
2020-06-02 08:51:14 +08:00
------------
2020-04-11 19:29:46 +08:00
This command will run automatic tests in the main directory
.. code-block:: bash
$ make pytest
2020-04-11 19:29:46 +08:00
2020-04-11 19:29:46 +08:00
Test by GitHub Actions
2020-06-02 08:51:14 +08:00
----------------------
2020-04-11 19:29:46 +08:00
2020-04-13 19:37:27 +08:00
1. Click the ``Actions`` button in your own repo:
2020-04-11 19:29:46 +08:00
.. image:: _static/images/action1.jpg
:align: center
2. Click the green button:
.. image:: _static/images/action2.jpg
:align: center
3. You will see ``Actions Enabled.`` on the top of html page.
4. When you push a new commit to your own repo (e.g. ``git push``), it will automatically run the test in this page:
.. image:: _static/images/action3.png
:align: center
2020-04-11 19:29:46 +08:00
Documentation
2020-06-02 08:51:14 +08:00
-------------
2020-04-11 19:29:46 +08:00
Documentations are written under the ``docs/`` directory as ReStructuredText (``.rst``) files. ``index.rst`` is the main page. A Tutorial on ReStructuredText can be found `here <https://pythonhosted.org/an_example_pypi_project/sphinx.html>`_.
API References are automatically generated by `Sphinx <http://www.sphinx-doc.org/en/stable/>`_ according to the outlines under ``docs/api/`` and should be modified when any code changes.
To compile documentation into webpage, run
2020-04-11 19:29:46 +08:00
.. code-block:: bash
$ make doc
2020-04-11 19:29:46 +08:00
The generated webpage is in ``docs/_build`` and can be viewed with browser (http://0.0.0.0:8000/).
2020-06-01 08:30:09 +08:00
Chinese documentation is in https://tianshou.readthedocs.io/zh/latest/.
Documentation Generation Test
-----------------------------
We have the following three documentation tests:
1. pydocstyle: test all docstring under ``tianshou/``;
2. doc8: test ReStructuredText format;
3. sphinx test: test if there is any error/warning when generating front-end html documentation.
To check, in the main directory, run:
.. code-block:: bash
$ make check-docstyle