Skip to content

Commit 49ed35e

Browse files
committed
Add hosted notebook instructions
1 parent 56c0347 commit 49ed35e

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

irrelevant/notebook_generator.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,27 @@
3232

3333
STATEMENT_PREFIXES = ["...", ">>> ", "$ "]
3434

35+
HOSTED_NOTEBOOK_INSTRUCTIONS = """
36+
37+
# Hosted notebook instructions
38+
39+
This is just an experimental attempt of browsing wtfpython through jupyter notebooks. Some examples are read-only because,
40+
- they either require a version of Python that's not supported in the hosted runtime.
41+
- or they can't be reproduced in the notebook envrinonment.
42+
43+
The expected outputs are already present in collapsed cells following the code cells. The Google colab provides Python2 (2.7) and Python3 (3.6, default) runtimes. You can switch among these for Python2 specific examples. For examples specific to other minor versions, you can simply refer to collapsed outputs (it's not possible to control the minor version in hosted notebooks as of now). You can check the active version using
44+
45+
```py
46+
>>> import sys
47+
>>> sys.version
48+
# Prints out Python version here.
49+
```
50+
51+
That being said, most of tbe examples do work as expected. If you face any trouble, feel free to consult the original content on wtfpython and create an issue in the repo. Have fun!
52+
53+
---
54+
"""
55+
3556

3657
def generate_code_block(statements, output):
3758
global sequence_num
@@ -255,7 +276,7 @@ def convert_to_notebook(pre_examples_content, parsed_json, post_examples_content
255276
"nbformat_minor": 2
256277
}
257278

258-
notebook_path = "test.ipynb"
279+
notebook_path = "wtf.ipynb"
259280

260281
result["cells"] += convert_to_cells([generate_markdown_block(pre_examples_content)], False)
261282

@@ -328,4 +349,5 @@ def convert_to_notebook(pre_examples_content, parsed_json, post_examples_content
328349

329350
except StopIteration as e:
330351
#pprint.pprint(result, indent=2)
352+
pre_stuff.append(HOSTED_NOTEBOOK_INSTRUCTIONS)
331353
convert_to_notebook(pre_stuff, result, post_stuff)

0 commit comments

Comments
 (0)