Skip to content

Commit c7c73f2

Browse files
committed
create docs page
1 parent 80e3656 commit c7c73f2

11 files changed

+549
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ ipympl/labextension
3232

3333
# OS specific items
3434
.DS_Store
35+
36+
# sphinx build dir
37+
docs/_build

dev-environment.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,14 @@ dependencies:
1313
- flake8
1414
- pytest
1515
- nbval
16+
- pre-commit
1617
- pip:
1718
- build
19+
- myst-nb
20+
- Sphinx >= 1.5
21+
- sphinx-copybutton
22+
- sphinx-panels
23+
- sphinx-thebe
24+
- sphinx-togglebutton
25+
- sphinx-book-them
26+
- sphinx-autobuild

docs/Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?= -T --color
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
22+
watch:
23+
sphinx-autobuild . _build/html --open-browser --watch examples

docs/_static/basic.apng

169 KB
Binary file not shown.

docs/_static/custom.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* Fix numpydoc format delimiters */
2+
.classifier:before {
3+
font-style: normal;
4+
margin: 0.5em;
5+
content: ":";
6+
}
7+
8+
/* override table no-wrap */
9+
.wy-table-responsive table td,
10+
.wy-table-responsive table th {
11+
white-space: normal;
12+
}

docs/conf.py

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
import inspect
10+
11+
# If extensions (or modules to document with autodoc) are in another directory,
12+
# add these directories to sys.path here. If the directory is relative to the
13+
# documentation root, use os.path.abspath to make it absolute, like shown here.
14+
#
15+
import os
16+
import sys
17+
18+
try:
19+
from ipympl import __version__ as release
20+
except ImportError:
21+
release = "unknown"
22+
23+
24+
# -- Project information -----------------------------------------------------
25+
26+
project = "ipympl"
27+
copyright = "2022, Matplotlib Development Team"
28+
author = "Matplotlib Development Team"
29+
30+
31+
# -- General configuration ---------------------------------------------------
32+
33+
# Add any Sphinx extension module names here, as strings. They can be
34+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
35+
# ones.
36+
extensions = [
37+
"jupyter_sphinx",
38+
"myst_nb",
39+
"sphinx.ext.intersphinx",
40+
"sphinx.ext.linkcode",
41+
"sphinx.ext.mathjax",
42+
"sphinx_copybutton",
43+
"sphinx_panels",
44+
"sphinx_thebe",
45+
"sphinx_togglebutton",
46+
]
47+
48+
49+
# Cross-referencing configuration
50+
default_role = "py:obj"
51+
primary_domain = "py"
52+
nitpicky = True # warn if cross-references are missing
53+
54+
# Intersphinx settings
55+
intersphinx_mapping = {
56+
"ipywidgets": ("https://ipywidgets.readthedocs.io/en/stable", None),
57+
"matplotlib": ("https://matplotlib.org/stable", None),
58+
"numpy": ("https://numpy.org/doc/stable", None),
59+
"python": ("https://docs.python.org/3", None),
60+
}
61+
62+
# remove panels css to get wider main content
63+
panels_add_bootstrap_css = False
64+
65+
# Settings for copybutton
66+
copybutton_prompt_is_regexp = True
67+
copybutton_prompt_text = r">>> |\.\.\. " # doctest
68+
69+
# Settings for linkcheck
70+
linkcheck_anchors = False
71+
linkcheck_ignore = [] # type: ignore
72+
73+
execution_timeout = -1
74+
jupyter_execute_notebooks = "off"
75+
if "EXECUTE_NB" in os.environ:
76+
print("\033[93;1mWill run Jupyter notebooks!\033[0m")
77+
jupyter_execute_notebooks = "force"
78+
79+
# Settings for myst-parser
80+
myst_enable_extensions = [
81+
"amsmath",
82+
"colon_fence",
83+
"dollarmath",
84+
"smartquotes",
85+
"substitution",
86+
]
87+
suppress_warnings = [
88+
"myst.header",
89+
]
90+
91+
# Add any paths that contain templates here, relative to this directory.
92+
templates_path = ["_templates"]
93+
94+
# List of patterns, relative to source directory, that match files and
95+
# directories to ignore when looking for source files.
96+
# This pattern also affects html_static_path and html_extra_path.
97+
exclude_patterns = [
98+
"**ipynb_checkpoints",
99+
".DS_Store",
100+
"Thumbs.db",
101+
"_build",
102+
]
103+
104+
105+
# -- Options for HTML output -------------------------------------------------
106+
107+
# The theme to use for HTML and HTML Help pages. See the documentation for
108+
# a list of builtin themes.
109+
#
110+
html_copy_source = True # needed for download notebook button
111+
html_css_files = [
112+
"custom.css",
113+
]
114+
html_sourcelink_suffix = ""
115+
html_static_path = ["_static"]
116+
html_theme = "sphinx_book_theme"
117+
html_theme_options = {
118+
"launch_buttons": {
119+
"binderhub_url": "https://mybinder.org",
120+
"colab_url": "https://colab.research.google.com",
121+
"notebook_interface": "jupyterlab",
122+
"thebe": True,
123+
"thebelab": True,
124+
},
125+
"path_to_docs": "docs",
126+
"repository_branch": "main",
127+
"repository_url": "https://github.com/matplotlib/ipympl",
128+
"use_download_button": True,
129+
"use_edit_page_button": True,
130+
"use_issues_button": True,
131+
"use_repository_button": True,
132+
}
133+
html_title = "ipympl"
134+
135+
master_doc = "index"
136+
thebe_config = {
137+
"repository_url": html_theme_options["repository_url"],
138+
"repository_branch": html_theme_options["repository_branch"],
139+
}
140+
141+
142+
# based on pandas/doc/source/conf.py
143+
def linkcode_resolve(domain, info):
144+
"""
145+
Determine the URL corresponding to Python object
146+
"""
147+
if domain != "py":
148+
return None
149+
150+
modname = info["module"]
151+
fullname = info["fullname"]
152+
153+
submod = sys.modules.get(modname)
154+
if submod is None:
155+
return None
156+
157+
obj = submod
158+
for part in fullname.split("."):
159+
try:
160+
obj = getattr(obj, part)
161+
except AttributeError:
162+
return None
163+
164+
try:
165+
fn = inspect.getsourcefile(inspect.unwrap(obj))
166+
except TypeError:
167+
fn = None
168+
if not fn:
169+
return None
170+
171+
try:
172+
source, lineno = inspect.getsourcelines(obj)
173+
except OSError:
174+
lineno = None
175+
176+
if lineno:
177+
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
178+
else:
179+
linespec = ""
180+
181+
fn = os.path.relpath(fn, start=os.path.dirname("../ipympl"))
182+
183+
return (
184+
f"https://github.com/matplotlib/ipympl/blob/main/ipympl/{fn}{linespec}" # noqa
185+
)

docs/contributing.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Contributing
2+
3+
Thanks for thinking of a way to help improve this library! Remember that contributions come in all shapes and sizes beyond writing bug fixes. Contributing to [documentation](#documentation), opening new [issues](https://github.com/matplotlib/ipympl/issues) for bugs, asking for clarification on things you find unclear, and requesting new features, are all super valuable contributions.
4+
5+
## Code Improvements
6+
7+
All development for this library happens on GitHub [here](https://github.com/matplotlib/ipympl). We recommend you work with a [Conda](https://www.anaconda.com/products/individual) environment (or an alternative virtual environment like [`venv`](https://docs.python.org/3/library/venv.html)).
8+
9+
The below instructions use [Mamba](https://github.com/mamba-org/mamba#the-fast-cross-platform-package-manager) which is a very fast implementation of `conda`.
10+
11+
```bash
12+
git clone <your fork>
13+
cd ipympl
14+
mamba env create --file dev-environment.yml
15+
conda activate ipympl-dev
16+
pre-commit install
17+
```
18+
19+
Install the Python Packge
20+
```bash
21+
pip install -e .
22+
```
23+
24+
When developing your extensions, you need to manually enable your extensions with the
25+
notebook / lab frontend. For lab, this is done by the command:
26+
27+
```bash
28+
jupyter labextension develop --overwrite .
29+
yarn run build
30+
```
31+
32+
For classic notebook, you need to run:
33+
```bash
34+
jupyter nbextension install --py --symlink --sys-prefix --overwrite ipympl
35+
jupyter nbextension enable --py --sys-prefix ipympl
36+
```
37+
38+
39+
40+
### How to see your changes
41+
42+
**Typescript**:
43+
44+
If you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the widget.
45+
46+
```bash
47+
# Watch the source directory in one terminal, automatically rebuilding when needed
48+
yarn run watch
49+
# Run JupyterLab in another terminal
50+
jupyter lab
51+
```
52+
53+
After a change wait for the build to finish and then refresh your browser and the changes should take effect.
54+
55+
**Python:**
56+
57+
If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.
58+
59+
60+
## Documentation
61+
62+
Our documentation on Read the Docs ([mpl-interactions.rtfd.io](https://mpl-interactions.readthedocs.io)) is built with [Sphinx](https://www.sphinx-doc.org) from the notebooks in the `docs` folder. It contains both Markdown files and Jupyter notebooks.
63+
64+
Examples are best written as Jupyter notebooks. To write a new example, create in a notebook in the `docs/examples` directory and list its path under one of the [`toctree`s](https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-toctree) in the `index.ipynb` file. When the docs are generated, they will be rendered as static html pages by [myst-nb](https://myst-nb.readthedocs.io).
65+
66+
If you have installed all developer dependencies (see [above](#contributing)), you can rebuild the docs with the following `make` command run from inside the `docs` folder:
67+
68+
```
69+
make html
70+
```
71+
72+
Then you can open the `_build/index.html` file in your browser you should now be able to see the rendered documentation.
73+
74+
Alternatively, you can use [sphinx-autobuild](https://github.com/executablebooks/sphinx-autobuild) to continuously watch source files for changes and rebuild the documentation for you. Sphinx-autobuild will be installed automatically in the dev environment you created earlier so all you need to do is run
75+
76+
```bash
77+
make watch
78+
```
79+
from inside the `docs` folder
80+
81+
In a few seconds your web browser should open up the documentation. Now whenever you save a file the documentation will automatically regenerate and the webpage will refresh for you!
82+
83+
## Working with Git
84+
85+
Using Git/GitHub can confusing (<https://xkcd.com/1597>), so if you're new to Git, you may find it helpful to use a program like [GitHub Desktop](https://desktop.github.com) and to follow a [guide](https://github.com/firstcontributions/first-contributions#first-contributions).
86+
87+
Also feel free to ask for help/advice on the relevant GitHub [issue](https://github.com/ianhi/mpl-interactions/issues).
88+
89+
90+
## Getting Help contributing
91+
92+
Feel free to ask questions about how to contribute on any Github Issue. You can also ask shorter questions on the [gitter chatroom](https://gitter.im/jupyter-widgets/Lobby).

0 commit comments

Comments
 (0)