Skip to content

Commit

Permalink
Execute included notebook from its directory
Browse files Browse the repository at this point in the history
  • Loading branch information
tbekolay committed Apr 9, 2016
1 parent b1255d1 commit 387df6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 0 additions & 3 deletions doc/subdir2/included.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.1+"
},
"nbsphinx": {
"orphan": true
}
},
"nbformat": 4,
Expand Down
7 changes: 4 additions & 3 deletions nbsphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 387df6f

Please sign in to comment.