##// END OF EJS Templates
Removed ActivatableTransformer and moved enabled key into base.
Jonathan Frederic -
Show More
@@ -1,5 +1,4 b''
1 # Class base Transformers
1 # Class base Transformers
2 from .activatable import ActivatableTransformer
3 from .base import ConfigurableTransformer
2 from .base import ConfigurableTransformer
4 from .convertfigures import ConvertFiguresTransformer
3 from .convertfigures import ConvertFiguresTransformer
5 from .svg2pdf import Svg2PdfTransformer
4 from .svg2pdf import Svg2PdfTransformer
@@ -17,6 +17,7 b' It exposes a convenient class to inherit from to access configurability.'
17 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
18
18
19 from ..utils.config import GlobalConfigurable
19 from ..utils.config import GlobalConfigurable
20 from IPython.utils.traitlets import Bool
20
21
21 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
22 # Classes and Functions
23 # Classes and Functions
@@ -33,6 +34,9 b' class ConfigurableTransformer(GlobalConfigurable):'
33
34
34 you can overwrite transform_cell to apply a transformation independently on each cell
35 you can overwrite transform_cell to apply a transformation independently on each cell
35 or __call__ if you prefer your own logic. See corresponding docstring for informations.
36 or __call__ if you prefer your own logic. See corresponding docstring for informations.
37
38 Disabled by default and can be enabled via the config by
39 'c.YourTransformerName.enabled = True'
36 """
40 """
37
41
38 enabled = Bool(False, config=True)
42 enabled = Bool(False, config=True)
@@ -53,7 +57,11 b' class ConfigurableTransformer(GlobalConfigurable):'
53
57
54
58
55 def __call__(self, nb, resources):
59 def __call__(self, nb, resources):
60 if self.enabled:
56 return self.call(nb,resources)
61 return self.call(nb,resources)
62 else:
63 return nb, resources
64
57
65
58 def call(self, nb, resources):
66 def call(self, nb, resources):
59 """
67 """
@@ -15,13 +15,13 b' one format to another.'
15 # Imports
15 # Imports
16 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
17
17
18 from .activatable import ActivatableTransformer
18 from .base import ConfigurableTransformer
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Classes
21 # Classes
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24 class ConvertFiguresTransformer(ActivatableTransformer):
24 class ConvertFiguresTransformer(ConfigurableTransformer):
25 """
25 """
26 Converts all of the outputs in a notebook from one format to another.
26 Converts all of the outputs in a notebook from one format to another.
27 """
27 """
@@ -19,7 +19,7 b' from pygments.formatters import HtmlFormatter'
19
19
20 from IPython.utils import path
20 from IPython.utils import path
21
21
22 from .activatable import ActivatableTransformer
22 from .base import ConfigurableTransformer
23
23
24 from IPython.utils.traitlets import Unicode
24 from IPython.utils.traitlets import Unicode
25
25
@@ -27,7 +27,7 b' from IPython.utils.traitlets import Unicode'
27 # Classes and functions
27 # Classes and functions
28 #-----------------------------------------------------------------------------
28 #-----------------------------------------------------------------------------
29
29
30 class CSSHTMLHeaderTransformer(ActivatableTransformer):
30 class CSSHTMLHeaderTransformer(ConfigurableTransformer):
31 """
31 """
32 Transformer used to pre-process notebook for HTML output. Adds IPython notebook
32 Transformer used to pre-process notebook for HTML output. Adds IPython notebook
33 front-end CSS and Pygments CSS to HTML output.
33 front-end CSS and Pygments CSS to HTML output.
@@ -15,13 +15,13 b" notebook file. The extracted figures are returned in the 'resources' dictionary"
15
15
16 import sys
16 import sys
17 from IPython.utils.traitlets import Dict, Unicode
17 from IPython.utils.traitlets import Dict, Unicode
18 from .activatable import ActivatableTransformer
18 from .base import ConfigurableTransformer
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Classes
21 # Classes
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24 class ExtractFigureTransformer(ActivatableTransformer):
24 class ExtractFigureTransformer(ConfigurableTransformer):
25 """
25 """
26 Extracts all of the figures from the notebook file. The extracted
26 Extracts all of the figures from the notebook file. The extracted
27 figures are returned in the 'resources' dictionary.
27 figures are returned in the 'resources' dictionary.
@@ -17,14 +17,14 b' from __future__ import print_function, absolute_import'
17
17
18 # Our own imports
18 # Our own imports
19 # Needed to override transformer
19 # Needed to override transformer
20 from .activatable import (ActivatableTransformer)
20 from .base import (ConfigurableTransformer)
21 from IPython.nbconvert import filters
21 from IPython.nbconvert import filters
22
22
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24 # Classes
24 # Classes
25 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
26
26
27 class LatexTransformer(ActivatableTransformer):
27 class LatexTransformer(ConfigurableTransformer):
28 """
28 """
29 Converter for latex destined documents.
29 Converter for latex destined documents.
30 """
30 """
@@ -33,7 +33,7 b' from pygments.formatters import LatexFormatter'
33 from IPython.utils.traitlets import Unicode, Bool
33 from IPython.utils.traitlets import Unicode, Bool
34
34
35 # Needed to override transformer
35 # Needed to override transformer
36 from .activatable import (ActivatableTransformer) #TODO
36 from .base import (ConfigurableTransformer)
37
37
38 from IPython.nbconvert.utils import console
38 from IPython.nbconvert.utils import console
39
39
@@ -41,7 +41,7 b' from IPython.nbconvert.utils import console'
41 # Classes and functions
41 # Classes and functions
42 #-----------------------------------------------------------------------------
42 #-----------------------------------------------------------------------------
43
43
44 class SphinxTransformer(ActivatableTransformer):
44 class SphinxTransformer(ConfigurableTransformer):
45 """
45 """
46 Sphinx utility transformer.
46 Sphinx utility transformer.
47
47
General Comments 0
You need to be logged in to leave comments. Login now