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

updated line length in code contrib section #348

Merged
merged 5 commits into from
Jan 15, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions doc/source/contributing_code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ Code formatting in Python

MDAnalysis is a project with a long history and many contributors; it hasn't used a consistent coding style. Since version 0.11.0, we are trying to update all the code to conform with `PEP8`_. Our strategy is to update the style every time we touch an old function and thus switch to `PEP8`_ continuously.

**Important requirements (from PEP8):**
- keep line length to **79 characters or less**; break long lines sensibly
**Important requirements (from PEP8)**:
- keep line length to **79 characters or less**; break long lines sensibly although for readability we may allow longer lines
- indent with **spaces** and use **4 spaces per level**
- naming:

Expand All @@ -408,6 +408,7 @@ MDAnalysis is a project with a long history and many contributors; it hasn't use
We recommend that you use a Python Integrated Development Environment (IDE) (`PyCharm`_ and others) or external tools like `flake8`_ for code linting. For integration of external tools with emacs and vim, check out `elpy`_ (emacs) and `python-mode`_ (vim).

To apply the code formatting in an automated way, you can also use code formatters. External tools include `autopep8`_ and `yapf`_. Most IDEs either have their own code formatter or will work with one of the above through plugins.
See :ref:`format-darker` for notes on maintaining code style compliance with existing tools.


.. _`PEP8`: https://www.python.org/dev/peps/pep-0008/
Expand Down Expand Up @@ -475,7 +476,7 @@ Changes to the code should be reflected in the ongoing ``CHANGELOG``. Add an ent
Ensure PEP8 compliance (mandatory) and format your code with Darker (optional)
-------------------------------------------------------------------------------

`Darker <https://github.com/akaihola/darker>`_ is a *partial formatting* tool that helps to reformat new or modified code
`darker`_ is a *partial formatting* tool that helps to reformat new or modified code
lines so the codebase progressively adapts a code style instead of doing a full reformat,
which would be a big commitment. It was designed with the ``black`` formatter in mind, hence the name.

Expand Down Expand Up @@ -515,6 +516,20 @@ Or if you're ok with the suggested formatting changes, just apply the suggested
darker -r upstream/develop testsuite/MDAnalysisTests -L flake8


.. note::

MDAnalysis does *not* currently use the popular `black`_ code formatter across the whole project, therefore please consider the following rules:

* Do **not run ``black`` on an existing file** that you are editing. This makes the diff for the PR very difficult to read. Instead use ``darker`` as explained above to only reformat your changes.
orbeckst marked this conversation as resolved.
Show resolved Hide resolved
* You *may* run ``black`` on a *new file* that you are adding to the code base.

For an ongoing discussion (which you are welcome to join) see `issue #2450`_.

.. _`darker`: https://github.com/akaihola/darker
.. _`black`: https://black.readthedocs.io/
.. _`issue #2450`: https://github.com/MDAnalysis/mdanalysis/issues/2450


.. _adding-code-to-mda:

------------------------------
Expand Down
Loading