Skip to content

Commit

Permalink
feat: add matplotlib notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreCameron committed May 8, 2020
1 parent 2988f39 commit 7e1948a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 54 deletions.
56 changes: 28 additions & 28 deletions docs/conf.py
Expand Up @@ -23,7 +23,7 @@
from pathlib import Path
import m2r

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))

from version import VERSION, RELEASE # noqa

Expand Down Expand Up @@ -73,39 +73,39 @@ def export_md_in_rst(frad, export_subdir="docs"):

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# needs_sphinx = "1.0"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'readthedocs_ext.readthedocs',
'recommonmark',
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"readthedocs_ext.readthedocs",
"recommonmark",
]

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

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
# source_suffix = [".rst", ".md"]
source_suffix = {
'.rst': 'restructuredtext',
'.txt': 'markdown',
'.md': 'markdown',
".rst": "restructuredtext",
".txt": "markdown",
".md": "markdown",
}

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# General information about the project.
project = 'boar'
copyright = 'Alexandre Cameron'
author = 'Alexandre Cameron'
project = "boar"
copyright = "Alexandre Cameron"
author = "Alexandre Cameron"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand All @@ -126,10 +126,10 @@ def export_md_in_rst(frad, export_subdir="docs"):
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['.build', 'Thumbs.db', '.DS_Store']
exclude_patterns = [".build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False
Expand All @@ -140,7 +140,7 @@ def export_md_in_rst(frad, export_subdir="docs"):
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -151,32 +151,32 @@ def export_md_in_rst(frad, export_subdir="docs"):
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['.static']
html_static_path = [".static"]

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
"**": [
"relations.html", # needs "show_related": True theme option to display
"searchbox.html",
]
}


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'boardoc'
htmlhelp_basename = "boardoc"

# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'boar', 'boar documentation', [author], 1)
(master_doc, "boar", "boar documentation", [author], 1)
]


Expand All @@ -186,6 +186,6 @@ def export_md_in_rst(frad, export_subdir="docs"):
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'boar', 'boar documentation',
author, 'boar', 'One line description of project.'),
(master_doc, "boar", "boar documentation",
author, "boar", "One line description of project."),
]
12 changes: 12 additions & 0 deletions notebook/00-test/Matplotlib.ipynb
Expand Up @@ -7,6 +7,18 @@
"# Matplotlib graph"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pip\n",
"\n",
"pip.main([\"install\", \"numpy\"])\n",
"pip.main([\"install\", \"matplotlib\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
6 changes: 3 additions & 3 deletions tests/test_linting_e2e.py
Expand Up @@ -12,9 +12,9 @@
@pytest.mark.parametrize("notebook_path,expected_incorrect_lint_files", [
(Path(Notebook._02.value, "0-execution.ipynb"), []),
(Notebook._02.value, [
'notebook/02-lint/1-execution.ipynb',
'notebook/02-lint/level-1/one-execution.ipynb',
'notebook/02-lint/unstructured-executions.ipynb',
"notebook/02-lint/1-execution.ipynb",
"notebook/02-lint/level-1/one-execution.ipynb",
"notebook/02-lint/unstructured-executions.ipynb",
]),
(Notebook._00.value, [])
])
Expand Down
1 change: 1 addition & 0 deletions tests/test_testing_e2e.py
Expand Up @@ -5,6 +5,7 @@
from boar.__init__ import Notebook


@pytest.mark.filterwarnings("ignore::DeprecationWarning")
@pytest.mark.e2e
@pytest.mark.parametrize("notebook_name", [
"OK.ipynb",
Expand Down
46 changes: 23 additions & 23 deletions tests/utils/test_parse.py
Expand Up @@ -131,31 +131,31 @@ def test_remove_output_returns_correct_values(
file_path = Path(Notebook._02.value, "0-execution.ipynb")
inline = False
cells = [
{'cell_type': 'code', 'execution_count': None, 'metadata': {},
'outputs': [], 'source': ['a = 1\n', 'print(a)']},
{'cell_type': 'markdown', 'metadata': {}, 'source': ['---']}]
{"cell_type": "code", "execution_count": None, "metadata": {},
"outputs": [], "source": ["a = 1\n", "print(a)"]},
{"cell_type": "markdown", "metadata": {}, "source": ["---"]}]
cleaned_cells = [
{'cell_type': 'code', 'metadata': {},
'source': ['a = 1\n', 'print(a)'], 'execution_count': None, 'outputs': []},
{'cell_type': 'markdown', 'metadata': {}, 'source': ['---']}]
{"cell_type": "code", "metadata": {},
"source": ["a = 1\n", "print(a)"], "execution_count": None, "outputs": []},
{"cell_type": "markdown", "metadata": {}, "source": ["---"]}]
not_cells = {
'metadata': {
'kernelspec': {
'display_name': 'Python 3', 'language': 'python', 'name': 'python3'},
'language_info': {
'codemirror_mode': {'name': 'ipython', 'version': 3},
'file_extension': '.py',
'mimetype': 'text/x-python',
'name': 'python',
'nbconvert_exporter': 'python',
'pygments_lexer': 'ipython3',
'version': '3.8.0'}
"metadata": {
"kernelspec": {
"display_name": "Python 3", "language": "python", "name": "python3"},
"language_info": {
"codemirror_mode": {"name": "ipython", "version": 3},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"}
},
'nbformat': 4,
'nbformat_minor': 4
"nbformat": 4,
"nbformat_minor": 4

}
expected_cleaned_content = {'cells': cleaned_cells, **not_cells}
expected_cleaned_content = {"cells": cleaned_cells, **not_cells}

# Thus
mock_manager = Mock()
Expand All @@ -178,9 +178,9 @@ def test_remove_output_returns_correct_values(
@pytest.mark.parametrize("cell,expected_cleaned_cell", [
({"cell_type": "not_code"}, {"cell_type": "not_code"}),
({"cell_type": "code"},
{"cell_type": "code", 'execution_count': None, 'outputs': []}),
({"cell_type": "code", 'execution_count': 1, 'outputs': ["a"]},
{"cell_type": "code", 'execution_count': None, 'outputs': []}),
{"cell_type": "code", "execution_count": None, "outputs": []}),
({"cell_type": "code", "execution_count": 1, "outputs": ["a"]},
{"cell_type": "code", "execution_count": None, "outputs": []}),
])
def test_clean_cell_returns_correct_values(
cell: dict,
Expand Down

0 comments on commit 7e1948a

Please sign in to comment.