Debian Codegraph @

doc/source/contributing/index.rst

raw
1 .. _contributing:
2 :github_url:
3
4
5 .. image:: ../_static/scikit-rf-title-flat.svg
6 :target: ../_static/scikit-rf-title-flat.svg
7 :height: 100
8 :align: center
9
10
11 Contributing to scikit-rf
12 ==========================
13
14 Sponsoring the Project
15 ----------------------
16 It is possible to sponsor the maintainers and developers of the scikit-rf package, using the GitHub Sponsor option ("Sponsor this project") visible on the `scikit-rf GitHub page <https://github.com/scikit-rf/scikit-rf>`_.
17
18 Sponsoring is one more way to contribute to open source: financially supporting the people who build and maintain it. Funding individuals helps them keep doing important work, expands opportunities to participate, and gives developers the recognition they deserve.
19
20
21 Contributing to the Code
22 ------------------------
23
24 .. note:: if you feel that the instructions on this page are too complicated, but you still would like to contribute, do not hesitate to email us on the `scikit-rf mailing list <https://groups.google.com/forum/#!forum/scikit-rf>`_ or join us in the `scikit-rf Slack channel <https://join.slack.com/t/scikit-rf/shared_invite/zt-d82b62wg-0bdSJjZVhHBKf6687V80Jg>`_ or the `scikit-rf Matrix/Element channel <https://app.element.io/#/room/#scikit-rf:matrix.org>`_ to get some help.
25
26
27 **skrf** uses the "Fork + Pull" collaborative development model. If this is new to you, see GitHub's articles on `forking <https://help.github.com/articles/fork-a-repo>`_ and `pull requests <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests>`_.
28
29 Basically, you will:
30
31 1. `Fork <https://help.github.com/articles/fork-a-repo>`_ the `GitHub scikit-rf repository <https://github.com/scikit-rf/scikit-rf>`_,
32
33 2. Make your modifications.
34
35 3. Then send a `pull request (PR) <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests>`_ for your additions to be merged into the main scikit-rf repository. Your proposal will be reviewed or discussed and you may receive some comments which only aim to make your contribution as great as possible!
36
37
38 .. tip:: When making your modification locally, you may need to work into a dedicated development environment in order to not interfere with the scikit-rf package that you have `already installed <../tutorials/Installation.html>`_. You can use for example `anaconda environment <https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html>`_. In order for the anaconda environment to find your local scikit-rf repo, use the convenient `conda-develop <https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html>`_ command.
39
40 Pre-commit
41 ++++++++++
42
43 You can use pre-commit_ to automate your code quality checks and perform
44 automated fixes in **scikit-rf**.
45
46 To enable pre-commit on your computer (make sure it is installed first), open a terminal and Navigate to
47 the :file:`scikit-rf/` directory that contains your clone of scikit-rf's repository, then run:
48
49 .. code-block:: bash
50
51 pre-commit install
52
53 .. note::
54
55 Once pre-commit has been installed for a repository, pre-commit will
56 run every time you try to commit a change. If any pre-commit checks
57 fail, or if pre-commit changes any files, it will be necessary to
58 redo `git add` on the changed files and `git commit` once
59 again.
60
61 .. tip::
62
63 To commit a change without running pre-commit, use the `-n` or
64 `--no-verify` flag with git.
65
66
67 Basic git command-line workflow
68 +++++++++++++++++++++++++++++++
69
70 The following is a basic example of the git commands that can be used to contribute to the code.
71
72 .. code-block:: sh
73
74 # create your own fork of scikit-rf in the GitHub interface, say ME/scikit-rf
75
76 # clone your new fork locally, using either:
77 git clone [email protected]:ME/scikit-rf.git
78
79 # if you have ssh keys setup, or if not:
80 git clone https://github.com/scikit-rf/scikit-rf.git
81
82 # ... make your changes...
83
84 # commit changes locally
85 git commit -a
86
87 # push changes to your repo
88 git push origin
89
90 # create a pull request on github.com
91
92
93 Staying Synchronized
94 ++++++++++++++++++++
95
96 To keep your local version synchronized (up-to-date) with the scikit-rf repository, `add a "remote" (call it "upstream") <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/configuring-a-remote-for-a-fork>`_. From this remote, you can `"fetch" and "merge" the official scikit-rf repo's changes into your local repo <https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork>`_.
97
98 .. code-block:: sh
99
100 git remote add upstream https://github.com/scikit-rf/scikit-rf.git
101
102 # Fetch any new changes from the original repo
103 git fetch upstream
104
105 # Merges any changes fetched into your working files
106 git merge upstream/master
107
108
109
110 Tests
111 +++++
112
113 Tests are vital for software reliability and maintainability. Writing tests often require additional effort but saves time in the long run. Tests enable us to quickly discover when we introduce new errors. It is also a way to provide examples of how functions and classes were originally intended to be used.
114
115 Before making a Pull Request, we advise contributors to run the tests locally to check if nothing has been broken following their modifications. In addition, we highly recommend providing new tests when adding new features.
116
117 The structure of the testing generally follows the conventions of `numpy/scipy <https://github.com/numpy/numpy/blob/master/doc/TESTS.rst>`_. Test cases live in the module, or submodule, which they are testing, and are located in a directory called `tests`. So, the tests of the media module are located at `skrf/media/tests/`.
118 Tests can be run most easily with `pytest <https://docs.pytest.org/en/latest/index.html>`_.
119
120 You probably **don't** want to run the tests for the virtual instruments ``skrf.vi`` with the rest of the tests, so these tests are excluded by default.
121
122 To run all the tests (except the virtual instruments)
123
124 .. code-block:: sh
125
126 cd scikit-rf
127 # Create environment and install dependencies, needed only once.
128 python -m venv .venv
129 pip install -e .[test,visa,netw,xlsx,plot,docs,testspice] --compile
130
131 # Activate Environment, needed for all following steps.
132 # on Linux Systems
133 . .venv/bin/activate
134
135 # on Windows
136 .\.venv\Scripts\activate
137
138 pytest
139
140 To run all tests *and* all tutorials and example notebooks in your current environment (recommended before making a pull request):
141
142 .. code-block:: sh
143
144 pytest --nbval-lax
145
146
147 If you want to test a single file or directory, you need to override the default pytest configuration and indicate the test path. For example, to run only the tests associated with the Network object (-v to increase the verbosity):
148
149 .. code-block:: sh
150
151 pytest -v -c "" skrf/tests/test_network.py
152
153
154 It is also possible to select some particular tests using the regex option (-k):
155
156 .. code-block:: sh
157
158 pytest -v -c "" skrf/calibration/tests/test_calibration.py -k "test_error_ntwk"
159
160
161
162
163
164 Contributing to the Documentation
165 ----------------------------------
166
167 Examples and Tutorials
168 ++++++++++++++++++++++
169
170 Usage examples of scikit-rf are welcomed, especially when adding new features. We are using `Jupyter Notebooks <https://jupyter.org/>`_ to write the examples and the tutorials, which are located in the ``scikit-rf/docs/source/examples/`` and ``doc/source/examples`` directories. These notebooks are then converted into webpages with the sphinx extension called `nbsphinx <http://nbsphinx.readthedocs.io/>`_.
171
172 The docs are automatically built and `served by readthedocs <https://scikit-rf.readthedocs.io/en/latest/>`_ when a Pull Request is accepted. The Python package requirements to build the docs are kept in ``scikit-rf/pyproject.toml``.
173
174 .. important:: Before pushing to your repo and making a pull request, at a minimum you will need to clear the notebook outputs using the "Clear All Output" command in the notebook (or install `nbstripout <https://pypi.python.org/pypi/nbstripout>`_ so that the output is not tracked in git (or the repo size would grow infinitely).
175
176
177 Reference (API) or static documentation
178 +++++++++++++++++++++++++++++++++++++++
179
180 The documentation source files can be found in ``doc/source/``.
181
182 The reference documentation for the functions, classes, and submodules are documented in docstrings following the conventions put forth by `Numpy/Scipy docstring format <https://numpydoc.readthedocs.io/en/latest/format.html>`_. The documentation as a whole is generated using sphinx, and written using reStructed (.rst) Text.
183
184 .. tip:: If you want to write some .rst file yourself, please use an RST format editor and checker (ex: `<https://livesphinx.herokuapp.com/>`_), as Sphinx is (very) picky with the syntax...
185
186
187 Building the documentation locally
188 ++++++++++++++++++++++++++++++++++
189
190 Before making a pull request concerning the documentation, it is a good idea to test locally if your changes lead to the desired HTML output (sometimes some problems can arise during the conversion to HTML). The documentation is built by the following commands:
191
192 .. code-block:: sh
193
194 # be sure to be in the scikit-rf/doc directory
195 make html
196
197
198 The built docs then reside in ``doc/build/html``.
199
200
201
202
203 Join the **scikit-rf** team!
204 ----------------------------
205
206 Do you like using scikit-rf? `Merchandise is available for you to express your love <https://scikit-rf.org/merch.html>`_.
207
208 .. image:: https://raw.githubusercontent.com/scikit-rf/scikit-rf/master/logo/skrfshirtwhite.png
209 :height: 400
210 :align: center