Skip to content

Commit

Permalink
Add export_from_notebook
Browse files Browse the repository at this point in the history
I was working on jupyter/notebook#3879 and it
looks like the intended way to determine whether the exporter should
show up in the list generated by the notebook server was by checking
`export_from_notebook`, but it isn't defined for any of the builtin
exporters.

The docs also say this specifies a friendly name for the exporter. In
the PR mentioned above, I used the name defined by the entrypoint to key
the exporter. It sounds like maybe we should use the value in
`export_from_notebook` instead, so I've made them match, but perhaps
it's confusing to have a "name" for the entrypoint in two places.
  • Loading branch information
starcruiseromega committed Aug 25, 2018
1 parent 1a7b848 commit 0802328
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions nbconvert/exporters/asciidoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def _template_file_default(self):
return 'asciidoc'

output_mimetype = 'text/asciidoc'
export_from_notebook = "asciidoc"

@default('raw_mimetypes')
def _raw_mimetypes_default(self):
Expand Down
1 change: 1 addition & 0 deletions nbconvert/exporters/latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class LatexExporter(TemplateExporter):
'template_file' config option. Place your template in the special "/latex"
subfolder of the "../templates" folder.
"""
export_from_notebook = "latex"

@default('file_extension')
def _file_extension_default(self):
Expand Down
1 change: 1 addition & 0 deletions nbconvert/exporters/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MarkdownExporter(TemplateExporter):
"""
Exports to a markdown document (.md)
"""
export_from_notebook = "markdown"

@default('file_extension')
def _file_extension_default(self):
Expand Down
1 change: 1 addition & 0 deletions nbconvert/exporters/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def _file_extension_default(self):
return '.ipynb'

output_mimetype = 'application/json'
export_from_notebook = "notebook"

def from_notebook_node(self, nb, resources=None, **kw):
nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
Expand Down
1 change: 1 addition & 0 deletions nbconvert/exporters/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class PDFExporter(LatexExporter):
a temporary directory using the template machinery, and then runs LaTeX
to create a pdf.
"""
export_from_notebook="pdf"

latex_count = Integer(3,
help="How many times latex will be called."
Expand Down
1 change: 1 addition & 0 deletions nbconvert/exporters/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ def _template_file_default(self):
return 'python.tpl'

output_mimetype = 'text/x-python'
export_from_notebook = "python"
1 change: 1 addition & 0 deletions nbconvert/exporters/rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def _template_file_default(self):
return 'rst.tpl'

output_mimetype = 'text/restructuredtext'
export_from_notebook = "rst"

@property
def default_config(self):
Expand Down
1 change: 1 addition & 0 deletions nbconvert/exporters/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ScriptExporter(TemplateExporter):
# Caches of already looked-up and instantiated exporters for delegation:
_exporters = Dict()
_lang_exporters = Dict()
export_form_notebook = "script"

@default('template_file')
def _template_file_default(self):
Expand Down
2 changes: 2 additions & 0 deletions nbconvert/exporters/slides.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def prepare(nb):
class SlidesExporter(HTMLExporter):
"""Exports HTML slides with reveal.js"""

export_from_notebook = "slides"

reveal_url_prefix = Unicode(
help="""The URL prefix for reveal.js (version 3.x).
This defaults to the reveal CDN, but can be any url pointing to a copy
Expand Down
2 changes: 2 additions & 0 deletions nbconvert/exporters/templateexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class TemplateExporter(Exporter):

_template_cached = None

export_from_notebook = "custom"

def _invalidate_template_cache(self, change=None):
self._template_cached = None

Expand Down

0 comments on commit 0802328

Please sign in to comment.