Show More
@@ -93,7 +93,7 b' def export(exporter, nb, **kw):' | |||||
93 |
|
93 | |||
94 | Parameters |
|
94 | Parameters | |
95 | ---------- |
|
95 | ---------- | |
96 |
exporter : class:`~ |
|
96 | exporter : class:`~jupyter_nbconvert.exporters.exporter.Exporter` class or instance | |
97 | Class type or instance of the exporter that should be used. If the |
|
97 | Class type or instance of the exporter that should be used. If the | |
98 | method initializes it's own instance of the class, it is ASSUMED that |
|
98 | method initializes it's own instance of the class, it is ASSUMED that | |
99 | the class type provided exposes a constructor (``__init__``) with the same |
|
99 | the class type provided exposes a constructor (``__init__``) with the same |
@@ -65,15 +65,15 b' class Exporter(LoggingConfigurable):' | |||||
65 |
|
65 | |||
66 | _preprocessors = List() |
|
66 | _preprocessors = List() | |
67 |
|
67 | |||
68 |
default_preprocessors = List([' |
|
68 | default_preprocessors = List(['jupyter_nbconvert.preprocessors.coalesce_streams', | |
69 |
' |
|
69 | 'jupyter_nbconvert.preprocessors.SVG2PDFPreprocessor', | |
70 |
' |
|
70 | 'jupyter_nbconvert.preprocessors.ExtractOutputPreprocessor', | |
71 |
' |
|
71 | 'jupyter_nbconvert.preprocessors.CSSHTMLHeaderPreprocessor', | |
72 |
' |
|
72 | 'jupyter_nbconvert.preprocessors.RevealHelpPreprocessor', | |
73 |
' |
|
73 | 'jupyter_nbconvert.preprocessors.LatexPreprocessor', | |
74 |
' |
|
74 | 'jupyter_nbconvert.preprocessors.ClearOutputPreprocessor', | |
75 |
' |
|
75 | 'jupyter_nbconvert.preprocessors.ExecutePreprocessor', | |
76 |
' |
|
76 | 'jupyter_nbconvert.preprocessors.HighlightMagicsPreprocessor'], | |
77 | config=True, |
|
77 | config=True, | |
78 | help="""List of preprocessors available by default, by name, namespace, |
|
78 | help="""List of preprocessors available by default, by name, namespace, | |
79 | instance, or type.""") |
|
79 | instance, or type.""") |
@@ -5,7 +5,7 b'' | |||||
5 |
|
5 | |||
6 | import os |
|
6 | import os | |
7 |
|
7 | |||
8 |
from |
|
8 | from jupyter_nbconvert.filters.highlight import Highlight2HTML | |
9 | from IPython.config import Config |
|
9 | from IPython.config import Config | |
10 |
|
10 | |||
11 | from .templateexporter import TemplateExporter |
|
11 | from .templateexporter import TemplateExporter |
@@ -19,7 +19,7 b' import os' | |||||
19 | from IPython.utils.traitlets import Unicode |
|
19 | from IPython.utils.traitlets import Unicode | |
20 | from IPython.config import Config |
|
20 | from IPython.config import Config | |
21 |
|
21 | |||
22 |
from |
|
22 | from jupyter_nbconvert.filters.highlight import Highlight2Latex | |
23 | from .templateexporter import TemplateExporter |
|
23 | from .templateexporter import TemplateExporter | |
24 |
|
24 | |||
25 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- |
@@ -36,7 +36,7 b' class PDFExporter(LatexExporter):' | |||||
36 | help="File extensions of temp files to remove after running." |
|
36 | help="File extensions of temp files to remove after running." | |
37 | ) |
|
37 | ) | |
38 |
|
38 | |||
39 |
writer = Instance(" |
|
39 | writer = Instance("jupyter_nbconvert.writers.FilesWriter", args=()) | |
40 |
|
40 | |||
41 | def run_command(self, command_list, filename, count, log_function): |
|
41 | def run_command(self, command_list, filename, count, log_function): | |
42 | """Run command_list count times. |
|
42 | """Run command_list count times. |
@@ -12,7 +12,7 b'' | |||||
12 | # Imports |
|
12 | # Imports | |
13 | #----------------------------------------------------------------------------- |
|
13 | #----------------------------------------------------------------------------- | |
14 |
|
14 | |||
15 |
from |
|
15 | from jupyter_nbconvert import preprocessors | |
16 | from IPython.config import Config |
|
16 | from IPython.config import Config | |
17 |
|
17 | |||
18 | from .html import HTMLExporter |
|
18 | from .html import HTMLExporter |
@@ -27,7 +27,7 b' from IPython.utils.traitlets import MetaHasTraits, Unicode, List, Dict, Any' | |||||
27 | from IPython.utils.importstring import import_item |
|
27 | from IPython.utils.importstring import import_item | |
28 | from IPython.utils import py3compat, text |
|
28 | from IPython.utils import py3compat, text | |
29 |
|
29 | |||
30 |
from |
|
30 | from jupyter_nbconvert import filters | |
31 | from .exporter import Exporter |
|
31 | from .exporter import Exporter | |
32 |
|
32 | |||
33 | #----------------------------------------------------------------------------- |
|
33 | #----------------------------------------------------------------------------- |
@@ -83,7 +83,7 b' class TestExporter(ExportersTestsBase):' | |||||
83 | """ |
|
83 | """ | |
84 | Can a preprocessor be added to the preprocessors list by dotted object name? |
|
84 | Can a preprocessor be added to the preprocessors list by dotted object name? | |
85 | """ |
|
85 | """ | |
86 |
config = Config({'Exporter': {'preprocessors': [' |
|
86 | config = Config({'Exporter': {'preprocessors': ['jupyter_nbconvert.exporters.tests.cheese.CheesePreprocessor']}}) | |
87 | exporter = self._make_exporter(config=config) |
|
87 | exporter = self._make_exporter(config=config) | |
88 | (output, resources) = exporter.from_filename(self._get_notebook()) |
|
88 | (output, resources) = exporter.from_filename(self._get_notebook()) | |
89 | assert resources is not None |
|
89 | assert resources is not None |
@@ -10,7 +10,7 b' from within Jinja templates.' | |||||
10 | # because errors should be raised at runtime if it's actually needed, |
|
10 | # because errors should be raised at runtime if it's actually needed, | |
11 | # not import time, when it may not be needed. |
|
11 | # not import time, when it may not be needed. | |
12 |
|
12 | |||
13 |
from |
|
13 | from jupyter_nbconvert.utils.base import NbConvertBase | |
14 | from warnings import warn |
|
14 | from warnings import warn | |
15 |
|
15 | |||
16 | MULTILINE_OUTPUTS = ['text', 'html', 'svg', 'latex', 'javascript', 'json'] |
|
16 | MULTILINE_OUTPUTS = ['text', 'html', 'svg', 'latex', 'javascript', 'json'] |
@@ -21,8 +21,8 b' except ImportError as e:' | |||||
21 | """mistune is unavailable, raise ImportError""" |
|
21 | """mistune is unavailable, raise ImportError""" | |
22 | raise ImportError("markdown2html requires mistune: %s" % _mistune_import_error) |
|
22 | raise ImportError("markdown2html requires mistune: %s" % _mistune_import_error) | |
23 |
|
23 | |||
24 |
from |
|
24 | from jupyter_nbconvert.utils.pandoc import pandoc | |
25 |
from |
|
25 | from jupyter_nbconvert.utils.exceptions import ConversionException | |
26 | from IPython.utils.process import get_output_error_code |
|
26 | from IPython.utils.process import get_output_error_code | |
27 | from IPython.utils.py3compat import cast_bytes |
|
27 | from IPython.utils.py3compat import cast_bytes | |
28 | from IPython.utils.version import check_version |
|
28 | from IPython.utils.version import check_version |
@@ -16,8 +16,8 b' from pygments.lexers import get_lexer_by_name' | |||||
16 | from pygments.formatters import HtmlFormatter |
|
16 | from pygments.formatters import HtmlFormatter | |
17 | from pygments.util import ClassNotFound |
|
17 | from pygments.util import ClassNotFound | |
18 |
|
18 | |||
19 |
from |
|
19 | from jupyter_nbconvert.filters.strings import add_anchor | |
20 |
from |
|
20 | from jupyter_nbconvert.utils.exceptions import ConversionException | |
21 | from IPython.utils.decorators import undoc |
|
21 | from IPython.utils.decorators import undoc | |
22 |
|
22 | |||
23 |
|
23 |
@@ -23,7 +23,7 b' from IPython.utils.traitlets import (' | |||||
23 | from IPython.utils.importstring import import_item |
|
23 | from IPython.utils.importstring import import_item | |
24 |
|
24 | |||
25 | from .exporters.export import get_export_names, exporter_map |
|
25 | from .exporters.export import get_export_names, exporter_map | |
26 |
from |
|
26 | from jupyter_nbconvert import exporters, preprocessors, writers, postprocessors | |
27 | from .utils.base import NbConvertBase |
|
27 | from .utils.base import NbConvertBase | |
28 | from .utils.exceptions import ConversionException |
|
28 | from .utils.exceptions import ConversionException | |
29 |
|
29 | |||
@@ -159,15 +159,15 b' class NbConvertApp(BaseIPythonApplication):' | |||||
159 | """.format(get_export_names())) |
|
159 | """.format(get_export_names())) | |
160 |
|
160 | |||
161 | # Writer specific variables |
|
161 | # Writer specific variables | |
162 |
writer = Instance(' |
|
162 | writer = Instance('jupyter_nbconvert.writers.base.WriterBase', | |
163 | help="""Instance of the writer class used to write the |
|
163 | help="""Instance of the writer class used to write the | |
164 | results of the conversion.""") |
|
164 | results of the conversion.""") | |
165 | writer_class = DottedObjectName('FilesWriter', config=True, |
|
165 | writer_class = DottedObjectName('FilesWriter', config=True, | |
166 | help="""Writer class used to write the |
|
166 | help="""Writer class used to write the | |
167 | results of the conversion""") |
|
167 | results of the conversion""") | |
168 |
writer_aliases = {'fileswriter': ' |
|
168 | writer_aliases = {'fileswriter': 'jupyter_nbconvert.writers.files.FilesWriter', | |
169 |
'debugwriter': ' |
|
169 | 'debugwriter': 'jupyter_nbconvert.writers.debug.DebugWriter', | |
170 |
'stdoutwriter': ' |
|
170 | 'stdoutwriter': 'jupyter_nbconvert.writers.stdout.StdoutWriter'} | |
171 | writer_factory = Type() |
|
171 | writer_factory = Type() | |
172 |
|
172 | |||
173 | def _writer_class_changed(self, name, old, new): |
|
173 | def _writer_class_changed(self, name, old, new): | |
@@ -176,14 +176,14 b' class NbConvertApp(BaseIPythonApplication):' | |||||
176 | self.writer_factory = import_item(new) |
|
176 | self.writer_factory = import_item(new) | |
177 |
|
177 | |||
178 | # Post-processor specific variables |
|
178 | # Post-processor specific variables | |
179 |
postprocessor = Instance(' |
|
179 | postprocessor = Instance('jupyter_nbconvert.postprocessors.base.PostProcessorBase', | |
180 | help="""Instance of the PostProcessor class used to write the |
|
180 | help="""Instance of the PostProcessor class used to write the | |
181 | results of the conversion.""") |
|
181 | results of the conversion.""") | |
182 |
|
182 | |||
183 | postprocessor_class = DottedOrNone(config=True, |
|
183 | postprocessor_class = DottedOrNone(config=True, | |
184 | help="""PostProcessor class used to write the |
|
184 | help="""PostProcessor class used to write the | |
185 | results of the conversion""") |
|
185 | results of the conversion""") | |
186 |
postprocessor_aliases = {'serve': ' |
|
186 | postprocessor_aliases = {'serve': 'jupyter_nbconvert.postprocessors.serve.ServePostProcessor'} | |
187 | postprocessor_factory = Type() |
|
187 | postprocessor_factory = Type() | |
188 |
|
188 | |||
189 | def _postprocessor_class_changed(self, name, old, new): |
|
189 | def _postprocessor_class_changed(self, name, old, new): |
@@ -21,7 +21,7 b' from IPython import nbformat' | |||||
21 | from .base import PreprocessorTestsBase |
|
21 | from .base import PreprocessorTestsBase | |
22 | from ..execute import ExecutePreprocessor |
|
22 | from ..execute import ExecutePreprocessor | |
23 |
|
23 | |||
24 |
from |
|
24 | from jupyter_nbconvert.filters import strip_ansi | |
25 | from nose.tools import assert_raises |
|
25 | from nose.tools import assert_raises | |
26 |
|
26 | |||
27 | addr_pat = re.compile(r'0x[0-9a-f]{7,9}') |
|
27 | addr_pat = re.compile(r'0x[0-9a-f]{7,9}') |
@@ -1,4 +1,4 b'' | |||||
1 |
from |
|
1 | from jupyter_nbconvert.writers.base import WriterBase | |
2 |
|
2 | |||
3 | class HelloWriter(WriterBase): |
|
3 | class HelloWriter(WriterBase): | |
4 |
|
4 |
@@ -87,7 +87,7 b' class TestNbConvertApp(TestsBase):' | |||||
87 | """Do post processors work?""" |
|
87 | """Do post processors work?""" | |
88 | with self.create_temp_cwd(['notebook1.ipynb']): |
|
88 | with self.create_temp_cwd(['notebook1.ipynb']): | |
89 | out, err = self.call('nbconvert --log-level 0 --to python notebook1 ' |
|
89 | out, err = self.call('nbconvert --log-level 0 --to python notebook1 ' | |
90 |
'--post |
|
90 | '--post jupyter_nbconvert.tests.test_nbconvertapp.DummyPost') | |
91 | self.assertIn('Dummy:notebook1.py', out) |
|
91 | self.assertIn('Dummy:notebook1.py', out) | |
92 |
|
92 | |||
93 | @dec.onlyif_cmds_exist('pandoc') |
|
93 | @dec.onlyif_cmds_exist('pandoc') |
@@ -11,7 +11,7 b'' | |||||
11 | #----------------------------------------------------------------------------- |
|
11 | #----------------------------------------------------------------------------- | |
12 | from pygments.token import Token |
|
12 | from pygments.token import Token | |
13 |
|
13 | |||
14 |
from |
|
14 | from jupyter_nbconvert.tests.base import TestsBase | |
15 | from .. import lexers |
|
15 | from .. import lexers | |
16 |
|
16 | |||
17 |
|
17 |
@@ -14,7 +14,7 b' import warnings' | |||||
14 |
|
14 | |||
15 | from IPython.testing import decorators as dec |
|
15 | from IPython.testing import decorators as dec | |
16 |
|
16 | |||
17 |
from |
|
17 | from jupyter_nbconvert.tests.base import TestsBase | |
18 | from .. import pandoc |
|
18 | from .. import pandoc | |
19 |
|
19 | |||
20 | #----------------------------------------------------------------------------- |
|
20 | #----------------------------------------------------------------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now