Skip to content

Commit 5737af9

Browse files
authored
Merge pull request #2 from kevin-bates/add-doc-framework
Introduce documentation framework
2 parents 4ea9edb + c583640 commit 5737af9

File tree

7 files changed

+161
-9
lines changed

7 files changed

+161
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# pytest-jupyter
22

3-
A pytest plugin for testing Jupyter core libraries and extensions.
3+
A set of pytest plugins for Jupyter libraries and extensions.

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 ?=
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)

docs/conf.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
# import os
14+
# import sys
15+
# sys.path.insert(0, os.path.abspath('.'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'pytest-jupyter'
21+
copyright = '2020, Project Jupyter'
22+
author = 'Project Jupyter'
23+
24+
25+
# -- General configuration ---------------------------------------------------
26+
27+
# Add any Sphinx extension module names here, as strings. They can be
28+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29+
# ones.
30+
extensions = [
31+
'myst_parser',
32+
'sphinx.ext.autodoc',
33+
]
34+
35+
# Autodoc fixtures
36+
# If true, the current module name will be prepended to all description
37+
# unit titles (such as .. function::).
38+
add_module_names = False
39+
40+
# Add any paths that contain templates here, relative to this directory.
41+
templates_path = ['_templates']
42+
43+
# List of patterns, relative to source directory, that match files and
44+
# directories to ignore when looking for source files.
45+
# This pattern also affects html_static_path and html_extra_path.
46+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
47+
48+
49+
# -- Options for HTML output -------------------------------------------------
50+
51+
# The theme to use for HTML and HTML Help pages. See the documentation for
52+
# a list of builtin themes.
53+
#
54+
html_theme = 'pydata_sphinx_theme'
55+
56+
# Add any paths that contain custom static files (such as style sheets) here,
57+
# relative to this directory. They are copied after the builtin static files,
58+
# so a file named "default.css" will overwrite the builtin "default.css".
59+
html_static_path = ['_static']

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[build-system]
2+
requires = ["jupyter_packaging~=0.7.5", "setuptools>=40.8.0", "wheel"]
3+
build-backend = "setuptools.build_meta"

pytest_jupyter/jupyter_server.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,20 @@ def jp_configurable_serverapp(
107107
jp_root_dir,
108108
io_loop,
109109
):
110-
"""Starts a Jupyter Server instance based on the provided configuration values."""
110+
"""Starts a Jupyter Server instance based on
111+
the provided configuration values.
112+
113+
The fixture is a factory; it can be called like
114+
a function inside a unit test. Here's a basic
115+
example of how use this fixture:
116+
117+
.. code-block:: python
118+
119+
def my_test(jp_configurable_serverapp):
120+
121+
app = jp_configurable_serverapp(...)
122+
...
123+
"""
111124
ServerApp.clear_instance()
112125

113126
def _configurable_serverapp(
@@ -262,3 +275,4 @@ def inner(nbpath):
262275
nbtext = nbformat.writes(nb, version=4)
263276
nbpath.write_text(nbtext)
264277
return inner
278+

setup.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,42 @@
11

22
import pathlib
33
from setuptools import setup, find_packages
4+
from jupyter_packaging import get_version
45

5-
here = pathlib.Path('.')
6+
NAME = "pytest-jupyter"
7+
PACKAGE_NAME = NAME.replace("-", "_")
8+
DESCRIPTION = "A pytest plugin for testing Jupyter libraries and extensions."
9+
VERSION = get_version(f"{PACKAGE_NAME}/_version.py")
610

7-
readme_path = here.joinpath('README.md')
11+
HERE = pathlib.Path('.')
12+
readme_path = HERE.joinpath('README.md')
813
README = readme_path.read_text()
9-
VERSION = "0.0.1"
1014

11-
setup(
12-
name="pytest-jupyter",
13-
packages=find_packages(),
15+
setup_args = dict(
16+
name=NAME,
1417
version=VERSION,
15-
description="A pytest plugin for testing Jupyter core libraries and extensions.",
18+
description=DESCRIPTION,
1619
long_description=README,
1720
long_description_content_type='text/markdown',
21+
packages=find_packages(),
1822
author='Jupyter Development Team',
1923
author_email='[email protected]',
2024
url='http://jupyter.org',
2125
license='BSD',
2226
platforms="Linux, Mac OS X, Windows",
2327
keywords=['Jupyter', 'pytest'],
28+
install_requires=[
29+
'traitlets',
30+
'tornado',
31+
'pytest',
32+
'nbformat',
33+
'pytest-tornasync',
34+
'jupyter_core',
35+
'jupyter_server'
36+
],
37+
extras_require={
38+
'docs': ['Sphinx', 'myst_parser', 'pydata_sphinx_theme']
39+
},
2440
# the following makes a plugin available to pytest
2541
entry_points={
2642
"pytest11": [
@@ -31,3 +47,8 @@
3147
# custom PyPI classifier for pytest plugins
3248
classifiers=["Framework :: Pytest"],
3349
)
50+
51+
52+
if __name__ == '__main__':
53+
setup(**setup_args)
54+

0 commit comments

Comments
 (0)