3.3.6. Sphinx thebe#
使您的代码单元与 Thebe 和 Binder 提供的内核进行交互。
例如,单击下面的按钮。请注意,下面的代码块变为可编辑和可运行的!(由于网络问题,运行按钮可能会显示失败)
print("hi")
```{thebe-button} Launch thebe
```
```{code-block} python
:class: thebe
print("hi")
```
3.3.6.1. 配置运行环境#
To install sphinx-thebe
:
pip install sphinx-thebe
Then, add it to your Sphinx site’s conf.py
file:
extensions = [
...
"sphinx_thebe"
...
]
thebe_config = {
"repository_url": "https://github.com/binder-examples/jupyter-stacks-datascience",
"repository_branch": "master",
}
See also
在这里,笔者只是简单的提供一个关于实现交互式笔记的思路,更多关于 thebe
的信息前往其官方文档:
thebe
依靠于myst_nb
解析;MyST-NB 文档
不过笔者现阶段不推荐使用 MyST Markdown 语法编写交互式笔记,如果读者有相关需要,那么推荐更加成熟的交互式笔记方案—— Jupyter Notebook 。myst_nb
能够解析 Jupyter Notebook(以.ipynb
结尾)。
Warning
默认情况下,sphinx-thebe
将为 jupyter-stacks-datascience 存储库提供 Binder 环境 。但是需要注意的是,这个是一个实验性的存储库,所以这并不是一个成熟的笔记方案。