Hello community,
here is the log from the commit of package python-nbsphinx for openSUSE:Factory
checked in at 2020-06-10 00:50:03
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-nbsphinx (Old)
and /work/SRC/openSUSE:Factory/.python-nbsphinx.new.3606 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-nbsphinx"
Wed Jun 10 00:50:03 2020 rev:6 rq:812828 version:0.7.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-nbsphinx/python-nbsphinx.changes
2020-05-26 17:22:05.792332908 +0200
+++
/work/SRC/openSUSE:Factory/.python-nbsphinx.new.3606/python-nbsphinx.changes
2020-06-10 00:50:05.507207998 +0200
@@ -1,0 +2,9 @@
+Tue Jun 9 08:42:49 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Update to 0.7.0:
+ * Warnings can be suppressed with suppress_warnings.
+ * CSS: prompts protrude into left margin if nbsphinx_prompt_width is
+too small
+ * <img> tags are handled in Markdown cells
+
+-------------------------------------------------------------------
Old:
----
nbsphinx-0.6.1.tar.gz
New:
----
nbsphinx-0.7.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-nbsphinx.spec ++++++
--- /var/tmp/diff_new_pack.9oEFXW/_old 2020-06-10 00:50:06.779211326 +0200
+++ /var/tmp/diff_new_pack.9oEFXW/_new 2020-06-10 00:50:06.779211326 +0200
@@ -19,26 +19,25 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define skip_python2 1
Name: python-nbsphinx
-Version: 0.6.1
+Version: 0.7.0
Release: 0
Summary: Jupyter Notebook Tools for Sphinx
License: MIT
-Group: Development/Languages/Python
URL: https://github.com/spatialaudio/nbsphinx/
Source:
https://files.pythonhosted.org/packages/source/n/nbsphinx/nbsphinx-%{version}.tar.gz
-BuildRequires: %{python_module Send2Trash}
-BuildRequires: %{python_module Sphinx >= 1.3.2}
+BuildRequires: %{python_module Sphinx >= 1.8}
BuildRequires: %{python_module docutils}
BuildRequires: %{python_module setuptools}
+BuildRequires: %{python_module traitlets}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-Jinja2
-Requires: python-Send2Trash
-Requires: python-Sphinx >= 1.3.2
+Requires: python-Sphinx >= 1.8
Requires: python-docutils
Requires: python-nbconvert
Requires: python-nbformat
Requires: python-sphinx_rtd_theme
+Requires: python-traitlets
Recommends: mathjax
Recommends: pandoc
Provides: python-jupyter_nbsphinx = %{version}
@@ -67,7 +66,7 @@
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
-%{fdupes %{buildroot}%{_jupyter_prefix} %{buildroot}%{python_sitelib}}
+%fdupes %{buildroot}%{_jupyter_prefix}
%files %{python_files}
%doc NEWS.rst README.rst
++++++ nbsphinx-0.6.1.tar.gz -> nbsphinx-0.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/NEWS.rst new/nbsphinx-0.7.0/NEWS.rst
--- old/nbsphinx-0.6.1/NEWS.rst 2020-04-18 17:47:19.000000000 +0200
+++ new/nbsphinx-0.7.0/NEWS.rst 2020-05-08 13:42:27.000000000 +0200
@@ -1,3 +1,11 @@
+Version 0.7.0 (2020-05-08):
+ * Warnings can be suppressed with ``suppress_warnings``.
+ * ``<img>`` tags are handled in Markdown cells; the ``alt``, ``width``,
+ ``height`` and ``class`` attributes are supported.
+ * CSS: prompts protrude into left margin if ``nbsphinx_prompt_width`` is
+ too small. If you want to hide the prompts, use `custom CSS`__.
+
+ __ https://nbsphinx.readthedocs.io/en/0.7.0/custom-css.html
Version 0.6.1 (2020-04-18):
* ``.ipynb_checkpoints`` is automatically added to ``exclude_patterns``
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/PKG-INFO new/nbsphinx-0.7.0/PKG-INFO
--- old/nbsphinx-0.6.1/PKG-INFO 2020-04-18 17:49:36.697565000 +0200
+++ new/nbsphinx-0.7.0/PKG-INFO 2020-05-08 13:45:10.372964600 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: nbsphinx
-Version: 0.6.1
+Version: 0.7.0
Summary: Jupyter Notebook Tools for Sphinx
Home-page: https://nbsphinx.readthedocs.io/
Author: Matthias Geier
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/conf.py
new/nbsphinx-0.7.0/doc/conf.py
--- old/nbsphinx-0.6.1/doc/conf.py 2020-04-18 17:39:50.000000000 +0200
+++ new/nbsphinx-0.7.0/doc/conf.py 2020-05-07 14:56:57.000000000 +0200
@@ -13,6 +13,7 @@
'sphinxcontrib.bibtex', # for bibliographic references
'sphinxcontrib.rsvgconverter', # for SVG->PDF conversion in LaTeX output
'sphinx_gallery.load_style', # load CSS for gallery (needs SG >= 0.6)
+ 'sphinx_last_updated_by_git', # get "last updated" from Git
]
# Default language for syntax highlighting in reST and Markdown cells:
@@ -45,24 +46,20 @@
.. raw:: html
<div class="admonition note">
- <p>This page was generated from
- <a class="reference external"
href="https://github.com/spatialaudio/nbsphinx/blob/{{ env.config.release|e
}}/{{ docname|e }}">{{ docname|e }}</a>.
- Interactive online version:
- <a href="https://mybinder.org/v2/gh/spatialaudio/nbsphinx/{{
env.config.release|e }}?filepath={{ docname|e }}"><img alt="Binder badge"
src="https://mybinder.org/badge_logo.svg"
style="vertical-align:text-bottom"></a>.
- </p>
+ This page was generated from
+ <a class="reference external"
href="https://github.com/spatialaudio/nbsphinx/blob/{{ env.config.release|e
}}/{{ docname|e }}">{{ docname|e }}</a>.
+ Interactive online version:
+ <a href="https://mybinder.org/v2/gh/spatialaudio/nbsphinx/{{
env.config.release|e }}?filepath={{ docname|e }}"><img alt="Binder badge"
src="https://mybinder.org/badge_logo.svg"
style="vertical-align:text-bottom"></a>.
<script>
if (document.location.host) {
- var p = document.currentScript.previousSibling.previousSibling;
- var a = document.createElement('a');
- a.innerHTML = 'View in <em>nbviewer</em>';
- a.href = `https://nbviewer.jupyter.org/url${
+ $(document.currentScript).replaceWith(
+ '<a class="reference external" ' +
+ 'href="https://nbviewer.jupyter.org/url' +
(window.location.protocol == 'https:' ? 's/' : '/') +
window.location.host +
- window.location.pathname.slice(0, -4) }ipynb`;
- a.classList.add('reference');
- a.classList.add('external');
- p.appendChild(a);
- p.appendChild(document.createTextNode('.'));
+ window.location.pathname.slice(0, -4) +
+ 'ipynb">View in <em>nbviewer</em></a>.'
+ );
}
</script>
</div>
@@ -104,7 +101,10 @@
author = 'Matthias Geier'
copyright = '2020, ' + author
-linkcheck_ignore = [r'http://localhost:\d+/']
+linkcheck_ignore = [
+ r'http://localhost:\d+/',
+ 'https://github.com/spatialaudio/nbsphinx/compare/',
+]
# -- Get version information and date from Git ----------------------------
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/custom-css.ipynb
new/nbsphinx-0.7.0/doc/custom-css.ipynb
--- old/nbsphinx-0.6.1/doc/custom-css.ipynb 1970-01-01 01:00:00.000000000
+0100
+++ new/nbsphinx-0.7.0/doc/custom-css.ipynb 2020-04-26 19:18:32.000000000
+0200
@@ -0,0 +1,151 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Custom CSS\n",
+ "\n",
+ "If you are not satisfied with the CSS styles\n",
+ "provided by `nbsphinx`\n",
+ "and by your Sphinx theme,\n",
+ "don't worry,\n",
+ "you can add your own styles easily."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## For All Pages\n",
+ "\n",
+ "Just create your own CSS file, e.g. `my-own-style.css`,\n",
+ "and put it into the `_static/` sub-directory\n",
+ "of your source directory.\n",
+ "\n",
+ "You'll also have to set the config values\n",
+
"[html_static_path](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path)\n",
+ "and\n",
+
"[html_css_files](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files)\n",
+ "in your `conf.py`, e.g. like this:\n",
+ "\n",
+ "```python\n",
+ "html_static_path = ['_static']\n",
+ "html_css_files = ['my-own-style.css']\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## For All RST files\n",
+ "\n",
+ "If you want your style to only apply to `*.rst` files\n",
+ "(and not Jupyter notebooks or other source files),\n",
+ "you can use\n",
+
"[rst_prolog](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-rst_prolog)\n",
+ "with the\n",
+
"[raw](https://docutils.sourceforge.io/docs/ref/rst/directives.html#raw-data-pass-through)\n",
+ "directive in your `conf.py` like this:\n",
+ "\n",
+ "```python\n",
+ "rst_prolog = \"\"\"\n",
+ ".. raw:: html\n",
+ "\n",
+ " <style>\n",
+ " h1 {\n",
+ " color: fuchsia;\n",
+ " }\n",
+ " </style>\n",
+ "\"\"\"\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## For All Notebooks\n",
+ "\n",
+ "Similarly,\n",
+ "if you want your style to only apply to notebooks,\n",
+ "you can use [nbsphinx_prolog](prolog-and-epilog.ipynb)\n",
+ "like this:\n",
+ "\n",
+ "```python\n",
+ "nbsphinx_prolog = \"\"\"\n",
+ ".. raw:: html\n",
+ "\n",
+ " <style>\n",
+ " h1 {\n",
+ " color: chartreuse;\n",
+ " }\n",
+ " </style>\n",
+ "\"\"\"\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## For a Single Notebook\n",
+ "\n",
+ "For styles that should affect only the current notebook,\n",
+ "you can simply insert `<style>` tags\n",
+ "into Markdown cells like this:\n",
+ "\n",
+ "```html\n",
+ "<style>\n",
+ " .nbinput .prompt,\n",
+ " .nboutput .prompt {\n",
+ " display: none;\n",
+ " }\n",
+ "</style> \n",
+ "```\n",
+ "\n",
+ "<style>\n",
+ " .nbinput .prompt,\n",
+ " .nboutput .prompt {\n",
+ " display: none;\n",
+ " }\n",
+ "</style>\n",
+ "\n",
+ "This CSS example removes the input and output prompts\n",
+ "from code cells,\n",
+ "see the following cell:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "6 * 7"
+ ]
+ }
+ ],
+ "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.8.2"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/index.rst
new/nbsphinx-0.7.0/doc/index.rst
--- old/nbsphinx-0.6.1/doc/index.rst 2020-04-18 17:39:50.000000000 +0200
+++ new/nbsphinx-0.7.0/doc/index.rst 2020-04-26 19:18:32.000000000 +0200
@@ -18,6 +18,7 @@
prolog-and-epilog
custom-formats
subdir/*
+ custom-css
a-normal-rst-file
links
contributing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/links.ipynb
new/nbsphinx-0.7.0/doc/links.ipynb
--- old/nbsphinx-0.6.1/doc/links.ipynb 2020-04-18 17:39:50.000000000 +0200
+++ new/nbsphinx-0.7.0/doc/links.ipynb 2020-05-07 12:57:59.000000000 +0200
@@ -79,13 +79,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
- "**jupyter-book**\n",
+ "**jupyterbook**\n",
"\n",
- "Create an online book with Jupyter Notebooks and Jekyll\n",
+ "Jupyter Book is an open source project for building beautiful,
publication-quality books and documents from computational material.\n",
"\n",
- "https://jupyter.org/jupyter-book\n",
+ "https://jupyterbook.org/\n",
"\n",
- "https://github.com/jupyter/jupyter-book"
+ "https://github.com/executablebooks/jupyter-book\n",
+ "\n",
+ "Previous tagline: \"Create an online book with Jupyter Notebooks and
Jekyll\":\n",
+ "https://legacy.jupyterbook.org/"
]
},
{
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/markdown-cells.ipynb
new/nbsphinx-0.7.0/doc/markdown-cells.ipynb
--- old/nbsphinx-0.6.1/doc/markdown-cells.ipynb 2020-04-18 17:39:50.000000000
+0200
+++ new/nbsphinx-0.7.0/doc/markdown-cells.ipynb 2020-04-26 19:18:32.000000000
+0200
@@ -246,8 +246,39 @@
"\n",
"Remote image: \n",
"\n",
- " \n",
+ " "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "### Using the HTML `<img>` tag\n",
+ "\n",
+ "The aforementioned Markdown syntax for including images\n",
+ "doesn't allow specifying the image size.\n",
+ "\n",
+ "If you want to control the size of the included image,\n",
+ "you can use the HTML\n",
+
"[\\<img\\>](https://www.w3.org/TR/html52/semantics-embedded-content.html#the-img-element)\n",
+ "element with the `width` attribute like this:\n",
+ "\n",
+ "```html\n",
+ "<img src=\"images/notebook_icon.png\" alt=\"Jupyter notebook icon\"
width=\"300\">\n",
+ "```\n",
"\n",
+ "<img src=\"images/notebook_icon.png\" alt=\"Jupyter notebook icon\"
width=\"300\">\n",
+ "\n",
+ "In addition to the `src`, `alt`, `width` and `height` attributes,\n",
+ "you can also use the `class` attribute,\n",
+ "which is simply forwarded to the HTML output (and ignored in LaTeX
output).\n",
+ "All other attributes are ignored."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### SVG support for LaTeX\n",
"\n",
"LaTeX doesn't support SVG images, but there are Sphinx extensions that
can be used for automatically converting SVG images for inclusion in LaTeX
output.\n",
@@ -257,19 +288,20 @@
"in your `conf.py` file.\n",
"\n",
"* `'sphinxcontrib.inkscapeconverter'` or
`'sphinxcontrib.rsvgconverter'`:\n",
- " See
https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter\n",
- " for installation instructions.\n",
- " \n",
- " The external programs `inkscape` or `rsvg-convert` (Debian/Ubuntu
package `librsvg2-bin`)\n",
- " are needed, respectively.\n",
+ " See
https://github.com/missinglinkelectronics/sphinxcontrib-svg2pdfconverter\n",
+ " for installation instructions.\n",
+ "\n",
+ " The external programs `inkscape` or `rsvg-convert`\n",
+ " (Debian/Ubuntu package `librsvg2-bin`)\n",
+ " are needed, respectively.\n",
"\n",
"* `'sphinx.ext.imgconverter'`:\n",
- " This is a built-in Sphinx extension, see\n",
- "
https://www.sphinx-doc.org/en/master/usage/extensions/imgconverter.html.\n",
- " \n",
- " This needs the external program `convert` from *ImageMagick*.\n",
+ " This is a built-in Sphinx extension, see\n",
+ "
https://www.sphinx-doc.org/en/master/usage/extensions/imgconverter.html.\n",
+ "\n",
+ " This needs the external program `convert` from *ImageMagick*.\n",
"\n",
- " The disadvantage of this extension is that SVGs are converted to bitmap
images.\n",
+ " The disadvantage of this extension is that SVGs are converted to
bitmap images.\n",
"\n",
"If one of those extensions is installed, SVG images can be used even for
LaTeX output:\n",
"\n",
@@ -443,8 +475,7 @@
"\n",
"```\n",
"[beginning of this section](#Links-to-Other-Notebooks)\n",
- "```",
- "\n",
+ "```\n",
"It's also possible to create a\n",
"[link to the beginning of the current page](#),\n",
"by simply using a `#` character:\n",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/requirements.txt
new/nbsphinx-0.7.0/doc/requirements.txt
--- old/nbsphinx-0.6.1/doc/requirements.txt 2020-04-18 17:39:50.000000000
+0200
+++ new/nbsphinx-0.7.0/doc/requirements.txt 2020-04-28 14:34:51.000000000
+0200
@@ -8,3 +8,4 @@
sphinx-copybutton
sphinx-gallery
jupytext
+sphinx-last-updated-by-git
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/doc/usage.ipynb
new/nbsphinx-0.7.0/doc/usage.ipynb
--- old/nbsphinx-0.6.1/doc/usage.ipynb 2020-04-18 17:39:50.000000000 +0200
+++ new/nbsphinx-0.7.0/doc/usage.ipynb 2020-05-08 13:26:03.000000000 +0200
@@ -142,6 +142,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
+ "#### `html_css_files`\n",
+ "\n",
+ "See [Custom CSS](custom-css.ipynb) and\n",
+
"[html_css_files](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_css_files)."
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"#### `html_scaled_image_link`\n",
"\n",
"As a work-around -- until
https://github.com/sphinx-doc/sphinx/issues/4229 is solved --\n",
@@ -200,6 +210,45 @@
"cell_type": "markdown",
"metadata": {},
"source": [
+ "#### `suppress_warnings`\n",
+ "\n",
+ "Warnings can be really helpful to detect small mistakes,\n",
+ "and you should consider invoking Sphinx with the\n",
+
"[-W](https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-W)\n",
+ "option,\n",
+ "which turns warnings into errors.\n",
+ "However, warnings can also be annoying,\n",
+ "especially if you are fully aware of the \"problem\",\n",
+ "but you simply don't care about it for some reason.\n",
+ "In this case, you can use\n",
+
"[suppress_warnings](https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-suppress_warnings)\n",
+ "to silence specific types of warnings.\n",
+ "\n",
+ "If you want to suppress all warnings from `nbsphinx`, use this:\n",
+ "\n",
+ "```python\n",
+ "suppress_warnings = [\n",
+ " 'nbsphinx',\n",
+ "]\n",
+ "```\n",
+ "\n",
+ "You can also be more specific:\n",
+ "\n",
+ "```python\n",
+ "suppress_warnings = [\n",
+ " 'nbsphinx.localfile',\n",
+ " 'nbsphinx.gallery',\n",
+ " 'nbsphinx.thumbnail',\n",
+ " 'nbsphinx.notebooktitle',\n",
+ " 'nbsphinx.ipywidgets',\n",
+ "]\n",
+ "```"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"### `nbsphinx` Configuration Values"
]
},
@@ -345,6 +394,8 @@
"\n",
"Width of input/output prompts (HTML only).\n",
"\n",
+ "If a prompt is wider than that, it protrudes into the left margin.\n",
+ "\n",
"Any CSS length can be specified."
]
},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/src/nbsphinx.egg-info/PKG-INFO
new/nbsphinx-0.7.0/src/nbsphinx.egg-info/PKG-INFO
--- old/nbsphinx-0.6.1/src/nbsphinx.egg-info/PKG-INFO 2020-04-18
17:49:36.000000000 +0200
+++ new/nbsphinx-0.7.0/src/nbsphinx.egg-info/PKG-INFO 2020-05-08
13:45:10.000000000 +0200
@@ -1,6 +1,6 @@
Metadata-Version: 1.2
Name: nbsphinx
-Version: 0.6.1
+Version: 0.7.0
Summary: Jupyter Notebook Tools for Sphinx
Home-page: https://nbsphinx.readthedocs.io/
Author: Matthias Geier
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/src/nbsphinx.egg-info/SOURCES.txt
new/nbsphinx-0.7.0/src/nbsphinx.egg-info/SOURCES.txt
--- old/nbsphinx-0.6.1/src/nbsphinx.egg-info/SOURCES.txt 2020-04-18
17:49:36.000000000 +0200
+++ new/nbsphinx-0.7.0/src/nbsphinx.egg-info/SOURCES.txt 2020-05-08
13:45:10.000000000 +0200
@@ -12,6 +12,7 @@
doc/conf.py
doc/configuring-kernels.ipynb
doc/contributing.rst
+doc/custom-css.ipynb
doc/executing-notebooks.ipynb
doc/hidden-cells.ipynb
doc/index.rst
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/nbsphinx-0.6.1/src/nbsphinx.py
new/nbsphinx-0.7.0/src/nbsphinx.py
--- old/nbsphinx-0.6.1/src/nbsphinx.py 2020-04-18 17:45:08.000000000 +0200
+++ new/nbsphinx-0.7.0/src/nbsphinx.py 2020-05-08 13:43:41.000000000 +0200
@@ -23,7 +23,7 @@
https://nbsphinx.readthedocs.io/
"""
-__version__ = '0.6.1'
+__version__ = '0.7.0'
import collections.abc
import copy
@@ -33,6 +33,7 @@
import re
import subprocess
from urllib.parse import unquote
+import uuid
import docutils
from docutils.parsers import rst
@@ -96,6 +97,8 @@
{% block any_cell %}
{%- if cell.metadata.nbsphinx != 'hidden' %}
{{ super() }}
+..
+{# Empty comment to make sure the preceding directive (if any) is closed #}
{% endif %}
{%- endblock any_cell %}
@@ -200,6 +203,8 @@
{% block nboutput -%}
+..
+{# Empty comment to make sure the preceding directive (if any) is closed #}
{%- set html_datatype, latex_datatype = output | get_output_type %}
{%- if html_datatype == latex_datatype %}
{{ insert_nboutput(html_datatype, output, cell) }}
@@ -251,12 +256,8 @@
{{ cell.source | indent }}
{%- elif raw_mimetype == 'text/markdown' %}
-..
-{# Empty comment to make sure the preceding directive (if any) is closed #}
{{ cell.source | markdown2rst }}
{%- elif raw_mimetype == 'text/restructuredtext' %}
-..
-{# Empty comment to make sure the preceding directive (if any) is closed #}
{{ cell.source }}
{% endif %}
{% endblock rawcell %}
@@ -485,21 +486,34 @@
/* all prompts */
div.nbinput.container div.prompt,
div.nboutput.container div.prompt {
- min-width: %(nbsphinx_prompt_width)s;
- padding-top: 0.3rem;
- padding-right: 0.3rem;
- text-align: right;
- flex: 0;
+ width: %(nbsphinx_prompt_width)s;
+ padding-top: 5px;
+ position: relative;
+ user-select: none;
}
+
+div.nbinput.container div.prompt > div,
+div.nboutput.container div.prompt > div {
+ position: absolute;
+ right: 0;
+ margin-right: 0.3ex;
+}
+
@media (max-width: %(nbsphinx_responsive_width)s) {
div.nbinput.container div.prompt,
div.nboutput.container div.prompt {
+ width: unset;
text-align: left;
padding: 0.4em;
}
div.nboutput.container div.prompt.empty {
padding: 0;
}
+
+ div.nbinput.container div.prompt > div,
+ div.nboutput.container div.prompt > div {
+ position: unset;
+ }
}
/* disable scrollbars on prompts */
@@ -591,7 +605,7 @@
div.nboutput.container div.output_area.rendered_html,
div.nboutput.container div.output_area > div.output_javascript,
div.nboutput.container div.output_area:not(.rendered_html) > img{
- padding: 0.3rem;
+ padding: 5px;
}
/* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */
@@ -812,7 +826,8 @@
def warning(msg, *args):
logger.warning(
'"nbsphinx-thumbnail": ' + msg, *args,
- location=resources.get('nbsphinx_docname'))
+ location=resources.get('nbsphinx_docname'),
+ type='nbsphinx', subtype='thumbnail')
thumbnail['filename'] = _BROKEN_THUMBNAIL
for cell_index, cell in enumerate(nb.cells):
@@ -1232,6 +1247,45 @@
self.cite = ''
+class ImgParser(html.parser.HTMLParser):
+ """Turn HTML <img> tags into raw RST blocks."""
+
+ def handle_starttag(self, tag, attrs):
+ self._check_img(tag, attrs)
+
+ def handle_startendtag(self, tag, attrs):
+ self._check_img(tag, attrs)
+
+ def _check_img(self, tag, attrs):
+ if tag != 'img':
+ return
+ # NB: attrs is a list of pairs
+ attrs = dict(attrs)
+ if 'src' not in attrs:
+ return
+ img_path = nbconvert.filters.posix_path(attrs['src'])
+ lines = ['image:: ' + img_path]
+ indent = ' ' * 4
+ if 'class' in attrs:
+ lines.append(indent + ':class: ' + attrs['class'])
+ if 'alt' in attrs:
+ lines.append(indent + ':alt: ' + attrs['alt'])
+ if 'width' in attrs:
+ lines.append(indent + ':width: ' + attrs['width'])
+ if 'height' in attrs:
+ lines.append(indent + ':height: ' + attrs['height'])
+
+ definition = '\n'.join(lines)
+ hex_id = uuid.uuid4().hex
+ definition = '.. |' + hex_id + '| ' + definition
+ self.obj = {'t': 'RawInline', 'c': ['rst', '|' + hex_id + '|']}
+ self.definition = definition
+
+ def reset(self):
+ super().reset()
+ self.obj = {}
+
+
def markdown2rst(text):
"""Convert a Markdown string to reST via pandoc.
@@ -1246,16 +1300,22 @@
"""
- def parse_html(obj):
+ def parse_citation(obj):
p = CitationParser()
p.feed(obj['c'][1])
p.close()
return p
+ def parse_img(obj):
+ p = ImgParser()
+ p.feed(obj['c'][1])
+ p.close()
+ return p
+
def object_hook(obj):
if object_hook.open_cite_tag:
if obj.get('t') == 'RawInline' and obj['c'][0] == 'html':
- p = parse_html(obj)
+ p = parse_citation(obj)
if p.endtag == object_hook.open_cite_tag:
object_hook.open_cite_tag = ''
return {'t': 'Str', 'c': ''} # Object is replaced by empty string
@@ -1274,14 +1334,20 @@
obj = {'t': 'RawInline',
'c': ['rst', ':nbsphinx-math:`{}`'.format(obj['c'][1])]}
elif obj.get('t') == 'RawInline' and obj['c'][0] == 'html':
- p = parse_html(obj)
+ p = parse_citation(obj)
if p.starttag:
object_hook.open_cite_tag = p.starttag
if p.cite:
obj = {'t': 'RawInline', 'c': ['rst', p.cite]}
+ if not p.starttag and not p.cite:
+ p = parse_img(obj)
+ if p.obj:
+ obj = p.obj
+ object_hook.image_definitions.append(p.definition)
return obj
object_hook.open_cite_tag = ''
+ object_hook.image_definitions = []
def filter_func(text):
json_data = json.loads(text, object_hook=object_hook)
@@ -1294,10 +1360,14 @@
input_format += '-native_divs+raw_html'
rststring = pandoc(text, input_format, 'rst', filter_func=filter_func)
- return re.sub(r'^\n( *)\x0e:nowrap:\x0f$',
- r'\1:nowrap:',
- rststring,
- flags=re.MULTILINE)
+ rststring = re.sub(
+ r'^\n( *)\x0e:nowrap:\x0f$',
+ r'\1:nowrap:',
+ rststring,
+ flags=re.MULTILINE)
+ rststring += '\n\n'
+ rststring += '\n'.join(object_hook.image_definitions)
+ return rststring
def pandoc(source, fmt, to, filter_func=None):
@@ -1540,7 +1610,8 @@
if not all_ids:
logger.warning(
'Each notebook should have at least one section title',
- location=self.document[0])
+ location=self.document[0],
+ type='nbsphinx', subtype='notebooktitle')
class CreateSectionLabels(docutils.transforms.Transform):
@@ -1673,11 +1744,14 @@
file = os.path.normpath(
os.path.join(os.path.dirname(env.docname), relpath))
if not os.path.isfile(os.path.join(env.srcdir, file)):
- logger.warning('File not found: %r', file, location=node)
+ logger.warning(
+ 'File not found: %r', file, location=node,
+ type='nbsphinx', subtype='localfile')
continue # Link is ignored
elif file.startswith('..'):
- logger.warning('Link outside source directory: %r', file,
- location=node)
+ logger.warning(
+ 'Link outside source directory: %r', file, location=node,
+ type='nbsphinx', subtype='localfile')
continue # Link is ignored
env.nbsphinx_files.setdefault(env.docname, []).append(file)
@@ -1733,48 +1807,11 @@
def config_inited(app, config):
- # Set default value for CSS prompt width (optimized for two-digit numbers)
- if config.nbsphinx_prompt_width is None:
- config.nbsphinx_prompt_width = {
- 'agogo': '4.5ex',
- 'alabaster': '5.5ex',
- 'alabaster_jupyterhub': '5.5ex',
- 'basicstrap': '5.5ex',
- 'better': '4.5ex',
- 'bizstyle': '5.5ex',
- 'bootstrap': '5.5ex',
- 'bootstrap-astropy': '5.5ex',
- 'classic': '4.5ex',
- 'cloud': '5ex',
- 'dotted': '5ex',
- 'greencloud': '5ex',
- 'guzzle_sphinx_theme': '5.5ex',
- 'haiku': '4.5ex',
- 'julia': '5.5ex',
- 'jupyter': '5.5ex',
- 'maisie_sphinx_theme': '5.5ex',
- 'nature': '5ex',
- 'pandas_sphinx_theme': '5.5ex',
- 'pangeo': '5ex',
- 'pydata_sphinx_theme': '5.5ex',
- 'pyramid': '4.5ex',
- 'pytorch_sphinx_theme': '14ex',
- 'redcloud': '5ex',
- 'scrolls': '5.5ex',
- 'sizzle': '5ex',
- 'sphinxdoc': '5.5ex',
- 'sphinx_material': '5.5ex',
- 'sphinx_py3doc_enhanced_theme': '6.5ex',
- 'sphinx_pyviz_theme': '5.5ex',
- 'sphinx_rtd_theme': '5ex',
- 'sphinx_typlog_theme': '5.5ex',
- 'traditional': '5ex',
- }.get(config.html_theme, '7ex')
-
for suffix in config.nbsphinx_custom_formats:
app.add_source_suffix(suffix, 'jupyter_notebook')
- config.exclude_patterns.append('**.ipynb_checkpoints')
+ if '**.ipynb_checkpoints' not in config.exclude_patterns:
+ config.exclude_patterns.append('**.ipynb_checkpoints')
# Make sure require.js is loaded after all other extensions,
# see https://github.com/spatialaudio/nbsphinx/issues/409
@@ -1808,6 +1845,30 @@
sphinx.util.ensuredir(env.nbsphinx_auxdir)
+def env_merge_info(app, env, docnames, other):
+ env.nbsphinx_notebooks.update(other.nbsphinx_notebooks)
+ env.nbsphinx_files.update(other.nbsphinx_files)
+ env.nbsphinx_thumbnails.update(other.nbsphinx_thumbnails)
+ env.nbsphinx_widgets.update(other.nbsphinx_widgets)
+
+
+def env_purge_doc(app, env, docname):
+ """Remove list of local files for a given document."""
+ try:
+ del env.nbsphinx_notebooks[docname]
+ except KeyError:
+ pass
+ try:
+ del env.nbsphinx_files[docname]
+ except KeyError:
+ pass
+ try:
+ del env.nbsphinx_thumbnails[docname]
+ except KeyError:
+ pass
+ env.nbsphinx_widgets.discard(docname)
+
+
def html_page_context(app, pagename, templatename, context, doctree):
"""Add CSS string to HTML pages that contain code cells."""
style = ''
@@ -1838,7 +1899,9 @@
try:
sphinx.util.copyfile(os.path.join(app.env.srcdir, file), target)
except OSError as err:
- logger.warning('Cannot copy local file %r: %s', file, err)
+ logger.warning(
+ 'Cannot copy local file %r: %s', file, err,
+ type='nbsphinx', subtype='localfile')
notebooks = app.env.nbsphinx_notebooks.values()
for notebook in status_iterator(
notebooks, 'copying notebooks ... ',
@@ -1849,23 +1912,6 @@
return [] # No new HTML pages are created
-def env_purge_doc(app, env, docname):
- """Remove list of local files for a given document."""
- try:
- del env.nbsphinx_notebooks[docname]
- except KeyError:
- pass
- try:
- del env.nbsphinx_files[docname]
- except KeyError:
- pass
- try:
- del env.nbsphinx_thumbnails[docname]
- except KeyError:
- pass
- env.nbsphinx_widgets.discard(docname)
-
-
def env_updated(app, env):
widgets_path = app.config.nbsphinx_widgets_path
if widgets_path is None:
@@ -1875,7 +1921,8 @@
except ImportError:
logger.warning(
'nbsphinx_widgets_path not given '
- 'and ipywidgets module unavailable')
+ 'and ipywidgets module unavailable',
+ type='nbsphinx', subtype='ipywidgets')
else:
widgets_path = DEFAULT_EMBED_REQUIREJS_URL
else:
@@ -1922,7 +1969,8 @@
logger.warning(
'page %s matches two patterns in '
'nbsphinx_thumbnails: %r and %r',
- doc, matched, pattern)
+ doc, matched, pattern,
+ type='nbsphinx', subtype='thumbnail')
# else the already matched pattern is more
# specific than the present one, because it
# contains no wildcard
@@ -1948,7 +1996,7 @@
else:
logger.warning(
'External links are not supported in gallery: %s', doc,
- location=fromdocname)
+ location=fromdocname, type='nbsphinx', subtype='gallery')
gallery = GalleryNode()
gallery['entries'] = entries
toctree['nbsphinx_gallery'] = True
@@ -2114,8 +2162,7 @@
app.add_config_value('nbsphinx_allow_errors', False, rebuild='')
app.add_config_value('nbsphinx_timeout', None, rebuild='')
app.add_config_value('nbsphinx_codecell_lexer', 'none', rebuild='env')
- # Default value is set in config_inited():
- app.add_config_value('nbsphinx_prompt_width', None, rebuild='html')
+ app.add_config_value('nbsphinx_prompt_width', '4.5ex', rebuild='html')
app.add_config_value('nbsphinx_responsive_width', '540px', rebuild='html')
app.add_config_value('nbsphinx_prolog', None, rebuild='env')
app.add_config_value('nbsphinx_epilog', None, rebuild='env')
@@ -2155,6 +2202,7 @@
app.connect('env-purge-doc', env_purge_doc)
app.connect('env-updated', env_updated)
app.connect('doctree-resolved', doctree_resolved)
+ app.connect('env-merge-info', env_merge_info)
app.add_transform(CreateSectionLabels)
app.add_transform(CreateDomainObjectLabels)
app.add_transform(RewriteLocalLinks)