diff --git a/README.md b/README.md index 5acbeda..39c1f36 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,14 @@ You can install using pip: `pip install handcalcs` +To install the optional nbconvert "no input" exporters, use: + +`pip install "handcalcs[exporters]"` + +**NEW** + +As of v1.9.0, handcalcs no longer installs the "no input" nbconvert exporters. This was done to lighten the installation load of handcalcs and to ensure the package has appropriate scope. The nbconvert exporters are now "out of scope" and are separately maintained at [https://github.com/connorferster/nb-hideinputs](nb-hideinputs). + ## Basic Usage 1: As a Jupyter cell magic (`%%render`) `handcalcs` is intended to be used with either Jupyter Notebook or Jupyter Lab as a _cell magic_. diff --git a/handcalcs/exporters.py b/handcalcs/exporters.py deleted file mode 100644 index 5452727..0000000 --- a/handcalcs/exporters.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2020 Connor Ferster - -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at - -# http://www.apache.org/licenses/LICENSE-2.0 - -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from nbconvert import PDFExporter, HTMLExporter, LatexExporter -from copy import deepcopy - - -class HTMLHideInputExporter(HTMLExporter): - """ - Exports HTML documents without input cells. - """ - - export_from_notebook = "HTML Hide Input" - - exclude_input = deepcopy(HTMLExporter.exclude_input) - exclude_input.default_value = True - - -class PDFHideInputExporter(PDFExporter): - """ - Exports PDF documents without input cells. - """ - - export_from_notebook = "PDF Hide Input" - exclude_input = deepcopy(PDFExporter.exclude_input) - exclude_input.default_value = True - - -class LatexHideInputExporter(LatexExporter): - """ - Exports LaTeX documents without input cells. - """ - - export_from_notebook = "LaTeX Hide Input" - exclude_input = deepcopy(LatexExporter.exclude_input) - exclude_input.default_value = True diff --git a/pyproject.toml b/pyproject.toml index 13619ca..a06e70a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,6 @@ classifiers = ["License :: OSI Approved :: Apache Software License"] dynamic = ["version", "description"] dependencies = [ "more_itertools", - "nbconvert >= 7.0.0", "innerscope >= 0.7.0", "pyparsing" ] @@ -22,27 +21,28 @@ Source = "https://github.com/connorferster/handcalcs" [project.optional-dependencies] +exporters = [ + "nb-hideinputs", +] + test = [ "pytest >= 8.0.0", "pytest-cov >= 4.1.0", "coverage[toml] >= 5.5.0", "pint >= 0.23", + "sympy", ] dev = [ "jupyterlab >= 4.0.0", - "sympy", "forallpeople >= 2.0", - "black" + "black", + "pint >= 0.23", + "sympy", ] doc = ["sphinx"] -[project.entry-points."nbconvert.exporters"] -HTML_NoInput = 'handcalcs.exporters:HTMLHideInputExporter' -PDF_NoInput = 'handcalcs.exporters:PDFHideInputExporter' -LaTeX_NoInput = 'handcalcs.exporters:LatexHideInputExporter' - [tool.coverage.paths] source = ['handcalcs', '*/site-packages'] diff --git a/test_handcalcs/test_handcalcs_file.py b/test_handcalcs/test_handcalcs_file.py index da855eb..decd3b1 100644 --- a/test_handcalcs/test_handcalcs_file.py +++ b/test_handcalcs/test_handcalcs_file.py @@ -16,17 +16,8 @@ import inspect from collections import deque -from handcalcs.exporters import ( - LatexHideInputExporter, - HTMLHideInputExporter, - PDFHideInputExporter, -) - import handcalcs -import pathlib import pytest -import nbconvert -import filecmp import forallpeople as si @@ -353,30 +344,6 @@ def test_handcalcs3(): assert func_3(4, 5) == {"x": 4, "y": 5, "a": 8, "b": 29} -# Test template.py - - -def test_latex_exporter(): - exporter = LatexHideInputExporter() - assert exporter.exclude_input == True - parent = exporter.__class__.__bases__[0]() - assert parent.exclude_input == False - - -def test_pdf_exporter(): - exporter = PDFHideInputExporter() - assert exporter.exclude_input == True - parent = exporter.__class__.__bases__[0]() - assert parent.exclude_input == False - - -def test_html_exporter(): - exporter = HTMLHideInputExporter() - assert exporter.exclude_input == True - parent = exporter.__class__.__bases__[0]() - assert parent.exclude_input == False - - # Test expected exceptions diff --git a/test_handcalcs/test_render_file.py b/test_handcalcs/test_render_file.py index e8d9407..22b2190 100644 --- a/test_handcalcs/test_render_file.py +++ b/test_handcalcs/test_render_file.py @@ -1,15 +1,8 @@ -import inspect -from collections import deque import handcalcs -import pathlib import pytest -import nbconvert -import filecmp from IPython.testing.globalipapp import start_ipython -from IPython.utils.io import capture_output -from IPython.display import Latex @pytest.fixture(scope="session") diff --git a/test_handcalcs/test_sympy_kit.py b/test_handcalcs/test_sympy_kit.py index a2fe0ac..325b266 100644 --- a/test_handcalcs/test_sympy_kit.py +++ b/test_handcalcs/test_sympy_kit.py @@ -1,12 +1,7 @@ -import inspect -from collections import deque from handcalcs.handcalcs import CalcLine, round_and_render_line_objects_to_latex import handcalcs.sympy_kit as sk import handcalcs.global_config -import pathlib import pytest -import nbconvert -import filecmp import sympy as sp a, b = sp.symbols("a b")