Skip to content

Commit 4133f74

Browse files
committed
Add pre-commit and black for autoformatting, update docs correspondingly.
1 parent c0df02f commit 4133f74

File tree

4 files changed

+98
-11
lines changed

4 files changed

+98
-11
lines changed

.pre-commit-config.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
repos:
2+
- repo: https://github.com/asottile/reorder_python_imports
3+
rev: v1.3.5
4+
hooks:
5+
- id: reorder-python-imports
6+
language_version: python3.6
7+
- repo: https://github.com/ambv/black
8+
rev: 18.9b0
9+
hooks:
10+
- id: black
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v2.1.0
13+
hooks:
14+
- id: end-of-file-fixer
15+
- id: check-json
16+
- id: check-yaml
17+
- id: check-case-conflict
18+
- id: check-executables-have-shebangs
19+
- id: requirements-txt-fixer
20+
- id: flake8

CONTRIBUTING.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Contributing to NBViewer
2+
3+
4+
Welcome! As a [Jupyter](https://jupyter.org) project,
5+
you can follow the [Jupyter contributor guide](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html).
6+
7+
Make sure to also follow [Project Jupyter's Code of Conduct](https://github.com/jupyter/governance/blob/master/conduct/code_of_conduct.md)
8+
for a friendly and welcoming collaborative environment.
9+
10+
## Setting up a development environment
11+
12+
See the instructions for local development or local installation first. Next, set up pre-commit hooks for automatic code formatting, etc.
13+
14+
```bash
15+
pre-commit install
16+
```
17+
18+
You can also invoke the pre-commit hook manually at any time with
19+
20+
```bash
21+
pre-commit run
22+
```
23+
24+
NBViewer has adopted automatic code formatting so you shouldn't
25+
need to worry too much about your code style.
26+
As long as your code is valid,
27+
the pre-commit hook should take care of how it should look.
28+
You can invoke the pre-commit hook by hand at any time with:
29+
30+
```bash
31+
pre-commit run
32+
```
33+
34+
which should run any autoformatting on your code
35+
and tell you about any errors it couldn't fix automatically.
36+
You may also install [black integration](https://github.com/ambv/black#editor-integration)
37+
into your text editor to format code automatically.
38+
39+
#### Running the Tests
40+
41+
It's a good idea to write tests to exercise any new features,
42+
or that trigger any bugs that you have fixed to catch regressions. `nose` is used to run the test suite. The tests currently make calls to
43+
external APIs such as GitHub, so it is best to use your Github API Token when
44+
running:
45+
46+
```shell
47+
$ cd <path to repo>
48+
$ pip install -r requirements-dev.txt
49+
$ GITHUB_API_TOKEN=<your token> python setup.py test
50+
```
51+
52+
You can run the tests with:
53+
54+
```bash
55+
nosetests -v
56+
```
57+
58+
in the repo directory.

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
1+
**[Quick Run](#quick-run)** |
2+
**[GitHub Enterprise](#github-enterprise)** |
3+
**[Base URL](#base-url)** |
4+
**[Local Development](#local-development)** |
5+
**[Contributing](#contributing)** |
6+
**[Extensions](#extending-the-notebook-viewer)** |
7+
**[Configuration](#config-file-and-command-line-configuration)** |
8+
**[Security](#securing-the-notebook-viewer)**
9+
10+
111
# Jupyter Notebook Viewer
212

3-
Jupyter nbviewer is the web application behind
13+
[![Latest PyPI version](https://img.shields.io/pypi/v/nbviewer?logo=pypi)](https://pypi.python.org/pypi/nbviewer)
14+
[![TravisCI build status](https://img.shields.io/travis/jupyter/nbviewer/master?logo=travis)](https://travis-ci.org/jupyter/nbviewer)
15+
[![GitHub](https://img.shields.io/badge/issue_tracking-github-blue?logo=github)](https://github.com/jupyter/nbviewer/issues)
16+
[![Gitter](https://img.shields.io/badge/social_chat-gitter-blue?logo=gitter)](https://gitter.im/jupyter/nbviewer)
17+
18+
Jupyter NBViewer is the web application behind
419
[The Jupyter Notebook Viewer](http://nbviewer.jupyter.org),
520
which is graciously hosted by [OVHcloud](https://ovhcloud.com).
621

@@ -129,17 +144,10 @@ $ python -m nbviewer --debug --no-cache
129144
This will automatically relaunch the server if a change is detected on a python file, and not cache any results. You can then just do the modifications you like to the source code and/or the templates then refresh the pages.
130145

131146

132-
#### Running the Tests
133-
134-
`nose` is used to run the test suite. The tests currently make calls to
135-
external APIs such as GitHub, so it is best to use your Github API Token when
136-
running:
147+
## Contributing
137148

138-
```shell
139-
$ cd <path to repo>
140-
$ pip install -r requirements-dev.txt
141-
$ GITHUB_API_TOKEN=<your token> python setup.py test
142-
```
149+
If you would like to contribute to the project, please read the [`CONTRIBUTING.md`](CONTRIBUTING.md). The `CONTRIBUTING.md` file
150+
explains how to set up a development installation and how to run the test suite.
143151

144152

145153
## Extending the Notebook Viewer

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ coverage
22
invoke>=0.13.0
33
mock>=1.3.0 # python34 and older versions of mock do not play well together.
44
nose
5+
pre-commit
56
requests

0 commit comments

Comments
 (0)