Repository: connorferster/handcalcs (language: python)

Issue:
nbconvert exports always missing input
When handcalcs is installed, exporting HTML/LaTeX/PDF with jupyterlab 3 or nbconvert 6 always excludes input. That is, PDF and PDF_noinput do the same thing.

The external exporter introduced in #81 and #84 (which is otherwise awesome, thank you @JimZwartveld) overrides the `exclude_input.default_value` on the parent class. PR coming up.


Discussion / hints:

Fix patch:
diff --git a/handcalcs/exporters.py b/handcalcs/exporters.py
index 6cbcafc..0964b06 100644
--- a/handcalcs/exporters.py
+++ b/handcalcs/exporters.py
@@ -1,3 +1,5 @@
+from copy import copy
+
 from nbconvert import PDFExporter, HTMLExporter, LatexExporter
 
 
@@ -7,7 +9,7 @@ class HTMLHideInputExporter(HTMLExporter):
     """
 
     export_from_notebook = "HTML Hide Input"
-    exclude_input = HTMLExporter.exclude_input
+    exclude_input = copy(HTMLExporter.exclude_input)
     exclude_input.default_value = True
 
 
@@ -17,7 +19,7 @@ class PDFHideInputExporter(PDFExporter):
     """
 
     export_from_notebook = "PDF Hide Input"
-    exclude_input = PDFExporter.exclude_input
+    exclude_input = copy(PDFExporter.exclude_input)
     exclude_input.default_value = True
 
 
@@ -27,5 +29,5 @@ class LatexHideInputExporter(LatexExporter):
     """
 
     export_from_notebook = "LaTeX Hide Input"
-    exclude_input = LatexExporter.exclude_input
-    exclude_input.default_value = True
\ No newline at end of file
+    exclude_input = copy(LatexExporter.exclude_input)
+    exclude_input.default_value = True


Test patch:
diff --git a/test_handcalcs/test_handcalcs_file.py b/test_handcalcs/test_handcalcs_file.py
index 77e9936..6530c06 100644
--- a/test_handcalcs/test_handcalcs_file.py
+++ b/test_handcalcs/test_handcalcs_file.py
@@ -282,16 +282,22 @@ def test_handcalcs3():
 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