##// END OF EJS Templates
generate `export_foo` methods...
MinRK -
Show More
@@ -128,62 +128,27 b' def export(exporter, nb, **kw):'
128 output, resources = exporter_instance.from_file(nb, resources)
128 output, resources = exporter_instance.from_file(nb, resources)
129 return output, resources
129 return output, resources
130
130
131 exporter_map = dict(
132 custom=Exporter,
133 html=HTMLExporter,
134 slides=SlidesExporter,
135 latex=LatexExporter,
136 markdown=MarkdownExporter,
137 python=PythonExporter,
138 rst=RSTExporter,
139 )
140
141 def _make_exporter(name, E):
142 """make an export_foo function from a short key and Exporter class E"""
143 def _export(nb, **kw):
144 return export(E, nb, **kw)
145 _export.__doc__ = """Export a notebook object to {0} format""".format(name)
146 return _export
147
148 g = globals()
131
149
132 @DocDecorator
150 for name, E in exporter_map.items():
133 def export_custom(nb, **kw):
151 g['export_%s' % name] = DocDecorator(_make_exporter(name, E))
134 """
135 Export a notebook object to a custom format
136 """
137 return export(Exporter, nb, **kw)
138
139
140 @DocDecorator
141 def export_html(nb, **kw):
142 """
143 Export a notebook object to HTML
144 """
145 return export(HTMLExporter, nb, **kw)
146
147
148 @DocDecorator
149 def export_slides(nb, **kw):
150 """
151 Export a notebook object to Slides
152 """
153 return export(SlidesExporter, nb, **kw)
154
155
156 @DocDecorator
157 def export_latex(nb, **kw):
158 """
159 Export a notebook object to LaTeX
160 """
161 return export(LatexExporter, nb, **kw)
162
163
164 @DocDecorator
165 def export_markdown(nb, **kw):
166 """
167 Export a notebook object to Markdown
168 """
169 return export(MarkdownExporter, nb, **kw)
170
171
172 @DocDecorator
173 def export_python(nb, **kw):
174 """
175 Export a notebook object to Python
176 """
177 return export(PythonExporter, nb, **kw)
178
179
180 @DocDecorator
181 def export_rst(nb, **kw):
182 """
183 Export a notebook object to reStructuredText
184 """
185 return export(RSTExporter, nb, **kw)
186
187
152
188 @DocDecorator
153 @DocDecorator
189 def export_by_name(format_name, nb, **kw):
154 def export_by_name(format_name, nb, **kw):
@@ -208,10 +173,4 b' def get_export_names():'
208 """Return a list of the currently supported export targets
173 """Return a list of the currently supported export targets
209
174
210 WARNING: API WILL CHANGE IN FUTURE RELEASES OF NBCONVERT"""
175 WARNING: API WILL CHANGE IN FUTURE RELEASES OF NBCONVERT"""
211
176 return sorted(exporter_map.keys())
212 # grab everything after 'export_'
213 l = [x[len('export_'):] for x in __all__ if x.startswith('export_')]
214
215 # filter out the one method that is not a template
216 l = [x for x in l if 'by_name' not in x]
217 return sorted(l)
General Comments 0
You need to be logged in to leave comments. Login now