##// END OF EJS Templates
Exporter -> TemplateExporter / BaseExporter
Matthias BUSSONNIER -
Show More
@@ -1,7 +1,7 b''
1 from .export import *
1 from .export import *
2 from .html import HTMLExporter
2 from .html import HTMLExporter
3 from .slides import SlidesExporter
3 from .slides import SlidesExporter
4 from .exporter import Exporter
4 from .exporter import TemplateExporter
5 from .latex import LatexExporter
5 from .latex import LatexExporter
6 from .markdown import MarkdownExporter
6 from .markdown import MarkdownExporter
7 from .python import PythonExporter
7 from .python import PythonExporter
@@ -1,4 +1,4 b''
1 """This module defines Exporter, a highly configurable converter
1 """This module defines BaseExporter, a highly configurable converter
2 that uses Jinja2 to export notebook files into different formats.
2 that uses Jinja2 to export notebook files into different formats.
3 """
3 """
4
4
@@ -18,7 +18,7 b' from functools import wraps'
18 from IPython.nbformat.v3.nbbase import NotebookNode
18 from IPython.nbformat.v3.nbbase import NotebookNode
19 from IPython.config import Config
19 from IPython.config import Config
20
20
21 from .exporter import Exporter
21 from .exporter import TemplateExporter
22 from .html import HTMLExporter
22 from .html import HTMLExporter
23 from .slides import SlidesExporter
23 from .slides import SlidesExporter
24 from .latex import LatexExporter
24 from .latex import LatexExporter
@@ -100,14 +100,14 b' def export(exporter, nb, **kw):'
100 #Check arguments
100 #Check arguments
101 if exporter is None:
101 if exporter is None:
102 raise TypeError("Exporter is None")
102 raise TypeError("Exporter is None")
103 elif not isinstance(exporter, Exporter) and not issubclass(exporter, Exporter):
103 elif not isinstance(exporter, TemplateExporter) and not issubclass(exporter, TemplateExporter):
104 raise TypeError("exporter does not inherit from Exporter (base)")
104 raise TypeError("exporter does not inherit from Exporter (base)")
105 if nb is None:
105 if nb is None:
106 raise TypeError("nb is None")
106 raise TypeError("nb is None")
107
107
108 #Create the exporter
108 #Create the exporter
109 resources = kw.pop('resources', None)
109 resources = kw.pop('resources', None)
110 if isinstance(exporter, Exporter):
110 if isinstance(exporter, TemplateExporter):
111 exporter_instance = exporter
111 exporter_instance = exporter
112 else:
112 else:
113 exporter_instance = exporter(**kw)
113 exporter_instance = exporter(**kw)
@@ -122,7 +122,7 b' def export(exporter, nb, **kw):'
122 return output, resources
122 return output, resources
123
123
124 exporter_map = dict(
124 exporter_map = dict(
125 custom=Exporter,
125 custom=TemplateExporter,
126 html=HTMLExporter,
126 html=HTMLExporter,
127 slides=SlidesExporter,
127 slides=SlidesExporter,
128 latex=LatexExporter,
128 latex=LatexExporter,
@@ -19,13 +19,13 b' from IPython.utils.traitlets import Unicode, List'
19 from IPython.nbconvert import preprocessors
19 from IPython.nbconvert import preprocessors
20 from IPython.config import Config
20 from IPython.config import Config
21
21
22 from .exporter import Exporter
22 from .exporter import TemplateExporter
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25 # Classes
25 # Classes
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27
27
28 class HTMLExporter(Exporter):
28 class HTMLExporter(TemplateExporter):
29 """
29 """
30 Exports a basic HTML document. This exporter assists with the export of
30 Exports a basic HTML document. This exporter assists with the export of
31 HTML. Inherit from it if you are writing your own HTML template and need
31 HTML. Inherit from it if you are writing your own HTML template and need
@@ -16,13 +16,13 b' Exporter that will export your ipynb to Markdown.'
16 from IPython.config import Config
16 from IPython.config import Config
17 from IPython.utils.traitlets import Unicode
17 from IPython.utils.traitlets import Unicode
18
18
19 from .exporter import Exporter
19 from .exporter import TemplateExporter
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Classes
22 # Classes
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class MarkdownExporter(Exporter):
25 class MarkdownExporter(TemplateExporter):
26 """
26 """
27 Exports to a markdown document (.md)
27 Exports to a markdown document (.md)
28 """
28 """
@@ -15,13 +15,13 b' Python exporter which exports Notebook code into a PY file.'
15
15
16 from IPython.utils.traitlets import Unicode
16 from IPython.utils.traitlets import Unicode
17
17
18 from .exporter import Exporter
18 from .exporter import TemplateExporter
19
19
20 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
21 # Classes
21 # Classes
22 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
23
23
24 class PythonExporter(Exporter):
24 class PythonExporter(TemplateExporter):
25 """
25 """
26 Exports a Python code file.
26 Exports a Python code file.
27 """
27 """
@@ -16,13 +16,13 b' Exporter for exporting notebooks to restructured text.'
16 from IPython.utils.traitlets import Unicode
16 from IPython.utils.traitlets import Unicode
17 from IPython.config import Config
17 from IPython.config import Config
18
18
19 from .exporter import Exporter
19 from .exporter import TemplateExporter
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Classes
22 # Classes
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class RSTExporter(Exporter):
25 class RSTExporter(TemplateExporter):
26 """
26 """
27 Exports restructured text documents.
27 Exports restructured text documents.
28 """
28 """
@@ -19,13 +19,13 b' from IPython.utils.traitlets import Unicode'
19 from IPython.nbconvert import preprocessors
19 from IPython.nbconvert import preprocessors
20 from IPython.config import Config
20 from IPython.config import Config
21
21
22 from .exporter import Exporter
22 from .exporter import TemplateExporter
23
23
24 #-----------------------------------------------------------------------------
24 #-----------------------------------------------------------------------------
25 # Classes
25 # Classes
26 #-----------------------------------------------------------------------------
26 #-----------------------------------------------------------------------------
27
27
28 class SlidesExporter(Exporter):
28 class SlidesExporter(TemplateExporter):
29 """
29 """
30 Exports slides
30 Exports slides
31 """
31 """
@@ -27,4 +27,4 b' class ExportersTestsBase(TestsBase):'
27
27
28 def _get_notebook(self):
28 def _get_notebook(self):
29 return os.path.join(self._get_files_path(), 'notebook2.ipynb')
29 return os.path.join(self._get_files_path(), 'notebook2.ipynb')
30 No newline at end of file
30
@@ -99,4 +99,4 b' class TestExport(ExportersTestsBase):'
99 (output, resources) = export(None, self._get_notebook())
99 (output, resources) = export(None, self._get_notebook())
100 except TypeError:
100 except TypeError:
101 pass
101 pass
102 No newline at end of file
102
@@ -59,7 +59,7 b' nbconvert_aliases = {}'
59 nbconvert_aliases.update(base_aliases)
59 nbconvert_aliases.update(base_aliases)
60 nbconvert_aliases.update({
60 nbconvert_aliases.update({
61 'to' : 'NbConvertApp.export_format',
61 'to' : 'NbConvertApp.export_format',
62 'template' : 'Exporter.template_file',
62 'template' : 'TemplateExporter.template_file',
63 'writer' : 'NbConvertApp.writer_class',
63 'writer' : 'NbConvertApp.writer_class',
64 'post': 'NbConvertApp.postprocessor_class',
64 'post': 'NbConvertApp.postprocessor_class',
65 'output': 'NbConvertApp.output_base',
65 'output': 'NbConvertApp.output_base',
General Comments 0
You need to be logged in to leave comments. Login now