Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add support for exclusion of Next and Previous metadata in conf.py #330

Merged
merged 1 commit into from
Jun 15, 2020
Merged
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
1 change: 1 addition & 0 deletions sphinxcontrib/jupyter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def setup(app):
app.add_config_value("jupyter_template_path", "templates", "jupyter")
app.add_config_value("jupyter_dependencies", None, "jupyter")
app.add_config_value("jupyter_download_nb_execute", None, "jupyter")
app.add_config_value("jupyter_nextprev_ignore", [], "jupyter")

# Jupyter pdf options
app.add_config_value("jupyter_latex_template", None, "jupyter")
Expand Down
32 changes: 22 additions & 10 deletions sphinxcontrib/jupyter/builders/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,32 @@ def update_Metadata(self, docname, nb):
titles = self.env.titles
if related and related[2]:
try:
next_doc = {
'link': self.get_relative_uri(docname, related[2]),
'title': titles[related[2]].children[0].astext()
}
nb.metadata.next_doc = next_doc
link = self.get_relative_uri(docname, related[2])
title = titles[related[2]].children[0].astext()
# link is document uri (i.e. docname) as specified in index
if link in self.config.jupyter_nextprev_ignore:
pass
else:
next_doc = {
'link': link,
'title': title
}
nb.metadata.next_doc = next_doc
except KeyError:
nb.metadata.next_doc = False
if related and related[1]:
try:
prev_doc = {
'link': self.get_relative_uri(docname, related[1]),
'title': titles[related[1]].children[0].astext()
}
nb.metadata.prev_doc = prev_doc
link = self.get_relative_uri(docname, related[1])
title = titles[related[1]].children[0].astext()
# link is document uri (i.e. docname) as specified in index
if link in self.config.jupyter_nextprev_ignore:
pass
else:
prev_doc = {
'link': link,
'title': title
}
nb.metadata.prev_doc = prev_doc
except KeyError:
nb.metadata.prev_doc = False
# Set Compile Datetime
Expand Down