diff --git a/doc/subdir2/included.ipynb b/doc/subdir2/included.ipynb index bc3af168..e7f1c25b 100644 --- a/doc/subdir2/included.ipynb +++ b/doc/subdir2/included.ipynb @@ -49,9 +49,6 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.5.1+" - }, - "nbsphinx": { - "orphan": true } }, "nbformat": 4, diff --git a/nbsphinx.py b/nbsphinx.py index 3b884a71..fc0bfad3 100644 --- a/nbsphinx.py +++ b/nbsphinx.py @@ -401,11 +401,12 @@ def get_transforms(self): return rst.Parser.get_transforms(self) + [ProcessLocalLinks, CreateSectionLabels] - def parse(self, inputstring, document): + def parse(self, inputstring, document, srcdir=None): """Parse `inputstring`, write results to `document`.""" nb = nbformat.reads(inputstring, as_version=_ipynbversion) env = document.settings.env - srcdir = os.path.dirname(env.doc2path(env.docname)) + if srcdir is None: + srcdir = os.path.dirname(env.doc2path(env.docname)) auxdir = os.path.join(env.doctreedir, 'nbsphinx') sphinx.util.ensuredir(auxdir) @@ -585,7 +586,7 @@ def run(self): # Use the NotebookParser to get doctree nodes nbparser = NotebookParser() node = docutils.utils.new_document(path, settings) - nbparser.parse(rawtext, node) + nbparser.parse(rawtext, node, srcdir=os.path.dirname(path)) if isinstance(node.children[0], docutils.nodes.field_list): return node.children[1:] return node.children