Skip to content

Commit 46df250

Browse files
authored
Merge pull request #99 from datalayer-externals/ci/docs
2 parents 89b046a + 4ee16e0 commit 46df250

File tree

2 files changed

+198
-1
lines changed

2 files changed

+198
-1
lines changed

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ jobs:
4848
run: |
4949
EXIT_STATUS=0
5050
make -C docs/ html || EXIT_STATUS=$?
51-
pytest --nbval --current-env docs || EXIT_STATUS=$?
51+
cd docs/source && pytest --nbval --current-env .. || EXIT_STATUS=$?
5252
exit $EXIT_STATUS

CONTRIBUTING.rst

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
Contributing to the Jupyter NbClassic
2+
=====================================
3+
4+
If you're reading this section, you're probably interested in contributing to
5+
Jupyter. Welcome and thanks for your interest in contributing!
6+
7+
Please take a look at the Contributor documentation, familiarize yourself with
8+
using the Jupyter NbClassic, and introduce yourself on the mailing list and
9+
share what area of the project you are interested in working on.
10+
11+
General Guidelines
12+
------------------
13+
14+
For general documentation about contributing to Jupyter projects, see the
15+
`Project Jupyter Contributor Documentation`__.
16+
17+
__ https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html
18+
19+
20+
Setting Up a Development Environment
21+
------------------------------------
22+
23+
Installing Node.js and npm
24+
^^^^^^^^^^^^^^^^^^^^^^^^^^
25+
26+
Building the NbClassic from its GitHub source code requires some tools to
27+
create and minify JavaScript components and the CSS,
28+
specifically Node.js and Node's package manager, ``npm``.
29+
It should be node version ≥ 6.0.
30+
31+
If you use ``conda``, you can get them with::
32+
33+
conda install -c conda-forge nodejs
34+
35+
If you use `Homebrew <https://brew.sh/>`_ on Mac OS X::
36+
37+
brew install node
38+
39+
Installation on Linux may vary, but be aware that the `nodejs` or `npm` packages
40+
included in the system package repository may be too old to work properly.
41+
42+
You can also use the installer from the `Node.js website <https://nodejs.org>`_.
43+
44+
45+
Installing the Jupyter NbClassic
46+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47+
48+
Once you have installed the dependencies mentioned above, use the following
49+
steps::
50+
51+
pip install --upgrade setuptools pip
52+
git clone https://github.com/jupyter/nbclassic
53+
cd nbclassic
54+
pip install -e .
55+
56+
If you are using a system-wide Python installation and you only want to install NbClassic for you,
57+
you can add ``--user`` to the install commands.
58+
59+
Once you have done this, you can launch the main branch of Jupyter NbClassic
60+
from any directory in your system with::
61+
62+
jupyter nbclassic
63+
64+
Verification
65+
^^^^^^^^^^^^
66+
67+
While running NbClassic, select one of your notebook files (the file will have the extension ``.ipynb``).
68+
In the top tab you will click on "Help" and then click on "About". In the pop window you will see information about the version of Jupyter that you are running. You will see "The version of the notebook server is:".
69+
If you are working in development mode, you will see that your version of Jupyter NbClassic will include the word "dev". If it does not include the word "dev", you are currently not working in development mode and should follow the steps below to uninstall and reinstall Jupyter.
70+
71+
Troubleshooting the Installation
72+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
73+
74+
If you do not see that your Jupyter NbClassic is not running on dev mode, it's possible that you are
75+
running other instances of Jupyter NbClassic. You can try the following steps:
76+
77+
1. Uninstall all instances of the NbClassic package. These include any installations you made using
78+
pip or conda.
79+
2. Run ``python3 -m pip install -e .`` in the NbClassic repository to install NbClassic from there.
80+
3. Run ``npm run build`` to make sure the Javascript and CSS are updated and compiled.
81+
4. Launch with ``python3 -m nbclassic --port 8989``, and check that the browser is pointing to ``localhost:8989``
82+
(rather than the default 8888). You don't necessarily have to launch with port 8989, as long as you use
83+
a port that is neither the default nor in use, then it should be fine.
84+
5. Verify the installation with the steps in the previous section.
85+
86+
87+
Rebuilding JavaScript and CSS
88+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89+
90+
There is a build step for the JavaScript and CSS in the nbclassic.
91+
To make sure that you are working with up-to-date code, you will need to run
92+
this command whenever there are changes to JavaScript or LESS sources::
93+
94+
npm run build
95+
96+
**IMPORTANT:** Don't forget to run ``npm run build`` after switching branches.
97+
When switching between branches of different versions (e.g. ``4.x`` and
98+
``main``), run ``pip install -e .``. If you have tried the above and still
99+
find that NbClassic is not reflecting the current source code, try cleaning
100+
the repo with ``git clean -xfd`` and reinstalling with ``pip install -e .``.
101+
102+
Development Tip
103+
"""""""""""""""
104+
105+
When doing development, you can use this command to automatically rebuild
106+
JavaScript and LESS sources as they are modified::
107+
108+
npm run build:watch
109+
110+
Git Hooks
111+
"""""""""
112+
113+
If you want to automatically update dependencies and recompile JavaScript and
114+
CSS after checking out a new commit, you can install post-checkout and
115+
post-merge hooks which will do it for you::
116+
117+
git-hooks/install-hooks.sh
118+
119+
See ``git-hooks/README.md`` for more details.
120+
121+
122+
Running Tests
123+
-------------
124+
125+
Python Tests
126+
^^^^^^^^^^^^
127+
128+
Install dependencies::
129+
130+
pip install -e '.[test]'
131+
132+
To run the Python tests, use::
133+
134+
pytest
135+
136+
If you want coverage statistics as well, you can run::
137+
138+
py.test --cov nbclassic -v --pyargs nbclassic
139+
140+
JavaScript Tests
141+
^^^^^^^^^^^^^^^^
142+
143+
To run the JavaScript tests, you will need to have PhantomJS and CasperJS
144+
installed::
145+
146+
npm install -g casperjs phantomjs-prebuilt
147+
148+
Then, to run the JavaScript tests::
149+
150+
python -m nbclassic.jstest [group]
151+
152+
where ``[group]`` is an optional argument that is a path relative to
153+
``nbclassic/tests/``.
154+
For example, to run all tests in ``nbclassic/tests/notebook``::
155+
156+
python -m nbclassic.jstest notebook
157+
158+
or to run just ``nbclassic/tests/notebook/deletecell.js``::
159+
160+
python -m nbclassic.jstest notebook/deletecell.js
161+
162+
163+
Building the Documentation
164+
--------------------------
165+
166+
To build the documentation you'll need `Sphinx <http://www.sphinx-doc.org/>`_,
167+
`pandoc <http://pandoc.org/>`_ and a few other packages.
168+
169+
To install (and activate) a conda environment named ``nbclassic_docs``
170+
containing all the necessary packages (except pandoc), use::
171+
172+
conda create -n nbclassic_docs pip
173+
conda activate nbclassic_docs # Linux and OS X
174+
activate nbclassic_docs # Windows
175+
pip install .[docs]
176+
177+
If you want to install the necessary packages with ``pip``, use the following instead::
178+
179+
pip install .[docs]
180+
181+
Once you have installed the required packages, you can build the docs with::
182+
183+
cd docs
184+
make html
185+
186+
After that, the generated HTML files will be available at
187+
``build/html/index.html``. You may view the docs in your browser.
188+
189+
You can automatically check if all hyperlinks are still valid::
190+
191+
make linkcheck
192+
193+
Windows users can find ``make.bat`` in the ``docs`` folder.
194+
195+
You should also have a look at the `Project Jupyter Documentation Guide`__.
196+
197+
__ https://jupyter.readthedocs.io/en/latest/contributing/docs-contributions/index.html

0 commit comments

Comments
 (0)