Show More
@@ -1,11 +1,7 b'' | |||||
1 |
from . |
|
1 | from .html import HTMLExporter | |
2 | from .export import * |
|
2 | from .export import * | |
3 | from .exporter import Exporter |
|
3 | from .exporter import Exporter | |
4 | from .fullhtml import FullHTMLExporter |
|
|||
5 | from .reveal import RevealExporter |
|
|||
6 | from .latex import LatexExporter |
|
4 | from .latex import LatexExporter | |
7 | from .markdown import MarkdownExporter |
|
5 | from .markdown import MarkdownExporter | |
8 | from .python import PythonExporter |
|
6 | from .python import PythonExporter | |
9 | from .rst import RSTExporter |
|
7 | from .rst import RSTExporter | |
10 | from .sphinx_howto import SphinxHowtoExporter |
|
|||
11 | from .sphinx_manual import SphinxManualExporter |
|
@@ -19,15 +19,11 b' 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 Exporter | |
22 |
from . |
|
22 | from .html import HTMLExporter | |
23 | from .fullhtml import FullHTMLExporter |
|
|||
24 | from .latex import LatexExporter |
|
23 | from .latex import LatexExporter | |
25 | from .markdown import MarkdownExporter |
|
24 | from .markdown import MarkdownExporter | |
26 | from .python import PythonExporter |
|
25 | from .python import PythonExporter | |
27 | from .reveal import RevealExporter |
|
|||
28 | from .rst import RSTExporter |
|
26 | from .rst import RSTExporter | |
29 | from .sphinx_howto import SphinxHowtoExporter |
|
|||
30 | from .sphinx_manual import SphinxManualExporter |
|
|||
31 |
|
27 | |||
32 | #----------------------------------------------------------------------------- |
|
28 | #----------------------------------------------------------------------------- | |
33 | # Classes |
|
29 | # Classes | |
@@ -69,14 +65,10 b' def DocDecorator(f):' | |||||
69 |
|
65 | |||
70 | __all__ = [ |
|
66 | __all__ = [ | |
71 | 'export', |
|
67 | 'export', | |
72 |
'export_ |
|
68 | 'export_html', | |
73 | 'export_sphinx_howto', |
|
|||
74 | 'export_basic_html', |
|
|||
75 | 'export_full_html', |
|
|||
76 | 'export_latex', |
|
69 | 'export_latex', | |
77 | 'export_markdown', |
|
70 | 'export_markdown', | |
78 | 'export_python', |
|
71 | 'export_python', | |
79 | 'export_reveal', |
|
|||
80 | 'export_rst', |
|
72 | 'export_rst', | |
81 | 'export_by_name', |
|
73 | 'export_by_name', | |
82 | 'get_export_names', |
|
74 | 'get_export_names', | |
@@ -126,35 +118,11 b' def export(exporter, nb, **kw):' | |||||
126 |
|
118 | |||
127 |
|
119 | |||
128 | @DocDecorator |
|
120 | @DocDecorator | |
129 |
def export_ |
|
121 | def export_html(nb, **kw): | |
130 | """ |
|
|||
131 | Export a notebook object to Sphinx Manual LaTeX |
|
|||
132 | """ |
|
|||
133 | return export(SphinxManualExporter, nb, **kw) |
|
|||
134 |
|
||||
135 |
|
||||
136 | @DocDecorator |
|
|||
137 | def export_sphinx_howto(nb, **kw): |
|
|||
138 | """ |
|
|||
139 | Export a notebook object to Sphinx HowTo LaTeX |
|
|||
140 | """ |
|
|||
141 | return export(SphinxHowtoExporter, nb, **kw) |
|
|||
142 |
|
||||
143 |
|
||||
144 | @DocDecorator |
|
|||
145 | def export_basic_html(nb, **kw): |
|
|||
146 | """ |
|
122 | """ | |
147 | Export a notebook object to Basic HTML |
|
123 | Export a notebook object to Basic HTML | |
148 | """ |
|
124 | """ | |
149 |
return export( |
|
125 | return export(HTMLExporter, nb, **kw) | |
150 |
|
||||
151 |
|
||||
152 | @DocDecorator |
|
|||
153 | def export_full_html(nb, **kw): |
|
|||
154 | """ |
|
|||
155 | Export a notebook object to Full HTML |
|
|||
156 | """ |
|
|||
157 | return export(FullHTMLExporter, nb, **kw) |
|
|||
158 |
|
126 | |||
159 |
|
127 | |||
160 | @DocDecorator |
|
128 | @DocDecorator | |
@@ -182,14 +150,6 b' def export_python(nb, **kw):' | |||||
182 |
|
150 | |||
183 |
|
151 | |||
184 | @DocDecorator |
|
152 | @DocDecorator | |
185 | def export_reveal(nb, **kw): |
|
|||
186 | """ |
|
|||
187 | Export a notebook object to a Reveal.js presentation |
|
|||
188 | """ |
|
|||
189 | return export(RevealExporter, nb, **kw) |
|
|||
190 |
|
||||
191 |
|
||||
192 | @DocDecorator |
|
|||
193 | def export_rst(nb, **kw): |
|
153 | def export_rst(nb, **kw): | |
194 | """ |
|
154 | """ | |
195 | Export a notebook object to reStructuredText |
|
155 | Export a notebook object to reStructuredText |
@@ -86,16 +86,17 b' class Exporter(Configurable):' | |||||
86 | transformers provided by default suffice, there is no need to inherit from |
|
86 | transformers provided by default suffice, there is no need to inherit from | |
87 | this class. Instead, override the template_file and file_extension |
|
87 | this class. Instead, override the template_file and file_extension | |
88 | traits via a config file. |
|
88 | traits via a config file. | |
89 |
|
||||
90 | {filters} |
|
|||
91 | """ |
|
89 | """ | |
92 |
|
90 | |||
93 | # finish the docstring |
|
91 | # finish the docstring | |
94 | __doc__ = __doc__.format(filters = '- '+'\n - '.join(default_filters.keys())) |
|
92 | __doc__ = __doc__.format(filters = '- '+'\n - '.join(default_filters.keys())) | |
95 |
|
93 | |||
96 |
|
94 | |||
|
95 | flavor = Unicode(config=True, help="""Flavor of the data format to use. | |||
|
96 | I.E. 'full' or 'basic'""") | |||
|
97 | ||||
97 | template_file = Unicode( |
|
98 | template_file = Unicode( | |
98 |
|
|
99 | config=True, | |
99 | help="Name of the template file to use") |
|
100 | help="Name of the template file to use") | |
100 |
|
101 | |||
101 | file_extension = Unicode( |
|
102 | file_extension = Unicode( | |
@@ -155,6 +156,9 b' class Exporter(Configurable):' | |||||
155 | extra_loaders : list[of Jinja Loaders] |
|
156 | extra_loaders : list[of Jinja Loaders] | |
156 | ordered list of Jinja loder to find templates. Will be tried in order |
|
157 | ordered list of Jinja loder to find templates. Will be tried in order | |
157 | before the default FileSysteme ones. |
|
158 | before the default FileSysteme ones. | |
|
159 | flavor : str | |||
|
160 | Flavor to use when exporting. This determines what template to use | |||
|
161 | if one hasn't been specifically provided. | |||
158 | """ |
|
162 | """ | |
159 |
|
163 | |||
160 | #Call the base class constructor |
|
164 | #Call the base class constructor | |
@@ -165,6 +169,7 b' class Exporter(Configurable):' | |||||
165 | super(Exporter, self).__init__(config=c, **kw) |
|
169 | super(Exporter, self).__init__(config=c, **kw) | |
166 |
|
170 | |||
167 | #Init |
|
171 | #Init | |
|
172 | self._init_template(**kw) | |||
168 | self._init_environment(extra_loaders=extra_loaders) |
|
173 | self._init_environment(extra_loaders=extra_loaders) | |
169 | self._init_transformers() |
|
174 | self._init_transformers() | |
170 | self._init_filters() |
|
175 | self._init_filters() | |
@@ -329,6 +334,25 b' class Exporter(Configurable):' | |||||
329 | raise TypeError('filter') |
|
334 | raise TypeError('filter') | |
330 |
|
335 | |||
331 |
|
336 | |||
|
337 | def _init_template(self, **kw): | |||
|
338 | """ | |||
|
339 | Make sure a template name is specified. If one isn't specified, try to | |||
|
340 | build one from the information we know. | |||
|
341 | """ | |||
|
342 | ||||
|
343 | # Set the template_file if it has not been set explicitly. | |||
|
344 | if not self.template_file: | |||
|
345 | ||||
|
346 | # Build the template file name from the name of the exporter and the | |||
|
347 | # flavor (if available). The flavor can be set on the traitlet | |||
|
348 | # or passed in as a kw arg. The flavor specified in kw overrides | |||
|
349 | # what is set in the flavor traitlet. | |||
|
350 | if self.flavor or 'flavor' in kw: | |||
|
351 | self.template_file = self.__name__ + '_' + kw.get('flavor', self.flavor) | |||
|
352 | else: | |||
|
353 | self.template_file = self.__name__ | |||
|
354 | ||||
|
355 | ||||
332 | def _init_environment(self, extra_loaders=None): |
|
356 | def _init_environment(self, extra_loaders=None): | |
333 | """ |
|
357 | """ | |
334 | Create the Jinja templating environment. |
|
358 | Create the Jinja templating environment. |
@@ -24,7 +24,7 b' from .exporter import Exporter' | |||||
24 | # Classes |
|
24 | # Classes | |
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
26 |
|
26 | |||
27 |
class |
|
27 | class HTMLExporter(Exporter): | |
28 | """ |
|
28 | """ | |
29 | Exports a basic HTML document. This exporter assists with the export of |
|
29 | Exports a basic HTML document. This exporter assists with the export of | |
30 | HTML. Inherit from it if you are writing your own HTML template and need |
|
30 | HTML. Inherit from it if you are writing your own HTML template and need | |
@@ -37,6 +37,18 b' class BasicHTMLExporter(Exporter):' | |||||
37 | help="Extension of the file that should be written to disk" |
|
37 | help="Extension of the file that should be written to disk" | |
38 | ) |
|
38 | ) | |
39 |
|
39 | |||
40 | template_file = Unicode( |
|
40 | flavor = Unicode('full', config=True, help="""Flavor of the data format to | |
41 | 'basichtml', config=True, |
|
41 | use. I.E. 'full' or 'basic'""") | |
42 | help="Name of the template file to use") |
|
42 | ||
|
43 | @property | |||
|
44 | def default_config(self): | |||
|
45 | c = Config({ | |||
|
46 | 'CSSHTMLHeaderTransformer':{ | |||
|
47 | 'enabled':True | |||
|
48 | }, | |||
|
49 | 'RevealHelpTransformer':{ | |||
|
50 | 'enabled':True, | |||
|
51 | }, | |||
|
52 | }) | |||
|
53 | c.merge(super(RevealExporter,self).default_config) | |||
|
54 | return c |
@@ -44,9 +44,8 b' class LatexExporter(Exporter):' | |||||
44 | 'tex', config=True, |
|
44 | 'tex', config=True, | |
45 | help="Extension of the file that should be written to disk") |
|
45 | help="Extension of the file that should be written to disk") | |
46 |
|
46 | |||
47 | template_file = Unicode( |
|
47 | flavor = Unicode('article', config=True, help="""Flavor of the data format to | |
48 | 'base', config=True, |
|
48 | use. I.E. 'full' or 'basic'""") | |
49 | help="Name of the template file to use") |
|
|||
50 |
|
49 | |||
51 | #Latex constants |
|
50 | #Latex constants | |
52 | default_template_path = Unicode( |
|
51 | default_template_path = Unicode( | |
@@ -68,6 +67,7 b' class LatexExporter(Exporter):' | |||||
68 | #Extension that the template files use. |
|
67 | #Extension that the template files use. | |
69 | template_extension = Unicode(".tplx", config=True) |
|
68 | template_extension = Unicode(".tplx", config=True) | |
70 |
|
69 | |||
|
70 | ||||
71 | @property |
|
71 | @property | |
72 | def default_config(self): |
|
72 | def default_config(self): | |
73 | c = Config({ |
|
73 | c = Config({ | |
@@ -83,6 +83,9 b' class LatexExporter(Exporter):' | |||||
83 | 'LatexTransformer': { |
|
83 | 'LatexTransformer': { | |
84 | 'enabled':True |
|
84 | 'enabled':True | |
85 | } |
|
85 | } | |
|
86 | 'SphinxTransformer': { | |||
|
87 | 'enabled':True | |||
|
88 | } | |||
86 | }) |
|
89 | }) | |
87 | c.merge(super(LatexExporter,self).default_config) |
|
90 | c.merge(super(LatexExporter,self).default_config) | |
88 | return c |
|
91 | return c |
@@ -29,7 +29,3 b' class MarkdownExporter(Exporter):' | |||||
29 | file_extension = Unicode( |
|
29 | file_extension = Unicode( | |
30 | 'md', config=True, |
|
30 | 'md', config=True, | |
31 | help="Extension of the file that should be written to disk") |
|
31 | help="Extension of the file that should be written to disk") | |
32 |
|
||||
33 | template_file = Unicode( |
|
|||
34 | 'markdown', config=True, |
|
|||
35 | help="Name of the template file to use") |
|
@@ -29,7 +29,3 b' class PythonExporter(Exporter):' | |||||
29 | file_extension = Unicode( |
|
29 | file_extension = Unicode( | |
30 | 'py', config=True, |
|
30 | 'py', config=True, | |
31 | help="Extension of the file that should be written to disk") |
|
31 | help="Extension of the file that should be written to disk") | |
32 |
|
||||
33 | template_file = Unicode( |
|
|||
34 | 'python', config=True, |
|
|||
35 | help="Name of the template file to use") |
|
@@ -31,10 +31,6 b' class RSTExporter(Exporter):' | |||||
31 | 'rst', config=True, |
|
31 | 'rst', config=True, | |
32 | help="Extension of the file that should be written to disk") |
|
32 | help="Extension of the file that should be written to disk") | |
33 |
|
33 | |||
34 | template_file = Unicode( |
|
|||
35 | 'rst', config=True, |
|
|||
36 | help="Name of the template file to use") |
|
|||
37 |
|
||||
38 | @property |
|
34 | @property | |
39 | def default_config(self): |
|
35 | def default_config(self): | |
40 | c = Config({'ExtractOutputTransformer':{'enabled':True}}) |
|
36 | c = Config({'ExtractOutputTransformer':{'enabled':True}}) |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/basichtml.tpl to IPython/nbconvert/templates/html_basic.tpl |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/basichtml.tpl to IPython/nbconvert/templates/html_basic.tpl |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/fullhtml.tpl to IPython/nbconvert/templates/html_full.tpl |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/fullhtml.tpl to IPython/nbconvert/templates/html_full.tpl |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/reveal.tpl to IPython/nbconvert/templates/html_slides.tpl |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/reveal.tpl to IPython/nbconvert/templates/html_slides.tpl |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/latex/base.tplx to IPython/nbconvert/templates/latex/latex.tplx |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/base.tplx to IPython/nbconvert/templates/latex/latex.tplx |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/latex/sphinx_howto.tplx to IPython/nbconvert/templates/latex/latex_article.tplx |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/sphinx_howto.tplx to IPython/nbconvert/templates/latex/latex_article.tplx |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/latex/sphinx_manual.tplx to IPython/nbconvert/templates/latex/latex_book.tplx |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/sphinx_manual.tplx to IPython/nbconvert/templates/latex/latex_book.tplx |
1 | NO CONTENT: file renamed from IPython/nbconvert/templates/latex/sphinx_base.tplx to IPython/nbconvert/templates/latex/sphinx.tplx |
|
NO CONTENT: file renamed from IPython/nbconvert/templates/latex/sphinx_base.tplx to IPython/nbconvert/templates/latex/sphinx.tplx |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now