Skip to content

Commit

Permalink
Merge pull request #434 from ianhi/docs
Browse files Browse the repository at this point in the history
Create docs
  • Loading branch information
ianhi authored Mar 26, 2022
2 parents 80e3656 + c3b777b commit 44a4ff2
Show file tree
Hide file tree
Showing 18 changed files with 1,066 additions and 987 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Docs

on: [push, pull_request]


defaults:
run:
shell: bash -l {0}
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: Setup conda
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: ipympl-dev
environment-file: dev-environment.yml
python-version: ${{ matrix.python-version }}
mamba-version: "*"
auto-activate-base: false
channels: conda-forge
- name: Install
run: python -m pip install -v .[docs]
- name: Build
run: make -C docs html
- name: Publish
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
force_orphan: true
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: Tests
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

defaults:
run:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mpl-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
- cron: "0 12 * * 1" # monday at noon UTC
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
run:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ ipympl/labextension

# OS specific items
.DS_Store

# sphinx build dir
docs/_build
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Latest PyPI version](https://img.shields.io/pypi/v/ipympl?logo=pypi)](https://pypi.python.org/pypi/ipympl)
[![Latest conda-forge version](https://img.shields.io/conda/vn/conda-forge/ipympl?logo=conda-forge)](https://anaconda.org/conda-forge/ipympl)
[![Latest npm version](https://img.shields.io/npm/v/jupyter-matplotlib?logo=npm)](https://www.npmjs.com/package/jupyter-matplotlib)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/matplotlib/ipympl/stable?urlpath=retro/notebooks/examples/ipympl.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/matplotlib/ipympl/stable?urlpath=retro/notebooks/docs/examples/full-example.ipynb)
[![Gitter](https://img.shields.io/badge/gitter-Join_chat-blue?logo=gitter)](https://gitter.im/jupyter-widgets/Lobby)

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

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

![matplotlib screencast](matplotlib.gif)

Expand Down
9 changes: 9 additions & 0 deletions dev-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,14 @@ dependencies:
- flake8
- pytest
- nbval
- pre-commit
- pip:
- build
- myst-nb
- Sphinx >= 1.5
- sphinx-copybutton
- sphinx-panels
- sphinx-thebe
- sphinx-togglebutton
- sphinx-book-theme
- sphinx-autobuild
23 changes: 23 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -T --color
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

watch:
sphinx-autobuild . _build/html --open-browser --watch examples
Binary file added docs/_static/basic.apng
Binary file not shown.
12 changes: 12 additions & 0 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/* Fix numpydoc format delimiters */
.classifier:before {
font-style: normal;
margin: 0.5em;
content: ":";
}

/* override table no-wrap */
.wy-table-responsive table td,
.wy-table-responsive table th {
white-space: normal;
}
181 changes: 181 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

import inspect

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

try:
from ipympl import __version__ as release
except ImportError:
release = "unknown"


# -- Project information -----------------------------------------------------

project = "ipympl"
copyright = "2022, Matplotlib Development Team"
author = "Matplotlib Development Team"


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"myst_nb",
"sphinx.ext.intersphinx",
"sphinx.ext.linkcode",
"sphinx.ext.mathjax",
"sphinx_copybutton",
"sphinx_thebe",
"sphinx_togglebutton",
]


# Cross-referencing configuration
default_role = "py:obj"
primary_domain = "py"
nitpicky = True # warn if cross-references are missing

# Intersphinx settings
intersphinx_mapping = {
"ipywidgets": ("https://ipywidgets.readthedocs.io/en/stable", None),
"matplotlib": ("https://matplotlib.org/stable", None),
"numpy": ("https://numpy.org/doc/stable", None),
"python": ("https://docs.python.org/3", None),
}


# Settings for copybutton
copybutton_prompt_is_regexp = True
copybutton_prompt_text = r">>> |\.\.\. " # doctest

# Settings for linkcheck
linkcheck_anchors = False
linkcheck_ignore = [] # type: ignore

execution_timeout = -1
jupyter_execute_notebooks = "off"
if "EXECUTE_NB" in os.environ:
print("\033[93;1mWill run Jupyter notebooks!\033[0m")
jupyter_execute_notebooks = "force"

# Settings for myst-parser
myst_enable_extensions = [
"amsmath",
"colon_fence",
"dollarmath",
"smartquotes",
"substitution",
]
suppress_warnings = [
"myst.header",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
"**ipynb_checkpoints",
".DS_Store",
"Thumbs.db",
"_build",
]


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_copy_source = True # needed for download notebook button
html_css_files = [
"custom.css",
]
html_sourcelink_suffix = ""
html_static_path = ["_static"]
html_theme = "sphinx_book_theme"
html_theme_options = {
"launch_buttons": {
"binderhub_url": "https://mybinder.org",
"colab_url": "https://colab.research.google.com",
"notebook_interface": "jupyterlab",
"thebe": True,
"thebelab": True,
},
"path_to_docs": "docs",
"repository_branch": "main",
"repository_url": "https://github.com/matplotlib/ipympl",
"use_download_button": True,
"use_edit_page_button": True,
"use_issues_button": True,
"use_repository_button": True,
}
html_title = "ipympl"

master_doc = "index"
thebe_config = {
"repository_url": html_theme_options["repository_url"],
"repository_branch": html_theme_options["repository_branch"],
}


# based on pandas/doc/source/conf.py
def linkcode_resolve(domain, info):
"""
Determine the URL corresponding to Python object
"""
if domain != "py":
return None

modname = info["module"]
fullname = info["fullname"]

submod = sys.modules.get(modname)
if submod is None:
return None

obj = submod
for part in fullname.split("."):
try:
obj = getattr(obj, part)
except AttributeError:
return None

try:
fn = inspect.getsourcefile(inspect.unwrap(obj))
except TypeError:
fn = None
if not fn:
return None

try:
source, lineno = inspect.getsourcelines(obj)
except OSError:
lineno = None

if lineno:
linespec = f"#L{lineno}-L{lineno + len(source) - 1}"
else:
linespec = ""

fn = os.path.relpath(fn, start=os.path.dirname("../ipympl"))

return (
f"https://github.com/matplotlib/ipympl/blob/main/ipympl/{fn}{linespec}" # noqa
)
Loading

0 comments on commit 44a4ff2

Please sign in to comment.