2016-03-15 03:21:27 +08:00
|
|
|
Contributing to the Jupyter Notebook
|
|
|
|
====================================
|
|
|
|
|
2016-03-19 21:24:08 +08:00
|
|
|
If you're reading this section, you're probably interested in contributing to
|
|
|
|
Jupyter. Welcome and thanks for your interest in contributing!
|
|
|
|
|
|
|
|
Please take a look at the Contributor documentation, familiarize yourself with
|
2016-10-03 02:59:18 +08:00
|
|
|
using the Jupyter Notebook, and introduce yourself on the mailing list and
|
|
|
|
share what area of the project you are interested in working on.
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
General Guidelines
|
|
|
|
------------------
|
|
|
|
|
|
|
|
For general documentation about contributing to Jupyter projects, see the
|
|
|
|
`Project Jupyter Contributor Documentation`__.
|
|
|
|
|
2016-10-10 04:56:18 +08:00
|
|
|
__ https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
Setting Up a Development Environment
|
|
|
|
------------------------------------
|
|
|
|
|
2016-03-15 22:38:31 +08:00
|
|
|
Installing Node.js and npm
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
Building the Notebook from its GitHub source code requires some tools to
|
|
|
|
create and minify JavaScript components and the CSS.
|
2016-03-19 21:37:58 +08:00
|
|
|
Namely, that's Node.js and Node's package manager, ``npm``.
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2016-03-19 21:37:58 +08:00
|
|
|
If you use ``conda``, you can get them with::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2016-03-19 21:37:58 +08:00
|
|
|
conda install -c javascript nodejs
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2016-03-19 21:37:58 +08:00
|
|
|
If you use `Homebrew <http://brew.sh/>`_ on Mac OS X::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
brew install node
|
|
|
|
|
2016-03-15 21:32:49 +08:00
|
|
|
For Debian/Ubuntu systems, you should use the ``nodejs-legacy`` package instead
|
|
|
|
of the ``node`` package::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get install nodejs-legacy npm
|
|
|
|
|
2016-03-19 21:37:58 +08:00
|
|
|
You can also use the installer from the `Node.js website <https://nodejs.org>`_.
|
|
|
|
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2016-03-15 22:28:08 +08:00
|
|
|
Installing the Jupyter Notebook
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Once you have installed the dependencies mentioned above, use the following
|
|
|
|
steps::
|
|
|
|
|
|
|
|
pip install setuptools pip --upgrade --user
|
|
|
|
git clone https://github.com/jupyter/notebook
|
|
|
|
cd notebook
|
|
|
|
pip install -e . --user
|
|
|
|
|
|
|
|
If you want the development environment to be available for all users of your
|
2016-03-25 06:13:48 +08:00
|
|
|
system (assuming you have the necessary rights) or if you are installing in a
|
|
|
|
virtual environment, just drop the ``--user`` option.
|
2016-03-15 22:28:08 +08:00
|
|
|
|
2016-07-16 23:26:01 +08:00
|
|
|
Once you have done this, you can launch the master branch of Jupyter notebook
|
|
|
|
from any directory in your system with::
|
|
|
|
|
|
|
|
jupyter notebook
|
|
|
|
|
2016-03-15 22:28:08 +08:00
|
|
|
|
2016-03-15 03:21:27 +08:00
|
|
|
Rebuilding JavaScript and CSS
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
There is a build step for the JavaScript and CSS in the notebook.
|
2016-03-15 21:32:49 +08:00
|
|
|
To make sure that you are working with up-to-date code, you will need to run
|
|
|
|
this command whenever there are changes to JavaScript or LESS sources::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2017-02-14 07:57:08 +08:00
|
|
|
npm run build
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2017-02-14 07:57:08 +08:00
|
|
|
**IMPORTANT:** Don't forget to run ``npm run build`` after switching branches.
|
|
|
|
When switching between branches of different versions (e.g. ``4.x`` and
|
|
|
|
``master``), run ``pip install -e .``. If you have tried the above and still
|
|
|
|
find that the notebook is not reflecting the current source code, try cleaning
|
|
|
|
the repo with ``git clean -xfd`` and reinstalling with ``pip install -e .``.
|
|
|
|
|
|
|
|
Development Tip
|
2016-03-15 03:21:27 +08:00
|
|
|
"""""""""""""""
|
|
|
|
|
2017-02-14 07:57:08 +08:00
|
|
|
When doing development, you can use this command to automatically rebuild
|
|
|
|
JavaScript and LESS sources as they are modified::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
npm run build:watch
|
|
|
|
|
|
|
|
Git Hooks
|
|
|
|
"""""""""
|
|
|
|
|
2017-02-14 07:57:08 +08:00
|
|
|
If you want to automatically update dependencies and recompile JavaScript and
|
|
|
|
CSS after checking out a new commit, you can install post-checkout and
|
|
|
|
post-merge hooks which will do it for you::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
git-hooks/install-hooks.sh
|
|
|
|
|
|
|
|
See ``git-hooks/README.md`` for more details.
|
|
|
|
|
|
|
|
|
|
|
|
Running Tests
|
|
|
|
-------------
|
|
|
|
|
2016-03-15 22:28:08 +08:00
|
|
|
Python Tests
|
|
|
|
^^^^^^^^^^^^
|
|
|
|
|
|
|
|
Install dependencies::
|
|
|
|
|
|
|
|
pip install -e .[test] --user
|
|
|
|
|
|
|
|
To run the Python tests, use::
|
|
|
|
|
|
|
|
nosetests
|
|
|
|
|
|
|
|
If you want coverage statistics as well, you can run::
|
|
|
|
|
|
|
|
nosetests --with-coverage --cover-package=notebook notebook
|
|
|
|
|
2016-03-15 03:21:27 +08:00
|
|
|
JavaScript Tests
|
|
|
|
^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
To run the JavaScript tests, you will need to have PhantomJS and CasperJS
|
|
|
|
installed::
|
|
|
|
|
|
|
|
npm install -g casperjs phantomjs@1.9.18
|
|
|
|
|
|
|
|
Then, to run the JavaScript tests::
|
|
|
|
|
|
|
|
python -m notebook.jstest [group]
|
|
|
|
|
|
|
|
where ``[group]`` is an optional argument that is a path relative to
|
|
|
|
``notebook/tests/``.
|
|
|
|
For example, to run all tests in ``notebook/tests/notebook``::
|
|
|
|
|
|
|
|
python -m notebook.jstest notebook
|
|
|
|
|
|
|
|
or to run just ``notebook/tests/notebook/deletecell.js``::
|
|
|
|
|
|
|
|
python -m notebook.jstest notebook/deletecell.js
|
|
|
|
|
2016-03-25 01:48:23 +08:00
|
|
|
|
2016-03-15 03:21:27 +08:00
|
|
|
Building the Documentation
|
|
|
|
--------------------------
|
|
|
|
|
2016-10-03 02:59:18 +08:00
|
|
|
To build the documentation you'll need `Sphinx <http://www.sphinx-doc.org/>`_,
|
|
|
|
`pandoc <http://pandoc.org/>`_ and a few other packages.
|
2016-03-25 01:48:23 +08:00
|
|
|
|
|
|
|
To install (and activate) a `conda environment`_ named ``notebook_docs``
|
2016-07-05 23:10:52 +08:00
|
|
|
containing all the necessary packages (except pandoc), use::
|
2016-03-25 01:48:23 +08:00
|
|
|
|
2016-03-25 06:13:48 +08:00
|
|
|
conda env create -f docs/environment.yml
|
2016-03-25 01:48:23 +08:00
|
|
|
source activate notebook_docs # Linux and OS X
|
|
|
|
activate notebook_docs # Windows
|
|
|
|
|
|
|
|
.. _conda environment:
|
|
|
|
http://conda.pydata.org/docs/using/envs.html#use-environment-from-file
|
|
|
|
|
2016-03-25 06:13:48 +08:00
|
|
|
If you want to install the necessary packages with ``pip`` instead, use
|
|
|
|
(omitting --user if working in a virtual environment)::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2016-03-25 06:13:48 +08:00
|
|
|
pip install -r docs/doc-requirements.txt --user
|
2016-03-15 03:21:27 +08:00
|
|
|
|
2016-03-25 01:48:23 +08:00
|
|
|
Once you have installed the required packages, you can build the docs with::
|
2016-03-15 03:21:27 +08:00
|
|
|
|
|
|
|
cd docs
|
|
|
|
make html
|
|
|
|
|
2016-03-15 22:15:33 +08:00
|
|
|
After that, the generated HTML files will be available at
|
2016-03-25 06:13:48 +08:00
|
|
|
``build/html/index.html``. You may view the docs in your browser.
|
2016-03-15 22:15:33 +08:00
|
|
|
|
|
|
|
You can automatically check if all hyperlinks are still valid::
|
|
|
|
|
|
|
|
make linkcheck
|
|
|
|
|
2016-03-15 03:21:27 +08:00
|
|
|
Windows users can find ``make.bat`` in the ``docs`` folder.
|
|
|
|
|
|
|
|
You should also have a look at the `Project Jupyter Documentation Guide`__.
|
|
|
|
|
2016-06-08 04:08:58 +08:00
|
|
|
__ https://jupyter.readthedocs.io/en/latest/contrib_docs/index.html
|