Skip to content

Commit 3f48345

Browse files
authored
Merge pull request #57 from akhmerov/issue-56-fix
fix PDF documentation
2 parents bbe72a1 + 26fb81a commit 3f48345

File tree

2 files changed

+39
-22
lines changed

2 files changed

+39
-22
lines changed

.travis.yml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
language: python
2-
dist: bionic
3-
python:
4-
- "3.5"
5-
- "3.6"
6-
- "3.7"
2+
matrix:
3+
include:
4+
- name: "Python 3.5"
5+
dist: xenial
6+
python: 3.5
7+
- name: "Python 3.6"
8+
dist: bionic
9+
python: 3.6
10+
- name: "Python 3.7"
11+
dist: cosmic
12+
python: 3.7
13+
- name: "Docs"
14+
dist: cosmic
15+
python: 3.7
16+
# Because we are using multiple extra packages, installation is much more
17+
# involved and we use conda.
18+
install:
19+
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
20+
- bash miniconda.sh -b -p $HOME/miniconda
21+
- export PATH="$HOME/miniconda/bin:$PATH"
22+
- source "$HOME"/miniconda/etc/profile.d/conda.sh
23+
- conda config --set always_yes yes --set changeps1 no
24+
- conda env create -f environment.yml
25+
- conda activate jupyter-sphinx
26+
- python -m ipykernel install --user --name python3 --display-name "Python3"
27+
- pip install .
28+
script:
29+
- make -C doc html
30+
- make -C doc latex
731
install:
832
- pip install .
933
script:

jupyter_sphinx/execute.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,13 @@ class JupyterWidgetViewNode(docutils.nodes.Element):
201201
outputs this doctree node is rendered generically.
202202
"""
203203

204-
def __init__(self, view_spec):
205-
super().__init__('', view_spec=view_spec)
204+
def __init__(self, rawsource='', *children, **attributes):
205+
super().__init__('', view_spec=attributes['view_spec'])
206206

207207
def html(self):
208208
return ipywidgets.embed.widget_view_template.format(
209209
view_spec=json.dumps(self['view_spec']))
210210

211-
def text(self):
212-
return '[ widget ]'
213-
214211

215212
class JupyterWidgetStateNode(docutils.nodes.Element):
216213
"""Appended to doctree if any Jupyter cell produced a widget as output.
@@ -223,8 +220,8 @@ class JupyterWidgetStateNode(docutils.nodes.Element):
223220
from all script tags on the page of the correct mimetype.
224221
"""
225222

226-
def __init__(self, state):
227-
super().__init__('', state=state)
223+
def __init__(self, rawsource='', *children, **attributes):
224+
super().__init__('', state=attributes['state'])
228225

229226
def html(self):
230227
# TODO: render into a separate file if 'html-manager' starts fully
@@ -323,7 +320,7 @@ def apply(self):
323320
attach_outputs(output_nodes, node)
324321

325322
if contains_widgets(notebook):
326-
doctree.append(JupyterWidgetStateNode(get_widgets(notebook)))
323+
doctree.append(JupyterWidgetStateNode(state=get_widgets(notebook)))
327324

328325

329326
### Roles
@@ -448,7 +445,7 @@ def cell_output_to_nodes(cell, data_priority, dir):
448445
format='html',
449446
))
450447
elif mime_type == WIDGET_VIEW_MIMETYPE:
451-
to_add.append(JupyterWidgetViewNode(data))
448+
to_add.append(JupyterWidgetViewNode(view_spec=data))
452449

453450
return to_add
454451

@@ -625,17 +622,13 @@ def visit_widget_html(self, node):
625622
self.body.append(node.html())
626623
raise docutils.nodes.SkipNode
627624

628-
def visit_widget_text(self, node):
629-
self.body.append(node.text())
630-
raise docutils.nodes.SkipNode
631-
632625
app.add_node(
633626
JupyterWidgetViewNode,
634627
html=(visit_widget_html, None),
635-
latex=(visit_widget_text, None),
636-
textinfo=(visit_widget_text, None),
637-
text=(visit_widget_text, None),
638-
man=(visit_widget_text, None),
628+
latex=(skip, None),
629+
textinfo=(skip, None),
630+
text=(skip, None),
631+
man=(skip, None),
639632
)
640633
# JupyterWidgetStateNode holds the widget state JSON,
641634
# but is only rendered in HTML documents.

0 commit comments

Comments
 (0)