我试图在github存储库中使用nbsphinx和travis以及Jupyter笔记本。
存储库设置:
.
├── _docs
| ├── config.py # I added nbsphinx extension here
| ├── including.rst # File with .. include :: ../projects/testingjupyter.ipynb
| └── index.rst # basically just toctree with "including" among other titles
├── _projects
| └── testingjupyter.ipynb
├── tests
├── travis.yml
└── requirements.txt
travis.yml:
language: python
python:
- "2.7.12"
- "3.5"
- "3.5"
- "nightly"
install:
- pip install -r requirements.txt
- sudo apt-get install pandoc
script:
- py.test tests/
- travis-sphinx --source ./docs build
after_success:
- travis-sphinx --branches=master,Develop deploy
requirements.txt:
sphinx-rtd-theme==0.2.4
Sphinx==1.5.3
travis-sphinx==1.4.3
flask==0.12
jupyter
nbconvert
pandoc
nbsphinx
IPython
ipykernel
当travis-sphinx尝试构建时,会出现以下错误:意外缩进
testingjupyter.ipynb:
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Testing Jupyter"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello World\n"
]
}
],
"source": [
"print('Hello World')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
答案 0 :(得分:0)
它无法使用
.. include:: ../projects/testingjupyter.ipynb
AFAIK,仅适用于*.rst
个文件(请参阅docutils docs)。
您应该将笔记本添加到toctree
,例如
.. toctree::
:maxdepth: 3
testingjupyter
指定.ipynb
扩展名是可选的。
或者,您可以将其包含在另一个包含nbsphinx-toctree元数据的笔记本中。
<强>更新强>
笔记本确实必须在源目录中。不支持使用源目录外部的笔记本,尽管它是在https://github.com/spatialaudio/nbsphinx/pull/33中提出的。