##// END OF EJS Templates
Decorator for docstrings referring to objects imported from nbformat.current
Thomas Kluyver -
Show More
@@ -32,9 +32,6 b' from IPython.utils.traitlets import MetaHasTraits, Unicode, List'
32 from IPython.utils.importstring import import_item
32 from IPython.utils.importstring import import_item
33 from IPython.utils import text, py3compat
33 from IPython.utils import text, py3compat
34
34
35 from IPython.nbconvert import preprocessors as nbpreprocessors
36
37
38 #-----------------------------------------------------------------------------
35 #-----------------------------------------------------------------------------
39 # Class
36 # Class
40 #-----------------------------------------------------------------------------
37 #-----------------------------------------------------------------------------
@@ -96,14 +93,14 b' class Exporter(LoggingConfigurable):'
96 def default_config(self):
93 def default_config(self):
97 return Config()
94 return Config()
98
95
99
96 @nbformat.docstring_nbformat_mod
100 def from_notebook_node(self, nb, resources=None, **kw):
97 def from_notebook_node(self, nb, resources=None, **kw):
101 """
98 """
102 Convert a notebook from a notebook node instance.
99 Convert a notebook from a notebook node instance.
103
100
104 Parameters
101 Parameters
105 ----------
102 ----------
106 nb : :class:`~IPython.nbformat.v3.nbbase.NotebookNode`
103 nb : :class:`~{nbformat_mod}.nbbase.NotebookNode`
107 Notebook node
104 Notebook node
108 resources : dict
105 resources : dict
109 Additional resources that can be accessed read/write by
106 Additional resources that can be accessed read/write by
@@ -27,6 +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 IPython.nbformat.current import docstring_nbformat_mod
30 from IPython.nbconvert import filters
31 from IPython.nbconvert import filters
31 from .exporter import Exporter
32 from .exporter import Exporter
32
33
@@ -186,14 +187,15 b' class TemplateExporter(Exporter):'
186 else:
187 else:
187 self.log.info("Loaded template %s", try_name)
188 self.log.info("Loaded template %s", try_name)
188 break
189 break
189
190
191 @docstring_nbformat_mod
190 def from_notebook_node(self, nb, resources=None, **kw):
192 def from_notebook_node(self, nb, resources=None, **kw):
191 """
193 """
192 Convert a notebook from a notebook node instance.
194 Convert a notebook from a notebook node instance.
193
195
194 Parameters
196 Parameters
195 ----------
197 ----------
196 nb : :class:`~IPython.nbformat.v3.nbbase.NotebookNode`
198 nb : :class:`~{nbformat_mod}.nbbase.NotebookNode`
197 Notebook node
199 Notebook node
198 resources : dict
200 resources : dict
199 Additional resources that can be accessed read/write by
201 Additional resources that can be accessed read/write by
@@ -30,6 +30,7 b' from IPython.nbformat.v3 import ('
30 parse_filename, new_metadata, new_author, new_heading_cell, nbformat,
30 parse_filename, new_metadata, new_author, new_heading_cell, nbformat,
31 nbformat_minor, to_notebook_json
31 nbformat_minor, to_notebook_json
32 )
32 )
33 from IPython.nbformat import v3 as _v_latest
33
34
34 from .reader import reads as reader_reads
35 from .reader import reads as reader_reads
35 from .reader import versions
36 from .reader import versions
@@ -41,6 +42,16 b' from .convert import convert'
41
42
42 current_nbformat = nbformat
43 current_nbformat = nbformat
43 current_nbformat_minor = nbformat_minor
44 current_nbformat_minor = nbformat_minor
45 current_nbformat_module = _v_latest.__name__
46
47 def docstring_nbformat_mod(func):
48 """Decorator for docstrings referring to classes/functions accessed through
49 nbformat.current.
50
51 Put {nbformat_mod} in the docstring in place of 'IPython.nbformat.v3'.
52 """
53 func.__doc__ = func.__doc__.format(nbformat_mod=current_nbformat_module)
54 return func
44
55
45
56
46 class NBFormatError(ValueError):
57 class NBFormatError(ValueError):
General Comments 0
You need to be logged in to leave comments. Login now