如何通过Nbsphinx使用Travis CI和Jupyter笔记本

2024-04-29 14:11:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在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

在特拉维斯·伊梅尔公司名称:

^{pr2}$

在要求.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尝试构建时,出现以下错误:意外缩进

Travis Log

在测试jupyter.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
}

Tags: namepy名称travistypewithsphinxextension
1条回答
网友
1楼 · 发布于 2024-04-29 14:11:45

它不适用于

.. include:: ../projects/testingjupyter.ipynb

AFAIK,这只适用于*.rst文件(请参见docutils docs)。

您应该将笔记本添加到toctree,例如

^{pr2}$

指定.ipynb扩展名是可选的。

或者,您可以将其包含在另一个带有nbsphinx-toctree元数据的笔记本中。

更新:

笔记本确实必须在源目录中。不支持从源目录外部使用笔记本,尽管它是在https://github.com/spatialaudio/nbsphinx/pull/33中建议的。

相关问题 更多 >