diff --git a/IPython/nbconvert/exporters/__init__.py b/IPython/nbconvert/exporters/__init__.py index 10d570d..c4eb2cb 100755 --- a/IPython/nbconvert/exporters/__init__.py +++ b/IPython/nbconvert/exporters/__init__.py @@ -1,5 +1,6 @@ -from .html import HTMLExporter from .export import * +from .html import HTMLExporter +from .slides import SlidesExporter from .exporter import Exporter from .latex import LatexExporter from .markdown import MarkdownExporter diff --git a/IPython/nbconvert/exporters/export.py b/IPython/nbconvert/exporters/export.py index e6766db..e96fb4f 100755 --- a/IPython/nbconvert/exporters/export.py +++ b/IPython/nbconvert/exporters/export.py @@ -20,6 +20,7 @@ from IPython.config import Config from .exporter import Exporter from .html import HTMLExporter +from .slides import SlidesExporter from .latex import LatexExporter from .markdown import MarkdownExporter from .python import PythonExporter @@ -67,6 +68,7 @@ __all__ = [ 'export', 'export_html', 'export_custom', + 'export_slides', 'export_latex', 'export_markdown', 'export_python', @@ -135,6 +137,14 @@ def export_html(nb, **kw): @DocDecorator +def export_slides(nb, **kw): + """ + Export a notebook object to Slides + """ + return export(SlidesExporter, nb, **kw) + + +@DocDecorator def export_latex(nb, **kw): """ Export a notebook object to LaTeX diff --git a/IPython/nbconvert/exporters/slides.py b/IPython/nbconvert/exporters/slides.py new file mode 100644 index 0000000..58f7900 --- /dev/null +++ b/IPython/nbconvert/exporters/slides.py @@ -0,0 +1,52 @@ +""" +Exporter that exports Basic HTML. +""" + +#----------------------------------------------------------------------------- +# Copyright (c) 2013, the IPython Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +from IPython.utils.traitlets import Unicode + +from IPython.nbconvert import transformers +from IPython.config import Config + +from .exporter import Exporter + +#----------------------------------------------------------------------------- +# Classes +#----------------------------------------------------------------------------- + +class SlidesExporter(Exporter): + """ + Exports slides + """ + + file_extension = Unicode( + 'html', config=True, + help="Extension of the file that should be written to disk" + ) + + flavor = Unicode('reveal', config=True, help="""Flavor of the data format to + use. I.E. 'reveal'""") + + @property + def default_config(self): + c = Config({ + 'CSSHTMLHeaderTransformer':{ + 'enabled':True + }, + 'RevealHelpTransformer':{ + 'enabled':True, + }, + }) + c.merge(super(SlidesExporter,self).default_config) + return c diff --git a/IPython/nbconvert/exporters/tests/test_html.py b/IPython/nbconvert/exporters/tests/test_html.py index 7499eb4..e6542bb 100644 --- a/IPython/nbconvert/exporters/tests/test_html.py +++ b/IPython/nbconvert/exporters/tests/test_html.py @@ -1,5 +1,5 @@ """ -Module with tests for basichtml.py +Module with tests for html.py """ #----------------------------------------------------------------------------- @@ -23,7 +23,7 @@ from IPython.testing.decorators import onlyif_cmds_exist #----------------------------------------------------------------------------- class TestHTMLExporter(ExportersTestsBase): - """Contains test functions for basichtml.py""" + """Contains test functions for html.py""" def test_constructor(self): """ @@ -54,11 +54,3 @@ class TestHTMLExporter(ExportersTestsBase): """ (output, resources) = HTMLExporter(flavor='full').from_filename(self._get_notebook()) assert len(output) > 0 - - - def test_export_reveal(self): - """ - Can a HTMLExporter export using the 'reveal' flavor? - """ - (output, resources) = HTMLExporter(flavor='reveal').from_filename(self._get_notebook()) - assert len(output) > 0 \ No newline at end of file diff --git a/IPython/nbconvert/exporters/tests/test_slides.py b/IPython/nbconvert/exporters/tests/test_slides.py new file mode 100644 index 0000000..6131845 --- /dev/null +++ b/IPython/nbconvert/exporters/tests/test_slides.py @@ -0,0 +1,47 @@ +""" +Module with tests for slides.py +""" + +#----------------------------------------------------------------------------- +# Copyright (c) 2013, the IPython Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +from .base import ExportersTestsBase +from ..slides import SlidesExporter + +#----------------------------------------------------------------------------- +# Class +#----------------------------------------------------------------------------- + +class TestSlidesExporter(ExportersTestsBase): + """Contains test functions for slides.py""" + + def test_constructor(self): + """ + Can a SlidesExporter be constructed? + """ + SlidesExporter() + + + def test_export(self): + """ + Can a SlidesExporter export something? + """ + (output, resources) = SlidesExporter().from_filename(self._get_notebook()) + assert len(output) > 0 + + + def test_export_reveal(self): + """ + Can a SlidesExporter export using the 'reveal' flavor? + """ + (output, resources) = SlidesExporter(flavor='reveal').from_filename(self._get_notebook()) + assert len(output) > 0 diff --git a/IPython/nbconvert/nbconvertapp.py b/IPython/nbconvert/nbconvertapp.py index 3f85d8e..75ab356 100755 --- a/IPython/nbconvert/nbconvertapp.py +++ b/IPython/nbconvert/nbconvertapp.py @@ -96,8 +96,8 @@ class NbConvertApp(BaseIPythonApplication): > ipython nbconvert --to latex mynotebook.ipnynb Both HTML and LaTeX support multiple flavors of output. LaTeX includes - 'basic', 'book', and 'article'. HTML includes 'basic', 'full', and - 'reveal'. You can specify the flavor of the format used. + 'basic', 'book', and 'article'. HTML includes 'basic' and 'full'. You + can specify the flavor of the format used. > ipython nbconvert --to html --flavor reveal mynotebook.ipnynb diff --git a/IPython/nbconvert/templates/html_reveal.tpl b/IPython/nbconvert/templates/slides_reveal.tpl similarity index 100% rename from IPython/nbconvert/templates/html_reveal.tpl rename to IPython/nbconvert/templates/slides_reveal.tpl diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py b/IPython/nbconvert/tests/test_nbconvertapp.py index 5add7a5..35f8b01 100644 --- a/IPython/nbconvert/tests/test_nbconvertapp.py +++ b/IPython/nbconvert/tests/test_nbconvertapp.py @@ -82,10 +82,10 @@ class TestNbConvertApp(TestsBase): def test_flavor(self): """ - Do explicit notebook names work? + Do export flavors work? """ with self.create_temp_cwd(['notebook*.ipynb']): - assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="html"', + assert not 'error' in self.call([IPYTHON, 'nbconvert', '--to="slides"', '--notebooks=["notebook2.ipynb"]', '--flavor="reveal"']).lower() assert os.path.isfile('notebook2.html') with open('notebook2.html') as f: