You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For doing cmd2 development, you actually do NOT want to have cmd2 installed as a Python package.
182
182
So if you have previously installed cmd2, make sure to uninstall it:
183
-
```bash
184
-
pip uninstall cmd2
183
+
```sh
184
+
$ pip uninstall cmd2
185
185
```
186
186
187
187
Assuming you cloned the repository to `~/src/cmd2`:
188
-
```bash
188
+
```sh
189
189
$ cd~/src/cmd2
190
190
$ pip install -e .
191
191
```
@@ -195,18 +195,39 @@ imports `cmd2`, there is no need to re-install the module after every change. Th
195
195
command will also install all of the runtime dependencies for `cmd2`.
196
196
197
197
Next you should install all the modules used for development of `cmd2`:
198
-
```bash
198
+
```sh
199
199
$ cd~/src/cmd2
200
200
$ pip install -e .[dev]
201
201
```
202
202
203
-
This will install `pytest` and `tox` for running unit tests, `pylint` for
204
-
static code analysis, and `sphinx` for building the documentation.
203
+
This project uses many python modules for various development tasks, including
204
+
testing, rendering documentation, and building and distributing releases. These
205
+
modules can be configured many different ways, which can make it difficult to
206
+
learn the specific incantations required for each project you are familiar with.
207
+
208
+
This project uses `invoke <http://www.pyinvoke.org>`_ to provide a clean, high
209
+
level interface for these development tasks. To see the full list of functions
210
+
available::
211
+
```sh
212
+
$ invoke -l
213
+
```
214
+
215
+
You can run multiple tasks in a single invocation, for example::
216
+
```sh
217
+
$ invoke docs sdist wheel
218
+
```
219
+
220
+
That one command will remove all superflous cache, testing, and build
221
+
files, render the documentation, and build a source distribution and a
222
+
wheel distribution.
223
+
224
+
If you want to see the details about what `invoke` is doing under the hood,
225
+
have a look at `tasks.py`.
205
226
206
227
Now you can check if everything is installed and working:
207
-
```bash
208
-
cd~src/cmd2
209
-
python examples/example.py
228
+
```sh
229
+
$ cd~src/cmd2
230
+
$ python examples/example.py
210
231
```
211
232
212
233
If the example app loads, you should see a prompt that says "(Cmd)". You can
@@ -220,20 +241,32 @@ This bit is up to you!
220
241
221
242
#### How to find the code in the cmd2 codebase to fix/edit?
222
243
223
-
The cmd2 project directory structure is pretty simple and straightforward. All actual code for cmd2
224
-
is located underneath the `cmd2` directory. The code to generate the documentation is in the `docs` directory. Unit tests are in the `tests` directory. The `examples` directory contains examples of how
225
-
to use cmd2. There are various other files in the root directory, but these are primarily related to
226
-
continuous integration and to release deployment.
244
+
The cmd2 project directory structure is pretty simple and straightforward. All
245
+
actual code for cmd2 is located underneath the `cmd2` directory. The code to
246
+
generate the documentation is in the `docs` directory. Unit tests are in the
247
+
`tests` directory. The `examples` directory contains examples of how to use
248
+
cmd2. There are various other files in the root directory, but these are
249
+
primarily related to continuous integration and to release deployment.
227
250
228
251
#### Changes to the documentation files
229
-
If you made changes to any file in the `/docs` directory, you need to build the Sphinx documentation
230
-
and make sure your changes look good:
231
-
```shell
232
-
cd docs
233
-
make clean html
252
+
253
+
If you made changes to any file in the `/docs` directory, you need to build the
254
+
Sphinx documentation and make sure your changes look good:
255
+
```sh
256
+
$ invoke docs
234
257
```
235
258
In order to see the changes, use your web browser of choice to open `<cmd2>/docs/_build/html/index.html`.
236
259
260
+
If you would rather use a webserver to view the documentation, including
261
+
automatic page refreshes as you edit the files, use:
262
+
263
+
```sh
264
+
$ invoke livehtml
265
+
```
266
+
267
+
You will be shown the IP address and port number where the documents are now
268
+
served (usually [http://localhost:8000](http://localhost:8000).
269
+
237
270
### Static Code Analysis
238
271
239
272
You should have some sort of [PEP8](https://www.python.org/dev/peps/pep-0008/)-based linting running in your editor or IDE or at the command-line before you commit code. [pylint](https://www.pylint.org) is a good Python linter which can be run at the command-line but also can integrate with many IDEs and editors.
@@ -242,21 +275,14 @@ You should have some sort of [PEP8](https://www.python.org/dev/peps/pep-0008/)-b
242
275
243
276
### Run The Test Suite
244
277
When you're ready to share your code, run the test suite:
Then use your web browser of choice to look at the results which are in `<cmd2>/htmlcov/index.html`.
284
+
Running the test suite also calculates test code coverage. A summary of coverage
285
+
is shown on the screen. A full report is available in `<cmd2>/htmlcov/index.html`.
260
286
261
287
### Squash Your Commits
262
288
When you make a pull request, it is preferable for all of your changes to be in one commit.
@@ -301,7 +327,7 @@ Instance of cmd2](#maintaining-your-fork).
301
327
1. Perform the maintenance step of rebasing `master`.
302
328
2. Ensure you are on the `master` branch using `git status`:
303
329
304
-
```bash
330
+
```sh
305
331
$ git status
306
332
On branch master
307
333
Your branch is up-to-date with 'origin/master'.
@@ -458,6 +484,19 @@ excellent support for debugging console applications.
458
484
459
485
[PyCharm](https://www.jetbrains.com/pycharm/) is also quite good and has very nice [Code Inspection](https://www.jetbrains.com/help/pycharm/code-inspection.html) capabilities.
460
486
461
-
### Acknowledgement
487
+
## Publishing a new release
488
+
489
+
Since 0.9.2, the process of publishing a new release of `cmd2` to [PyPi](https://pypi.org/) has been
490
+
mostly automated. The manual steps are all git operations. Here's the checklist:
491
+
492
+
1. Make sure you are on the proper branch
493
+
2. Make sure the version strings in `cmd2.py`, `conf.py`, `setup.py`, and `test_cmd2.py` are correct.
494
+
3. Make sure all the unit tests pass.
495
+
4. Make sure `CHANGELOG.md` describes the version and has the correct release date.
496
+
5. Create and push a git tag that matches the version strings above.
497
+
6. (Optional) Run `invoke pypi_test` to clean, build, and upload a new release to [Test PyPi](https://test.pypi.org)
498
+
7. Run `invoke pypi` to clean, build, and upload a new release to [PyPi](https://pypi.org/)
499
+
500
+
## Acknowledgement
462
501
Thanks to the good folks at [freeCodeCamp](https://github.com/freeCodeCamp/freeCodeCamp) for creating
463
502
an excellent `CONTRIBUTING` file which we have borrowed heavily from.
0 commit comments