Skip to content

Commit 44a4ff2

Browse files
authored
Merge pull request #434 from ianhi/docs
Create docs
2 parents 80e3656 + c3b777b commit 44a4ff2

18 files changed

+1066
-987
lines changed

.github/workflows/docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Docs
2+
3+
on: [push, pull_request]
4+
5+
6+
defaults:
7+
run:
8+
shell: bash -l {0}
9+
jobs:
10+
build:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Setup conda
15+
uses: conda-incubator/setup-miniconda@v2
16+
with:
17+
activate-environment: ipympl-dev
18+
environment-file: dev-environment.yml
19+
python-version: ${{ matrix.python-version }}
20+
mamba-version: "*"
21+
auto-activate-base: false
22+
channels: conda-forge
23+
- name: Install
24+
run: python -m pip install -v .[docs]
25+
- name: Build
26+
run: make -C docs html
27+
- name: Publish
28+
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
29+
uses: peaceiris/actions-gh-pages@v3
30+
with:
31+
github_token: ${{ secrets.GITHUB_TOKEN }}
32+
publish_dir: ./docs/_build/html
33+
force_orphan: true

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ name: Tests
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77
pull_request:
88
branches:
9-
- master
9+
- main
1010

1111
defaults:
1212
run:

.github/workflows/mpl-latest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ on:
55
- cron: "0 12 * * 1" # monday at noon UTC
66
push:
77
branches:
8-
- master
8+
- main
99
pull_request:
1010
branches:
11-
- master
11+
- main
1212

1313
jobs:
1414
run:

.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

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Latest PyPI version](https://img.shields.io/pypi/v/ipympl?logo=pypi)](https://pypi.python.org/pypi/ipympl)
55
[![Latest conda-forge version](https://img.shields.io/conda/vn/conda-forge/ipympl?logo=conda-forge)](https://anaconda.org/conda-forge/ipympl)
66
[![Latest npm version](https://img.shields.io/npm/v/jupyter-matplotlib?logo=npm)](https://www.npmjs.com/package/jupyter-matplotlib)
7-
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/matplotlib/ipympl/stable?urlpath=retro/notebooks/examples/ipympl.ipynb)
7+
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/matplotlib/ipympl/stable?urlpath=retro/notebooks/docs/examples/full-example.ipynb)
88
[![Gitter](https://img.shields.io/badge/gitter-Join_chat-blue?logo=gitter)](https://gitter.im/jupyter-widgets/Lobby)
99

1010
Leveraging the Jupyter interactive widgets framework, `ipympl` enables the interactive features of matplotlib in the Jupyter notebook and in JupyterLab.
@@ -21,7 +21,7 @@ magic:
2121
```
2222

2323
## Example
24-
See the [example notebook](https://github.com/matplotlib/ipympl/blob/master/examples/ipympl.ipynb) for more!
24+
See the [example notebook](https://github.com/matplotlib/ipympl/blob/master/docs/examples/ipympl.ipynb) for more!
2525

2626
![matplotlib screencast](matplotlib.gif)
2727

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-theme
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: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
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+
"myst_nb",
38+
"sphinx.ext.intersphinx",
39+
"sphinx.ext.linkcode",
40+
"sphinx.ext.mathjax",
41+
"sphinx_copybutton",
42+
"sphinx_thebe",
43+
"sphinx_togglebutton",
44+
]
45+
46+
47+
# Cross-referencing configuration
48+
default_role = "py:obj"
49+
primary_domain = "py"
50+
nitpicky = True # warn if cross-references are missing
51+
52+
# Intersphinx settings
53+
intersphinx_mapping = {
54+
"ipywidgets": ("https://ipywidgets.readthedocs.io/en/stable", None),
55+
"matplotlib": ("https://matplotlib.org/stable", None),
56+
"numpy": ("https://numpy.org/doc/stable", None),
57+
"python": ("https://docs.python.org/3", None),
58+
}
59+
60+
61+
# Settings for copybutton
62+
copybutton_prompt_is_regexp = True
63+
copybutton_prompt_text = r">>> |\.\.\. " # doctest
64+
65+
# Settings for linkcheck
66+
linkcheck_anchors = False
67+
linkcheck_ignore = [] # type: ignore
68+
69+
execution_timeout = -1
70+
jupyter_execute_notebooks = "off"
71+
if "EXECUTE_NB" in os.environ:
72+
print("\033[93;1mWill run Jupyter notebooks!\033[0m")
73+
jupyter_execute_notebooks = "force"
74+
75+
# Settings for myst-parser
76+
myst_enable_extensions = [
77+
"amsmath",
78+
"colon_fence",
79+
"dollarmath",
80+
"smartquotes",
81+
"substitution",
82+
]
83+
suppress_warnings = [
84+
"myst.header",
85+
]
86+
87+
# Add any paths that contain templates here, relative to this directory.
88+
templates_path = ["_templates"]
89+
90+
# List of patterns, relative to source directory, that match files and
91+
# directories to ignore when looking for source files.
92+
# This pattern also affects html_static_path and html_extra_path.
93+
exclude_patterns = [
94+
"**ipynb_checkpoints",
95+
".DS_Store",
96+
"Thumbs.db",
97+
"_build",
98+
]
99+
100+
101+
# -- Options for HTML output -------------------------------------------------
102+
103+
# The theme to use for HTML and HTML Help pages. See the documentation for
104+
# a list of builtin themes.
105+
#
106+
html_copy_source = True # needed for download notebook button
107+
html_css_files = [
108+
"custom.css",
109+
]
110+
html_sourcelink_suffix = ""
111+
html_static_path = ["_static"]
112+
html_theme = "sphinx_book_theme"
113+
html_theme_options = {
114+
"launch_buttons": {
115+
"binderhub_url": "https://mybinder.org",
116+
"colab_url": "https://colab.research.google.com",
117+
"notebook_interface": "jupyterlab",
118+
"thebe": True,
119+
"thebelab": True,
120+
},
121+
"path_to_docs": "docs",
122+
"repository_branch": "main",
123+
"repository_url": "https://github.com/matplotlib/ipympl",
124+
"use_download_button": True,
125+
"use_edit_page_button": True,
126+
"use_issues_button": True,
127+
"use_repository_button": True,
128+
}
129+
html_title = "ipympl"
130+
131+
master_doc = "index"
132+
thebe_config = {
133+
"repository_url": html_theme_options["repository_url"],
134+
"repository_branch": html_theme_options["repository_branch"],
135+
}
136+
137+
138+
# based on pandas/doc/source/conf.py
139+
def linkcode_resolve(domain, info):
140+
"""
141+
Determine the URL corresponding to Python object
142+
"""
143+
if domain != "py":
144+
return None
145+
146+
modname = info["module"]
147+
fullname = info["fullname"]
148+
149+
submod = sys.modules.get(modname)
150+
if submod is None:
151+
return None
152+
153+
obj = submod
154+
for part in fullname.split("."):
155+
try:
156+
obj = getattr(obj, part)
157+
except AttributeError:
158+
return None
159+
160+
try:
161+
fn = inspect.getsourcefile(inspect.unwrap(obj))
162+
except TypeError:
163+
fn = None
164+
if not fn:
165+
return None
166+
167+
try:
168+
source, lineno = inspect.getsourcelines(obj)
169+
except OSError:
170+
lineno = None
171+
172+
if lineno:
173+
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
174+
else:
175+
linespec = ""
176+
177+
fn = os.path.relpath(fn, start=os.path.dirname("../ipympl"))
178+
179+
return (
180+
f"https://github.com/matplotlib/ipympl/blob/main/ipympl/{fn}{linespec}" # noqa
181+
)

0 commit comments

Comments
 (0)