Repository: duecredit/duecredit

Issue:
Make `DueSwitch._dump_collector_summary` public?
I am very new to this library, so there may be good reasons to avoid this. However, from my perspective, it seems natural to have `DueSwitch._dump_collector_summary` as a public function (perhaps exposed as `DueSwitch.due_summary` or something) to make using duecredit with standalone jupyter notebooks a little more self-contained. I am thinking along the lines of:

    # near top of notebook
    import os
    os.environ['DUECREDIT_ENABLE'] = 'yes'

    # body of notebook
    import fancymodule as fm
    fm.do_stuff()

    # section at the end
    fm.due._dump_collector_summary()

This way one doesn't have to deal with external files keeping track of citations, possibly being added to by other notebooks which could possibly be undesirable.



Discussion:

Patch:
diff --git a/duecredit/dueswitch.py b/duecredit/dueswitch.py
index 07ea589..1f76fb1 100644
--- a/duecredit/dueswitch.py
+++ b/duecredit/dueswitch.py
@@ -69,16 +69,23 @@ class DueSwitch(object):
         return self.__active
 
     @never_fail
-    def _dump_collector_summary(self):
+    def dump(self, **kwargs):
+        """Dumps summary of the citations
+
+        Parameters
+        ----------
+        **kwargs: dict
+           Passed to `CollectorSummary` constructor.
+        """
         from duecredit.collector import CollectorSummary
-        due_summary = CollectorSummary(self.__collectors[True])
+        due_summary = CollectorSummary(self.__collectors[True], **kwargs)
         due_summary.dump()
 
     def __prepare_exit_and_injections(self):
         # Wrapper to create and dump summary... passing method doesn't work:
         #  probably removes instance too early
 
-        atexit.register(self._dump_collector_summary)
+        atexit.register(self.dump)
 
         # Deal with injector
         from .injections import DueCreditInjector
@@ -93,7 +100,7 @@ class DueSwitch(object):
             is_public = lambda x: not x.startswith('_')
             # Clean up current bindings first
             for k in filter(is_public, dir(self)):
-                if k not in ('activate', 'active'):
+                if k not in ('activate', 'active', 'dump'):
                     delattr(self, k)
 
             new_due = self.__collectors[activate]


Test patch:
diff --git a/duecredit/tests/test_dueswitch.py b/duecredit/tests/test_dueswitch.py
index 6a1b826..c1d664d 100644
--- a/duecredit/tests/test_dueswitch.py
+++ b/duecredit/tests/test_dueswitch.py
@@ -38,4 +38,4 @@ def test_dueswitch_activate(monkeypatch):
     # was not active, so should have called activate of the injector class
     assert state["activate"] == 1
     assert state["register"] == 1
-    assert state["register_func"] == due._dump_collector_summary
+    assert state["register_func"] == due.dump