Contribution guide

Contributions of any size are highly welcomed and highly appreciated! You can make a high impact on ProPlot just by using it and reporting issues.

The following sections cover some general guidelines regarding development in ProPlot for maintainers and contributors. Feel free to suggest improvements or changes in the workflow.

Feature requests and feedback

We are eager to hear your requests for new features, suggestions regarding the current API, and so on. You can submit these as issues on Github. Please make sure to explain in detail how the feature should work and keep the scope as narrow as possible. This will make it easier to implement in small pull requests.

If you are feeling inspired, feel free to add the feature yourself and submit a pull request!

Report bugs

Bugs should be reported on the Github issues page. When reporting a bug, please follow the template message and include copy-pasteable code that reproduces the issue. This is critical for developers to fix the bug quickly.

If you can figure out how to fix the bug yourself, feel free to submit a pull request.

Write tests

Most modern python packages have test_*.py scripts that are run by pytest via the Travis Continuous Integration service whenever commits are pushed to the repository. Currently, ProPlot only tests the examples that appear on the website User Guide (see travis.yml). While we try to make the examples comprehensive, this approach leaves out a lot of use cases and leaves the project more vulnerable to bugs. Adding tests is a critical item on our to-do list.

If you can think of a useful test for ProPlot, feel free to submit a pull request. Your test will be used in the future.

Write documentation

Documentation can always be improved. For minor changes, you can edit docstrings and documentation files directly in the GitHub web interface without using a local copy.

  • The docstrings are written in reStructuredText with numpydoc style headers. They are embedded in the API reference section using a fork of sphinx-automodapi.

  • Other sections are written using .rst and files and .py files (translated to python notebooks via jupytext) in the docs folder. The notebooks are embedded in the User Guide using nbsphinx.

  • The default ReST role is py:obj. Please include py:obj links whenever discussing particular functions or classes – for example, if you are discussing the format method, please write `~proplot.axes.Axes.format` rather than format. ProPlot also uses intersphinx so you can link to external packages like matplotlib and cartopy.

To build the documentation locally, use the following commands:

  1. cd docs
  2. # Install dependencies to the base conda environment..
  3. conda env update -f environment.yml
  4. # ...or create a new conda environment
  5. # conda env create -n proplot-dev --file docs/environment.yml
  6. # source activate proplot-dev
  7. # Create HTML documentation
  8. make html

The built documentation should be available in docs/_build/html.

Preparing pull requests

Here is a quick guide for submitting pull requests:

  1. Fork the proplot GitHub repository. It’s fine to keep “proplot” as the fork repository name because it will live under your account.

  2. Clone your fork locally using git, connect your repository to the upstream (main project), and create a branch as follows:

    1. git clone git@github.com:YOUR_GITHUB_USERNAME/proplot.git
    2. cd proplot
    3. git remote add upstream git@github.com:lukelbd/proplot.git
    4. git checkout -b your-branch-name master

    If you need some help with git, follow the quick start guide.

  3. Make an editable install of ProPlot by running:

    1. pip install -e .

    This way import proplot imports your local copy, rather than the stable version you last downloaded from PyPi. You can import proplot; print(proplot.__file__) to verify your local copy has been imported.

  4. Install pre-commit and its hook on the proplot repo as follows:

    1. pip install --user pre-commit
    2. pre-commit install

    Afterwards pre-commit will run whenever you commit. pre-commit is a framework for managing and maintaining multi-language pre-commit hooks to ensure code-style and code formatting is consistent.

  5. You can now edit your local working copy as necessary. Please follow the PEP8 style guide. and try to generally adhere to the black subset of the PEP8 style (we may automatically enforce the “black” style in the future). When committing, pre-commit will modify the files as needed, or will generally be clear about what you need to do to pass the pre-commit test.

    Please break your edits up into reasonably sized commits:

    1. git commit -a -m "<commit message>"
    2. git push -u

    The commit messages should be short, sweet, and use the imperative mood, e.g. “Fix bug” instead of “Fixed bug”.

  6. If you intend to make changes or add examples to the user guide, you may want to open the docs/*.py files as jupyter notebooks. This can be done by installing jupytext, starting a jupyter session, and clicking on the .py files in the Files page.

  7. When you’re finished, create a new changelog entry in CHANGELOG.rst. The entry should be entered as:

    1. <description> (:pr:`<PR number>`) `<author name>`_

    where <description> is the description of the PR related to the change, <PR number> is the pull request number, and <author name> is your first and last name. Add yourself to list of authors at the end of CHANGELOG.rst if not there, in alphabetical order.

    Make sure to add the changelog entry under one of the valid .. rubric:: <heading> headings listed at the top of CHANGELOG.rst.

  8. Finally, submit a pull request through the GitHub website using this data:

    1. head-fork: YOUR_GITHUB_USERNAME/proplot
    2. compare: your-branch-name
    3. base-fork: lukelbd/proplot
    4. base: master

Note that you can create the pull request before you’re finished with your feature addition or bug fix. The PR will update as you add more commits. ProPlot developers and contributors can then review your code and offer suggestions.

Release procedure

Once version 1.0 is released, ProPlot will follow semantic versioning, with version numbers that look like vX.Y.Z. A major version (X) causes incompatible API changes, a minor version (Y) adds functionality, and a patch (Z) covers bug fixes. But these are not strict rules – more like guidelines. Currently, ProPlot’s major version number is 0, reflecting the fact that the API is new and subject to rapid changes (although we try to make sure the changes are not without warning).

For now, Luke Davis is the only one who can publish releases on PyPi, but this will change in the future. Releases should be carried out as follows:

  1. Create a new branch release-vX.Y.Z with the version for the release. In this branch, update CHANGELOG.rst, and make sure all new changes are reflected in the documentation:

    1. git add CHANGELOG.rst
    2. git commit -m "Changelog updates"
  2. Open a new pull request for this branch targeting master.

  3. After all tests pass and the pull request has been approved, merge into master.

  4. Get the latest version of the master branch:

    1. git checkout master
    2. git pull
  5. Tag the current commit and push to github:

    1. git tag -a vX.Y.Z -m "Version X.Y.Z"
    2. git push origin master --tags
  6. Build and publish release on PyPI:

    1. # Remove previous build products and build the package
    2. rm -r dist build *.egg-info
    3. python setup.py sdist bdist_wheel --universal
    4. # Check the source and upload to the test repository
    5. twine check dist/*
    6. twine upload --repository-url https://test.pypi.org/legacy/ dist/*
    7. # Go to https://test.pypi.org/project/proplot/ and make sure everything looks ok
    8. # Then make sure the package is installable
    9. pip install --index-url https://test.pypi.org/simple/ proplot
    10. # Register and push to pypi
    11. twine upload dist/*