Skip to content

Commit 339e6aa

Browse files
RDaxiniechedey-ls
andauthored
Split contributing.rst (#2219)
* create split contributing page (initial) besides splitting, some rearranging e.g. virtual environments section after pull requests section some changing of headings for the new pages to make sense and avoid repetition * Update v0.11.1.rst * Update docs/sphinx/source/contributing/testing.rst Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com> * add example gallery --------- Co-authored-by: Echedey Luis <80125792+echedey-ls@users.noreply.github.com>
1 parent e80355e commit 339e6aa

File tree

8 files changed

+562
-509
lines changed

8 files changed

+562
-509
lines changed

docs/sphinx/source/contributing.rst

Lines changed: 0 additions & 508 deletions
This file was deleted.
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
.. _contributing_new_code:
2+
3+
How to contribute new code
4+
==========================
5+
6+
The basics
7+
~~~~~~~~~~
8+
9+
Contributors to pvlib-python use GitHub's pull requests to add/modify
10+
its source code. The GitHub pull request process can be intimidating for
11+
new users, but you'll find that it becomes straightforward once you use
12+
it a few times. Please let us know if you get stuck at any point in the
13+
process. Here's an outline of the process:
14+
15+
#. Create a GitHub issue and get initial feedback from users and
16+
maintainers. If the issue is a bug report, please include the
17+
code needed to reproduce the problem.
18+
#. Obtain the latest version of pvlib-python: Fork the pvlib-python
19+
project to your GitHub account, ``git clone`` your fork to your computer.
20+
#. Make some or all of your changes/additions and ``git commit`` them to
21+
your local repository.
22+
#. Share your changes with us via a pull request: ``git push`` your
23+
local changes to your GitHub fork, then go to GitHub make a pull
24+
request.
25+
26+
The Pandas project maintains an excellent `contributing page
27+
<http://pandas.pydata.org/pandas-docs/stable/contributing.html>`_ that goes
28+
into detail on each of these steps. Also see GitHub's `Set Up Git
29+
<https://help.github.com/articles/set-up-git/>`_ and `Using Pull
30+
Requests <https://help.github.com/articles/using-pull-requests/>`_.
31+
32+
You must include documentation and unit tests for any new or improved
33+
code. We can provide help and advice on this after you start the pull
34+
request. See the :ref:`documentation` and :ref:`testing` sections for more
35+
information on these aspects.
36+
37+
38+
.. _pull-requests:
39+
40+
Pull requests (PRs)
41+
~~~~~~~~~~~~~~~~~~~
42+
43+
.. _pull-request-scope:
44+
45+
Scope
46+
-----
47+
48+
This section can be summed up as "less is more".
49+
50+
A pull request can quickly become unmanageable if too many lines are
51+
added or changed. "Too many" is hard to define, but as a rule of thumb,
52+
we encourage contributions that contain less than 50 lines of primary code.
53+
50 lines of primary code will typically need at least 250 lines
54+
of documentation and testing. This is about the limit of what the
55+
maintainers can review on a regular basis.
56+
57+
A pull request can also quickly become unmanageable if it proposes
58+
changes to the API in order to implement another feature. Consider
59+
clearly and concisely documenting all proposed API changes before
60+
implementing any code. Modifying
61+
`api.rst <https://github.com/pvlib/pvlib-python/tree/main/docs/sphinx/source/reference>`_
62+
and/or the latest `whatsnew file <https://github.com/pvlib/pvlib-python/tree/main/docs/sphinx/source/whatsnew>`_
63+
can help formalize this process.
64+
65+
Questions about related issues frequently come up in the process of
66+
addressing implementing code for a pull request. Please try to avoid
67+
expanding the scope of your pull request (this also applies to
68+
reviewers!). We'd rather see small, well-documented additions to the
69+
project's technical debt than see a pull request languish because its
70+
scope expanded beyond what the reviewer community is capable of
71+
processing.
72+
73+
Of course, sometimes it is necessary to make a large pull request. We
74+
only ask that you take a few minutes to consider how to break it into
75+
smaller chunks before proceeding.
76+
77+
pvlib-python contains :ref:`3 "layers" of code <modeling-paradigms>`:
78+
functions, PVSystem/Location, and ModelChain. We recommend that
79+
contributors focus their work on only one or two of those layers in a
80+
single pull request. New models are *not* required to be available to
81+
the higher-level API!
82+
83+
84+
When should I submit a pull request?
85+
------------------------------------
86+
87+
The short answer: anytime.
88+
89+
The long answer: it depends. If in doubt, go ahead and submit. You do
90+
not need to make all of your changes before creating a pull request.
91+
Your pull requests will automatically be updated when you commit new
92+
changes and push them to GitHub.
93+
94+
There are pros and cons to submitting incomplete pull-requests. On the
95+
plus side, it gives everybody an easy way to comment on the code and can
96+
make the process more efficient. On the minus side, it's easy for an
97+
incomplete pull request to grow into a multi-month saga that leaves
98+
everyone unhappy. If you submit an incomplete pull request, please be
99+
very clear about what you would like feedback on and what we should
100+
ignore. Alternatives to incomplete pull requests include creating a
101+
`gist <https://gist.github.com>`_ or experimental branch and linking to
102+
it in the corresponding issue.
103+
104+
The best way to ensure that a pull request will be reviewed and merged in
105+
a timely manner is to:
106+
107+
#. Start by creating an issue. The issue should be well-defined and
108+
actionable.
109+
#. Ask the `maintainers <https://github.com/orgs/pvlib/people>`_ to tag
110+
the issue with the appropriate milestone.
111+
#. Make a limited-scope pull request. It can be a lot of work to check all of
112+
the boxes in `pull request guidelines
113+
<https://github.com/pvlib/pvlib-python/blob/main/.github/PULL_REQUEST_TEMPLATE.md>`_,
114+
especially for pull requests with a lot of new primary code.
115+
See :ref:`pull-request-scope`.
116+
#. Tag pvlib community members or ``@pvlib`` when the pull
117+
request is ready for review. (see :ref:`pull-request-reviews`)
118+
119+
120+
.. _pull-request-reviews:
121+
122+
Pull request reviews
123+
--------------------
124+
125+
The pvlib community and maintainers will review your pull request in a
126+
timely fashion. Please "ping" ``@pvlib`` if it seems that
127+
your pull request has been forgotten at any point in the pull request
128+
process.
129+
130+
Keep in mind that the PV modeling community is diverse and each pvlib
131+
community member brings a different perspective when reviewing code.
132+
Some reviewers bring years of expertise in the sub-field that your code
133+
contributes to and will focus on the details of the algorithm. Other
134+
reviewers will be more focused on integrating your code with the rest of
135+
pvlib, ensuring that it is feasible to maintain, that it meets the
136+
:ref:`code style <code-style>` guidelines, and that it is
137+
:ref:`comprehensively tested <testing>`. Limiting the scope of the pull
138+
request makes it much more likely that all of these reviews can be
139+
conducted and any issues can be resolved in a timely fashion.
140+
141+
Sometimes it's hard for reviewers to be immediately available, so the
142+
right amount of patience is to be expected. That said, interested
143+
reviewers should do their best to not wait until the last minute to put
144+
in their two cents.
145+
146+
147+
.. _virtual-environments:
148+
149+
Virtual environments
150+
~~~~~~~~~~~~~~~~~~~~
151+
152+
We strongly recommend using virtual environments for development.
153+
Virtual environments make it easier to switch between different
154+
versions of software. This `scientific-python.org guide
155+
<https://learn.scientific-python.org/development/tutorials/dev-environment/>`_
156+
is a good reference for virtual environments. The pvlib-python `installation
157+
user guide <https://pvlib-python.readthedocs.io/en/stable/user_guide/
158+
installation.html#set-up-a-virtual-environment>`_ also provides instructions on
159+
setting up a virtual environment. If this is your first pull request, don't
160+
worry about using a virtual environment.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
============
2+
Contributing
3+
============
4+
5+
6+
.. toctree::
7+
:maxdepth: 2
8+
9+
introduction_to_contributing
10+
how_to_contribute_new_code
11+
style_guide
12+
testing
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.. _introduction-to-contributing:
2+
3+
Introduction to contributing
4+
============================
5+
6+
Encouraging more people to help develop pvlib-python is essential to our
7+
success. Therefore, we want to make it easy and rewarding for you to
8+
contribute.
9+
10+
There is a lot of material in this section, aimed at a variety of
11+
contributors from novice to expert. Don't worry if you don't (yet)
12+
understand parts of it.
13+
14+
15+
.. _easy-ways-to-contribute:
16+
17+
Easy ways to contribute
18+
~~~~~~~~~~~~~~~~~~~~~~~
19+
20+
Here are a few ideas for how you can contribute, even if you are new to
21+
pvlib-python, git, or Python:
22+
23+
* Ask and answer `pvlib questions on StackOverflow <http://stackoverflow.com/questions/tagged/pvlib>`_
24+
and participate in discussions in the `pvlib-python google group <https://groups.google.com/forum/#!forum/pvlib-python>`_.
25+
* Make `GitHub issues <https://github.com/pvlib/pvlib-python/issues>`_
26+
and contribute to the conversations about how to resolve them.
27+
* Read issues and pull requests that other people created and
28+
contribute to the conversation about how to resolve them.
29+
Look for issues tagged with
30+
`good first issue <https://github.com/pvlib/pvlib-python/labels/good%20first%20issue>`_,
31+
`easy <https://github.com/pvlib/pvlib-python/labels/easy>`_,
32+
or `help wanted <https://github.com/pvlib/pvlib-python/labels/help%20wanted>`_.
33+
* Improve the documentation and the unit tests.
34+
* Improve the Example Gallery or add new examples that
35+
demonstrate how to use pvlib-python in your area of expertise.
36+
* Tell your friends and colleagues about pvlib-python.
37+
* Add your project to our
38+
`Projects and publications that use pvlib-python wiki
39+
<https://github.com/pvlib/pvlib-python/wiki/Projects-and-publications-
40+
that-use-pvlib-python>`_.
41+
42+
43+
This documentation
44+
~~~~~~~~~~~~~~~~~~
45+
46+
If this documentation is unclear, help us improve it! Consider looking
47+
at the `pandas
48+
documentation <http://pandas.pydata.org/pandas-docs/stable/
49+
contributing.html>`_ for inspiration.
50+
51+
52+
Code of Conduct
53+
~~~~~~~~~~~~~~~
54+
All contributors are expected to adhere to the `Contributor Code of Conduct
55+
<https://github.com/pvlib/pvlib-python/blob/main/CODE_OF_CONDUCT.md#contributor-covenant-code-of-conduct>`_.
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
.. _documentation-and-style-guide:
2+
3+
Documentation and style guide
4+
=============================
5+
6+
.. _code-style:
7+
8+
Code style
9+
~~~~~~~~~~
10+
11+
pvlib python generally follows the `PEP 8 -- Style Guide for Python Code
12+
<https://www.python.org/dev/peps/pep-0008/>`_. Maximum line length for code
13+
is 79 characters.
14+
15+
pvlib python uses a mix of full and abbreviated variable names. See
16+
:ref:`variables_style_rules`. We could be better about consistency.
17+
Prefer full names for new contributions. This is especially important
18+
for the API. Abbreviations can be used within a function to improve the
19+
readability of formulae.
20+
21+
Set your editor to strip extra whitespace from line endings. This
22+
prevents the git commit history from becoming cluttered with whitespace
23+
changes.
24+
25+
Please see :ref:`Documentation` for information specific to documentation
26+
style.
27+
28+
Remove any ``logging`` calls and ``print`` statements that you added
29+
during development. ``warning`` is ok.
30+
31+
We typically use GitHub's
32+
"`squash and merge <https://help.github.com/articles/about-pull-request-merges/#squash-and-merge-your-pull-request-commits>`_"
33+
feature to merge your pull request into pvlib. GitHub will condense the
34+
commit history of your branch into a single commit when merging into
35+
pvlib-python/main (the commit history on your branch remains
36+
unchanged). Therefore, you are free to make commits that are as big or
37+
small as you'd like while developing your pull request.
38+
39+
40+
.. _documentation:
41+
42+
Documentation
43+
~~~~~~~~~~~~~
44+
45+
.. _documentation-style:
46+
47+
Documentation style
48+
-------------------
49+
50+
Documentation must be written in
51+
`numpydoc format <https://numpydoc.readthedocs.io/>`_ format which is rendered
52+
using the `Sphinx Napoleon extension
53+
<https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html>`_.
54+
55+
The numpydoc format includes a specification for the allowable input
56+
types. Python's `duck typing <https://en.wikipedia.org/wiki/Duck_typing>`_
57+
allows for multiple input types to work for many parameters. pvlib uses
58+
the following generic descriptors as short-hand to indicate which
59+
specific types may be used:
60+
61+
* dict-like : dict, OrderedDict, pd.Series
62+
* numeric : scalar, np.array, pd.Series. Typically int or float dtype.
63+
* array-like : np.array, pd.Series. Typically int or float dtype.
64+
65+
Parameters that specify a specific type require that specific input type.
66+
67+
Read the Docs will automatically build the documentation for each pull
68+
request. Please confirm the documentation renders correctly by following
69+
the ``docs/readthedocs.org:pvlib-python`` link within the checks
70+
status box at the bottom of the pull request.
71+
72+
73+
.. _building-the-documentation:
74+
75+
Building the documentation
76+
--------------------------
77+
78+
Building the documentation locally is useful for testing out changes to the
79+
documentation's source code without having to repeatedly update a PR and have
80+
Read the Docs build it for you. Building the docs locally requires installing
81+
pvlib python as an editable library (see :ref:`installation` for instructions).
82+
First, install the ``doc`` dependencies specified in the
83+
``EXTRAS_REQUIRE`` section of
84+
`setup.py <https://github.com/pvlib/pvlib-python/blob/main/setup.py>`_.
85+
An easy way to do this is with::
86+
87+
pip install pvlib[doc] # on Mac: pip install "pvlib[doc]"
88+
89+
Note: Anaconda users may have trouble using the above command to update an
90+
older version of docutils. If that happens, you can update it with ``conda``
91+
(e.g. ``conda install docutils=0.15.2``) and run the above command again.
92+
93+
Once the ``doc`` dependencies are installed, navigate to ``/docs/sphinx`` and
94+
execute::
95+
96+
make html
97+
98+
Be sure to skim through the output of this command because Sphinx might emit
99+
helpful warnings about problems with the documentation source code.
100+
If the build succeeds, it will make a new directory ``docs/sphinx/build``
101+
with the documentation's homepage located at ``build/html/index.html``.
102+
This file can be opened with a web browser to view the local version
103+
like any other website. Other output formats are available; run ``make help``
104+
for more information.
105+
106+
Note that Windows users need not have the ``make`` utility installed as pvlib
107+
includes a ``make.bat`` batch file that emulates its interface.
108+
109+
110+
.. _example-gallery:
111+
112+
Example Gallery
113+
---------------
114+
115+
The example gallery uses `sphinx-gallery <https://sphinx-gallery.github.io/>`_
116+
and is generated from script files in the
117+
`docs/examples <https://github.com/pvlib/pvlib-python/tree/main/docs/examples>`_
118+
directory. sphinx-gallery will execute example files that start with
119+
``plot_`` and capture the output.
120+
121+
Here is a starter template for new examples:
122+
123+
.. code-block:: python
124+
125+
"""
126+
Page Title
127+
==========
128+
129+
A sentence describing the example.
130+
"""
131+
132+
# %%
133+
# Explanatory text about the example, what it does, why it does it, etc.
134+
# Text in the comment block before the first line of code `import pvlib`
135+
# will be printed to the example's webpage.
136+
137+
import pvlib
138+
import matplotlib.pyplot as plt
139+
140+
plt.scatter([1, 2, 3], [4, 5, 6])
141+
plt.show()
142+
143+
For more details, see the sphinx-gallery
144+
`docs <https://sphinx-gallery.github.io/stable/syntax.html#embedding-rst>`_.

0 commit comments

Comments
 (0)