cheese.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. """
  2. Contains CheesePreprocessor
  3. """
  4. #-----------------------------------------------------------------------------
  5. # Copyright (c) 2013, the IPython Development Team.
  6. #
  7. # Distributed under the terms of the Modified BSD License.
  8. #
  9. # The full license is in the file COPYING.txt, distributed with this software.
  10. #-----------------------------------------------------------------------------
  11. #-----------------------------------------------------------------------------
  12. # Imports
  13. #-----------------------------------------------------------------------------
  14. from ...preprocessors.base import Preprocessor
  15. #-----------------------------------------------------------------------------
  16. # Classes
  17. #-----------------------------------------------------------------------------
  18. class CheesePreprocessor(Preprocessor):
  19. """
  20. Adds a cheese tag to the resources object
  21. """
  22. def __init__(self, **kw):
  23. """
  24. Public constructor
  25. """
  26. super(CheesePreprocessor, self).__init__(**kw)
  27. def preprocess(self, nb, resources):
  28. """
  29. Sphinx preprocessing to apply on each notebook.
  30. Parameters
  31. ----------
  32. nb : NotebookNode
  33. Notebook being converted
  34. resources : dictionary
  35. Additional resources used in the conversion process. Allows
  36. preprocessors to pass variables into the Jinja engine.
  37. """
  38. resources['cheese'] = 'real'
  39. return nb, resources