Please follow these guidelines for contributing. Pull requests are welcome.
- Create a new github issue for bugs or features. Search the ticket system first, to avoid filing a duplicate.
- Ensure code follows the syntax and conventions.
- Code must pass tests. See Testing for information on how to run and write unit tests.
- Commit messages should be informative.
- Fork us on github.
- Clone your repository.
- Create a feature branch for your issue.
- Apply your changes:
- Add them, and then commit them to your branch.
- Run the tests until they pass.
- When you feel you are finished, rebase your commits to ensure a simple and informative commit log.
- Create a pull request on github from your forked repository.
Use Black for formatting Python code.
Simply run black <filename>
from the command line.
Please use the Python domain info field lists for all docstrings. This way documentation can be auto-generated from docstrings.
example:
def func(foo, bar):
"""Function purpose.
:param int foo: description and type of the foo argument
:param bar: description of the bar argument
:type bar: int
:return: return description
:rtype: int
"""
return foo * bar
The tests are located tests
folder. Tests should be included for any new contributions.
All the tests for pyads can be run using tox.
Simply use pip install tox
and run tox
from the root directory. See tox.ini
for available environments.
Tests are written using unittest and can be individually run for each environment with the python built in library.
When creating a pull request (PR) on Github, Travis will automatically run the unit tests with the code in the PR and report back.
There are known issues when running tests using a Windows development environment with TwinCat installed; TwinCat can cause issues with the ADS Test Server. If running tests using tox causes problems, tests can be run using Docker instead.
To run the tests on Windows with TwinCAT installed, make sure TwinCAT is not running.
Either stop all services and process manually, or run
C:\TwinCAT\TcSwitchRuntime\TcSwitchRuntime.exe
and click 'disable'.
With Docker installed docker images can be built and run for any python version. The following commands will build an image using python3.8, then tests will run when the container starts:
docker build --build-arg python_version=3.8 -t container_name .
docker run --rm container_name
The container is deleted automatically after running so that multiple containers don't build up on the system. To rerun the tests after making changes to pyads, any docker images will need to be rebuilt.
Instead of using Docker, the Linux Subsystem for Windows also allows you to run the tests. See for example: https://docs.microsoft.com/en-us/windows/wsl/install-win10
With the subsystem installed, open a Linux shell in your clone directory and run:
sudo apt install python3 python3-pip
cd adslib && make && sudo make install && cd ..
python3 -m pip install tox
python3 -m tox -e py36
(Ubuntu 18.04 comes with Python 3.6, 20.04 with Python 3.8)
Sphinx is used to create the documentation from source files and docstrings in code. You can build your documentation changes for testing using:
pip install -r requirements.txt
cd doc
make html
The resulting html files are in doc/build/html
.
Documentation is found on read the docs and will automatically update when PRs are merged.