Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# This is processed by Jinja2 and inserted before each notebook
nbsphinx_prolog = r"""
{% set docname = 'doc/' + env.doc2path(env.docname, base=None)|string %}
{% set docname = 'doc/' + env.doc2path(env.docname, base=False)|string %}

.. raw:: html

Expand Down Expand Up @@ -77,7 +77,7 @@

# This is processed by Jinja2 and inserted after each notebook
nbsphinx_epilog = r"""
{% set docname = 'doc/' + env.doc2path(env.docname, base=None)|string %}
{% set docname = 'doc/' + env.doc2path(env.docname, base=False)|string %}
.. raw:: latex

\nbsphinxstopnotebook{\scriptsize\noindent\strut
Expand Down
1 change: 0 additions & 1 deletion doc/configuring-kernels.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
"source": [
"If you are using https://mybinder.org/ and you want to define environment variables,\n",
"you should create a file `.binder/start` in your repository\n",
"(see [Binder docs](https://mybinder.readthedocs.io/en/latest/using/config_files.html#start-run-code-before-the-user-sessions-starts))\n",
"containing definitions like this:\n",
"\n",
"```bash\n",
Expand Down
8 changes: 4 additions & 4 deletions doc/prolog-and-epilog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"You have access to the current [Sphinx build environment](https://www.sphinx-doc.org/en/master/extdev/envapi.html) via the variable `env`.\n",
"Most notably, you can get the file name of the current notebook with\n",
"\n",
" {{ env.doc2path(env.docname, base=None)|string }}\n",
" {{ env.doc2path(env.docname, base=False)|string }}\n",
"\n",
"Have a look at the [Jinja2 template documentation](https://jinja.palletsprojects.com/templates/) for more information.\n",
"\n",
Expand All @@ -42,7 +42,7 @@
"To avoid clashing braces you can try to insert additional spaces or LaTeX macros that don't have a visible effect, like e.g. `\\strut{}`.\n",
"For example, you can avoid three consecutive opening braces with something like that:\n",
"\n",
" \\texttt{\\strut{}{{ env.doc2path(env.docname, base=None)|string }}}\n",
" \\texttt{\\strut{}{{ env.doc2path(env.docname, base=False)|string }}}\n",
"\n",
"NB: The three consecutive closing braces in this example are not problematic.\n",
" \n",
Expand Down Expand Up @@ -83,7 +83,7 @@
"\n",
"```python\n",
"nbsphinx_prolog = \"\"\"\n",
"Go there: https://example.org/notebooks/{{ env.doc2path(env.docname, base=None)|string }}\n",
"Go there: https://example.org/notebooks/{{ env.doc2path(env.docname, base=False)|string }}\n",
"\n",
"----\n",
"\"\"\"\n",
Expand All @@ -93,7 +93,7 @@
"\n",
"```python\n",
"nbsphinx_prolog = r\"\"\"\n",
"{% set docname = env.doc2path(env.docname, base=None)|string %}\n",
"{% set docname = env.doc2path(env.docname, base=False)|string %}\n",
"\n",
".. only:: html\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion doc/usage.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"\n",
" python3 -m sphinx <source-dir> <build-dir> -b latex\n",
"\n",
"If you don't know how to create a PDF file from the LaTeX output, you should have a look at [Latexmk](http://personal.psu.edu/jcc8//software/latexmk-jcc/) (see also [this tutorial](https://mg.readthedocs.io/latexmk.html)).\n",
"If you don't know how to create a PDF file from the LaTeX output, you should have a look at [Latexmk](https://www.cantab.net/users/johncollins/latexmk/index.html) (see also [this tutorial](https://mg.readthedocs.io/latexmk.html)).\n",
"\n",
"Sphinx can automatically check if the links you are using are still valid.\n",
"Just invoke it like this:\n",
Expand Down
10 changes: 5 additions & 5 deletions src/nbsphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def parse(self, inputstring, document):
formats = {
'.ipynb': lambda s: nbformat.reads(s, as_version=_ipynbversion)}
formats.update(env.config.nbsphinx_custom_formats)
srcfile = str(env.doc2path(env.docname, base=None))
srcfile = str(env.doc2path(env.docname, base=False))
for format, converter in formats.items():
if srcfile.endswith(format):
break
Expand Down Expand Up @@ -655,14 +655,14 @@ def parse(self, inputstring, document):
except nbconvert.preprocessors.CellExecutionError as e:
lines = str(e).split('\n')
lines[0] = 'CellExecutionError in {}:'.format(
env.doc2path(env.docname, base=None))
env.doc2path(env.docname, base=False))
lines.append("You can ignore this error by setting the following "
"in conf.py:\n\n nbsphinx_allow_errors = True\n")
raise NotebookError('\n'.join(lines))
except Exception as e:
raise NotebookError(
type(e).__name__ + ' in ' +
str(env.doc2path(env.docname, base=None)) + ':\n' + str(e))
str(env.doc2path(env.docname, base=False)) + ':\n' + str(e))

rststring = """
.. role:: nbsphinx-math(raw)
Expand Down Expand Up @@ -1348,7 +1348,7 @@ class CreateSectionLabels(docutils.transforms.Transform):

def apply(self):
env = self.document.settings.env
file_ext = str(env.doc2path(env.docname, base=None))[len(env.docname):]
file_ext = str(env.doc2path(env.docname, base=False))[len(env.docname):]
i_still_have_to_create_the_document_label = True
for section in self.document.findall(docutils.nodes.section):
assert section.children
Expand Down Expand Up @@ -1379,7 +1379,7 @@ class CreateDomainObjectLabels(docutils.transforms.Transform):

def apply(self):
env = self.document.settings.env
file_ext = str(env.doc2path(env.docname, base=None))[len(env.docname):]
file_ext = str(env.doc2path(env.docname, base=False))[len(env.docname):]
for sig in self.document.findall(sphinx.addnodes.desc_signature):
try:
title = sig['ids'][0]
Expand Down
Loading