Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-nbsphinx for openSUSE:Factory checked in at 2023-01-08 21:25:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-nbsphinx (Old) and /work/SRC/openSUSE:Factory/.python-nbsphinx.new.1563 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-nbsphinx" Sun Jan 8 21:25:52 2023 rev:12 rq:1056888 version:0.8.11 Changes: -------- --- /work/SRC/openSUSE:Factory/python-nbsphinx/python-nbsphinx.changes 2022-06-18 22:06:05.479647710 +0200 +++ /work/SRC/openSUSE:Factory/.python-nbsphinx.new.1563/python-nbsphinx.changes 2023-01-08 21:25:53.719373934 +0100 @@ -1,0 +2,9 @@ +Sun Jan 8 09:45:44 UTC 2023 - Ben Greiner <c...@bnavigator.de> + +- Update to 0.8.11 + * LaTeX: apply code cell border style to all code blocks +- Release 0.8.10 + * Fix handling of source_suffix + * A few LaTeX fixes + +------------------------------------------------------------------- Old: ---- nbsphinx-0.8.9.tar.gz New: ---- nbsphinx-0.8.11.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-nbsphinx.spec ++++++ --- /var/tmp/diff_new_pack.B3cHbj/_old 2023-01-08 21:25:54.507378615 +0100 +++ /var/tmp/diff_new_pack.B3cHbj/_new 2023-01-08 21:25:54.507378615 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-nbsphinx # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,10 +16,9 @@ # -%{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-nbsphinx -Version: 0.8.9 +Version: 0.8.11 Release: 0 Summary: Jupyter Notebook Tools for Sphinx License: MIT @@ -31,9 +30,11 @@ BuildRequires: %{python_module docutils} BuildRequires: %{python_module nbconvert} BuildRequires: %{python_module nbformat} +BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} BuildRequires: %{python_module sphinx_rtd_theme} BuildRequires: %{python_module traitlets >= 5} +BuildRequires: %{python_module wheel} BuildRequires: fdupes BuildRequires: python-rpm-macros Requires: python-Jinja2 @@ -65,10 +66,10 @@ %setup -q -n nbsphinx-%{version} %build -%python_build +%pyproject_wheel %install -%python_install +%pyproject_install %python_expand %fdupes %{buildroot}%{$python_sitelib} @@ -86,6 +87,6 @@ %license LICENSE %{python_sitelib}/nbsphinx.py* %pycache_only %{python_sitelib}/__pycache__/nbsphinx.*.py* -%{python_sitelib}/nbsphinx-%{version}*-info +%{python_sitelib}/nbsphinx-%{version}.dist-info %changelog ++++++ nbsphinx-0.8.9.tar.gz -> nbsphinx-0.8.11.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/.circleci/config.yml new/nbsphinx-0.8.11/.circleci/config.yml --- old/nbsphinx-0.8.9/.circleci/config.yml 2022-04-10 15:35:02.000000000 +0200 +++ new/nbsphinx-0.8.11/.circleci/config.yml 2022-12-29 16:06:41.000000000 +0100 @@ -26,7 +26,7 @@ name: Installing apt Packages command: | apt-get -y update - apt-get install -y --no-install-recommends python3-pip librsvg2-bin + apt-get install -y --no-install-recommends python3-pip librsvg2-bin binutils - restore_cache: keys: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/NEWS.rst new/nbsphinx-0.8.11/NEWS.rst --- old/nbsphinx-0.8.9/NEWS.rst 2022-06-04 20:27:10.000000000 +0200 +++ new/nbsphinx-0.8.11/NEWS.rst 2022-12-29 16:53:03.000000000 +0100 @@ -1,3 +1,16 @@ +Version 0.8.11 -- 2022-12-29 -- PyPI__ -- diff__ + * LaTeX: apply code cell border style to all code blocks + +__ https://pypi.org/project/nbsphinx/0.8.11/ +__ https://github.com/spatialaudio/nbsphinx/compare/0.8.10...0.8.11 + +Version 0.8.10 -- 2022-11-13 -- PyPI__ -- diff__ + * Fix handling of ``source_suffix`` + * A few LaTeX fixes + +__ https://pypi.org/project/nbsphinx/0.8.10/ +__ https://github.com/spatialaudio/nbsphinx/compare/0.8.9...0.8.10 + Version 0.8.9 -- 2022-06-04 -- PyPI__ -- diff__ * CSS: support tables in widgets * Avoid empty "raw" directive diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/PKG-INFO new/nbsphinx-0.8.11/PKG-INFO --- old/nbsphinx-0.8.9/PKG-INFO 2022-06-04 20:28:44.205046400 +0200 +++ new/nbsphinx-0.8.11/PKG-INFO 2022-12-29 16:53:51.027439400 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: nbsphinx -Version: 0.8.9 +Version: 0.8.11 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.8.9/doc/code-cells.ipynb new/nbsphinx-0.8.11/doc/code-cells.ipynb --- old/nbsphinx-0.8.9/doc/code-cells.ipynb 2022-04-22 18:46:35.000000000 +0200 +++ new/nbsphinx-0.8.11/doc/code-cells.ipynb 2022-12-04 18:45:06.000000000 +0100 @@ -174,7 +174,7 @@ "source": [ "## Special Display Formats\n", "\n", - "See [IPython example notebook](https://nbviewer.jupyter.org/github/ipython/ipython/blob/master/examples/IPython Kernel/Rich Output.ipynb)." + "See [IPython example notebook](https://nbviewer.jupyter.org/github/ipython/ipython/blob/main/examples/IPython Kernel/Rich Output.ipynb)." ] }, { @@ -308,68 +308,67 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Plots\n", - "\n", - "The output formats for Matplotlib plots can be customized\n", - "via the IPython configuration file `ipython_kernel_config.py`.\n", - "This file can be either\n", - "in the directory where your notebook is located\n", - "(see the [ipython_kernel_config.py](ipython_kernel_config.py) in this directory),\n", - "or in your profile directory\n", - "(typically `~/.ipython/profile_default/ipython_kernel_config.py`).\n", - "To find out your IPython profile directory, use this command:\n", - "\n", - " python3 -m IPython profile locate\n", - "\n", - "A local `ipython_kernel_config.py` in the notebook directory\n", - "also works on https://mybinder.org/.\n", - "Alternatively, you can create a file with those settings in a file named\n", - "`.ipython/profile_default/ipython_kernel_config.py` in your repository.\n", - "\n", - "\n", - "If you want to use SVG images for Matplotlib plots,\n", - "add this line to your IPython configuration file:\n", - "\n", - "```python\n", - "c.InlineBackend.figure_formats = {'svg'}\n", - "```\n", - "\n", - "If you want SVG images, but also want nice plots when exporting to LaTeX/PDF, you can select:\n", - "\n", - "```python\n", - "c.InlineBackend.figure_formats = {'svg', 'pdf'}\n", - "```\n", + "### Plots" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "<div class=\"alert alert-info\">\n", "\n", - "If you want to use the default PNG plots or HiDPI plots using `'png2x'` (a.k.a. `'retina'`),\n", - "make sure to set this:\n", + "Make sure to use at least version 0.1.6 of the `matplotlib-inline` package\n", + "(which is an automatic dependency of the `ipython` package).\n", "\n", - "```python\n", - "c.InlineBackend.rc = {'figure.dpi': 96}\n", - "```\n", + "</div>" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "By default, the plots created with the \"inline\" backend have the wrong size.\n", + "More specifically, PNG plots (the default) will be slightly larger than SVG and PDF plots.\n", "\n", - "This is needed because the default `'figure.dpi'` value of 72\n", - "is only valid for the [Qt Console](https://qtconsole.readthedocs.io/).\n", + "This can be fixed easily by creating a file named `matplotlibrc`\n", + "(in the directory where your Jupyter notebooks live,\n", + "e.g. in this directory: [matplotlibrc](matplotlibrc))\n", + "and adding the following line:\n", "\n", - "If you are planning to store your SVG plots as part of your notebooks,\n", - "you should also have a look at the `'svg.hashsalt'` setting.\n", + " figure.dpi: 96\n", "\n", - "For more details on these and other settings, have a look at\n", - "[Default Values for Matplotlib's \"inline\" Backend](https://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/plotting/matplotlib-inline-defaults.ipynb).\n", + "If you are using Git to manage your files,\n", + "don't forget to commit this local configuration file to your repository.\n", + "Different directories can have different local configurations.\n", + "If a given configuration should apply to multiple directories,\n", + "symbolic links can be created in each directory.\n", "\n", - "If you for some reason can't use a `ipython_kernel_config.py` file,\n", - "you can also change these settings with\n", + "For more details, see\n", + "[Default Values for Matplotlib's \"inline\" Backend](https://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/plotting/matplotlib-inline-defaults.ipynb)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "By default, plots are generated in the PNG format.\n", + "In most cases,\n", + "it looks better\n", + "if SVG plots are used for HTML output\n", + "and PDF plots are used for LaTeX/PDF.\n", + "This can be achieved by setting\n", "[nbsphinx_execute_arguments](usage.ipynb#nbsphinx_execute_arguments)\n", - "in your `conf.py` file:\n", + "in your `conf.py` file like this:\n", "\n", "```python\n", "nbsphinx_execute_arguments = [\n", " \"--InlineBackend.figure_formats={'svg', 'pdf'}\",\n", - " \"--InlineBackend.rc=figure.dpi=96\",\n", "]\n", "```\n", " \n", "In the following example, `nbsphinx` should use an SVG image in the HTML output\n", - "and a PDF image for LaTeX/PDF output." + "and a PDF image for LaTeX/PDF output\n", + "(other Jupyter clients like JupyterLab will still show the default PNG format)." ] }, { @@ -395,8 +394,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Alternatively, the figure format(s) can also be chosen directly in the notebook\n", - "(which overrides the setting in `nbsphinx_execute_arguments` and in the IPython configuration):" + "For comparison,\n", + "this is how it would look in PNG format ..." ] }, { @@ -421,9 +420,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If you want to use PNG images, but with HiDPI resolution,\n", - "use the special `'png2x'` (a.k.a. `'retina'`) format\n", - "(which also looks nice in the LaTeX output):" + "... and in `'png2x'` (a.k.a. `'retina'`) format:" ] }, { @@ -754,7 +751,7 @@ "To obtain more information if widgets are not displayed as expected, you will need to look at the error message in the web browser console.\n", "\n", "> To figure out how to open the web browser console, you may look at the web browser documentation: \n", - "> Chrome: https://developer.chrome.com/docs/devtools/open/#console \n", + "> Chrome: https://developer.chrome.com/docs/devtools/open/#shortcuts \n", "> Firefox: https://developer.mozilla.org/en-US/docs/Tools/Web_Console#opening-the-web-console\n", "\n", "The error is most probably linked to the JavaScript files not being loaded or loaded in the wrong order within the HTML file. To analyze the error, you can inspect the HTML file within the web browser (e.g.: right-click on the page and select *View Page Source*) and look at the `<head>` section of the page. That section should contain\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/conf.py new/nbsphinx-0.8.11/doc/conf.py --- old/nbsphinx-0.8.9/doc/conf.py 2022-05-22 16:31:52.000000000 +0200 +++ new/nbsphinx-0.8.11/doc/conf.py 2022-12-29 16:48:47.000000000 +0100 @@ -26,6 +26,11 @@ # Don't add .txt suffix to source files: html_sourcelink_suffix = '' +# List of arguments to be passed to the kernel that executes the notebooks: +nbsphinx_execute_arguments = [ + "--InlineBackend.figure_formats={'svg', 'pdf'}", +] + # Environment variables to be passed to the kernel: os.environ['MY_DUMMY_VARIABLE'] = 'Hello from conf.py!' @@ -135,8 +140,6 @@ %verbatimwithframe=false, %verbatimwrapslines=false, %verbatimhintsturnover=false, - VerbatimColor={HTML}{F5F5F5}, - VerbatimBorderColor={HTML}{E0E0E0}, noteBorderColor={HTML}{E0E0E0}, noteborder=1.5pt, warningBorderColor={HTML}{E0E0E0}, @@ -152,10 +155,11 @@ }{ \renewcommand{\ttdefault}{lmtt} % typewriter font from lmodern } -\usepackage{booktabs} % for Pandas dataframes """, } +latex_table_style = ['booktabs'] + latex_documents = [ (master_doc, 'nbsphinx.tex', project, author, 'howto'), ] @@ -179,4 +183,4 @@ else: html_theme = 'insipid' html_copy_source = False - html_permalinks_icon = '§' + html_permalinks_icon = '#' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/configuring-kernels.ipynb new/nbsphinx-0.8.11/doc/configuring-kernels.ipynb --- old/nbsphinx-0.8.9/doc/configuring-kernels.ipynb 2022-01-01 18:45:53.000000000 +0100 +++ new/nbsphinx-0.8.11/doc/configuring-kernels.ipynb 2022-10-29 13:43:25.000000000 +0200 @@ -35,30 +35,15 @@ "source": [ "## Kernel Arguments\n", "\n", - "We can also pass options to the kernel by setting [nbsphinx_execute_arguments](usage.ipynb#nbsphinx_execute_arguments) in `conf.py`. These work the same way as `ipython_kernel_config.py`. For example, using\n", + "We can pass arguments to the kernel by using\n", + "[nbsphinx_execute_arguments](usage.ipynb#nbsphinx_execute_arguments),\n", + "for example to set [plot options](code-cells.ipynb#Plots):\n", + "\n", "```python\n", "nbsphinx_execute_arguments = [\n", - " \"--InlineBackend.rc=figure.dpi=96\",\n", + " \"--InlineBackend.figure_formats={'svg', 'pdf'}\",\n", "]\n", - "```\n", - "to set [plot options](code-cells.ipynb#Plots) is the same as writing:\n", - "```python\n", - "c.InlineBackend.rc = {'figure.dpi': 96}\n", - "```\n", - "in `ipython_kernel_config.py` or using:\n", - "```ipython\n", - "%config InlineBackend.rc={'figure.dpi': 96}\n", - "```\n", - "at the top of a notebook:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "get_ipython().config.InlineBackend.rc" + "```" ] }, { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/gallery/ipython_kernel_config.py new/nbsphinx-0.8.11/doc/gallery/ipython_kernel_config.py --- old/nbsphinx-0.8.9/doc/gallery/ipython_kernel_config.py 2022-04-10 15:35:02.000000000 +0200 +++ new/nbsphinx-0.8.11/doc/gallery/ipython_kernel_config.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -c.InlineBackend.figure_formats = {'svg', 'pdf'} -c.InlineBackend.rc = {'figure.dpi': 96} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/installation.ipynb new/nbsphinx-0.8.11/doc/installation.ipynb --- old/nbsphinx-0.8.9/doc/installation.ipynb 2022-01-01 18:45:53.000000000 +0100 +++ new/nbsphinx-0.8.11/doc/installation.ipynb 2022-10-29 13:43:25.000000000 +0200 @@ -23,7 +23,12 @@ "\n", "[](https://anaconda.org/conda-forge/nbsphinx)\n", "\n", - "If you are using the `conda` package manager (e.g. with [Anaconda](https://www.anaconda.com/products/individual#Downloads) for Linux/macOS/Windows), you can install `nbsphinx` from the [conda-forge](https://conda-forge.org/) channel:\n", + "If you are using the `conda` package manager\n", + "(e.g. with\n", + "[Miniforge](https://github.com/conda-forge/miniforge),\n", + "[Miniconda](https://docs.conda.io/en/latest/miniconda.html) or\n", + "[Anaconda](https://www.anaconda.com/products/distribution#Downloads)),\n", + "you can install `nbsphinx` from the [conda-forge](https://conda-forge.org/) channel:\n", "\n", " conda install -c conda-forge nbsphinx\n", "\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/ipython_kernel_config.py new/nbsphinx-0.8.11/doc/ipython_kernel_config.py --- old/nbsphinx-0.8.9/doc/ipython_kernel_config.py 2022-04-10 15:35:02.000000000 +0200 +++ new/nbsphinx-0.8.11/doc/ipython_kernel_config.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,2 +0,0 @@ -c.InlineBackend.figure_formats = {'svg', 'pdf'} -c.InlineBackend.rc = {'figure.dpi': 96} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/links.ipynb new/nbsphinx-0.8.11/doc/links.ipynb --- old/nbsphinx-0.8.9/doc/links.ipynb 2022-02-26 19:25:46.000000000 +0100 +++ new/nbsphinx-0.8.11/doc/links.ipynb 2022-10-29 13:43:25.000000000 +0200 @@ -85,10 +85,7 @@ "\n", "https://jupyterbook.org/\n", "\n", - "https://github.com/executablebooks/jupyter-book\n", - "\n", - "Previous tagline: \"Create an online book with Jupyter Notebooks and Jekyll\":\n", - "https://legacy.jupyterbook.org/" + "https://github.com/executablebooks/jupyter-book" ] }, { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/requirements.txt new/nbsphinx-0.8.11/doc/requirements.txt --- old/nbsphinx-0.8.9/doc/requirements.txt 2022-05-22 16:31:52.000000000 +0200 +++ new/nbsphinx-0.8.11/doc/requirements.txt 2022-12-23 17:25:55.000000000 +0100 @@ -1,4 +1,5 @@ ipykernel +ipython!=8.7.0 # see https://github.com/spatialaudio/nbsphinx/issues/687 numpy matplotlib pandas diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/doc/usage.ipynb new/nbsphinx-0.8.11/doc/usage.ipynb --- old/nbsphinx-0.8.9/doc/usage.ipynb 2022-04-10 15:35:02.000000000 +0200 +++ new/nbsphinx-0.8.11/doc/usage.ipynb 2022-09-18 16:14:25.000000000 +0200 @@ -730,7 +730,7 @@ "```\n", "Note: \n", "\n", - "You migh have to change the line `docs/` to `docs/source` in case that you have this folder structure, which is the default when using `sphinx-quickstart. " + "You might have to change the line `docs/` to `docs/source` in case that you have this folder structure, which is the default when using `sphinx-quickstart`. " ] }, { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/src/nbsphinx.egg-info/PKG-INFO new/nbsphinx-0.8.11/src/nbsphinx.egg-info/PKG-INFO --- old/nbsphinx-0.8.9/src/nbsphinx.egg-info/PKG-INFO 2022-06-04 20:28:43.000000000 +0200 +++ new/nbsphinx-0.8.11/src/nbsphinx.egg-info/PKG-INFO 2022-12-29 16:53:50.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: nbsphinx -Version: 0.8.9 +Version: 0.8.11 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.8.9/src/nbsphinx.egg-info/SOURCES.txt new/nbsphinx-0.8.11/src/nbsphinx.egg-info/SOURCES.txt --- old/nbsphinx-0.8.9/src/nbsphinx.egg-info/SOURCES.txt 2022-06-04 20:28:44.000000000 +0200 +++ new/nbsphinx-0.8.11/src/nbsphinx.egg-info/SOURCES.txt 2022-12-29 16:53:50.000000000 +0100 @@ -38,7 +38,6 @@ doc/hidden-cells.ipynb doc/index.rst doc/installation.ipynb -doc/ipython_kernel_config.py doc/links.ipynb doc/markdown-cells.ipynb doc/never-execute.ipynb @@ -55,7 +54,6 @@ doc/gallery/cell-metadata.ipynb doc/gallery/cell-tag.ipynb doc/gallery/due-rst.pct.py -doc/gallery/ipython_kernel_config.py doc/gallery/multiple-outputs.ipynb doc/gallery/no-thumbnail.ipynb doc/gallery/thumbnail-from-conf-py.ipynb diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.8.9/src/nbsphinx.py new/nbsphinx-0.8.11/src/nbsphinx.py --- old/nbsphinx-0.8.9/src/nbsphinx.py 2022-06-04 20:24:57.000000000 +0200 +++ new/nbsphinx-0.8.11/src/nbsphinx.py 2022-12-29 16:52:02.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2021 Matthias Geier +# Copyright (c) 2015-2022 Matthias Geier # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,11 +23,12 @@ https://nbsphinx.readthedocs.io/ """ -__version__ = '0.8.9' +__version__ = '0.8.11' import collections.abc import copy import html +from itertools import chain import json import os import re @@ -299,6 +300,15 @@ """.replace('__RST_DEFAULT_TEMPLATE__', nbconvert.RSTExporter().template_file) +# MEMO: the nbsphinxfancyoutput environment recycles some internal Sphinx +# LaTeX macros, as testify the @ in their names. At 5.1.0 these macros +# got modified so we now have two cases for the nbsphinxfancyoutput +# definition: Sphinx >= 5.1.0 or Sphinx < 5.1.0 (and >= 1.7.0 at least). + +# MEMO: since Sphinx 2.0 the upstream \sphinxincludegraphics is similar and +# slightly better than the \nbsphinxincludegraphics defined here. So for the +# >= 5.1.0 branch of nbsphinxfancyoutput, the code does no replacement of +# \sphinxincludegraphics by \nbsphinxincludegraphics anymore. LATEX_PREAMBLE = r""" % Jupyter Notebook code cell colors \definecolor{nbsphinxin}{HTML}{307FC1} @@ -326,8 +336,50 @@ \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF} \definecolor{ansi-default-inverse-bg}{HTML}{000000} +% Defaults for all code blocks, including, but not limited to code cells: +\sphinxsetup{VerbatimColor={named}{nbsphinx-code-bg}} +\sphinxsetup{VerbatimBorderColor={named}{nbsphinx-code-border}} +\makeatletter +\@ifpackagelater{sphinx}{2022/06/30}{% Sphinx >= 5.1.0 +% Restore settings from Sphinx < 5.1.0: +\sphinxsetup{pre_border-radius=0pt} +\sphinxsetup{pre_box-decoration-break=clone} +}{} +\makeatother + % Define an environment for non-plain-text code cell outputs (e.g. images) +\newbox\nbsphinxpromptbox \makeatletter +\@ifpackagelater{sphinx}{2022/06/30}{% "later" means here "at least" +% In this branch Sphinx is at least at 5.1.0 +\newenvironment{nbsphinxfancyoutput}{% +\sphinxcolorlet{VerbatimColor}{white}% +\spx@verb@boxes@fcolorbox@setup + % for \sphinxincludegraphics check of maximal height + \spx@image@maxheight \textheight + \advance\spx@image@maxheight -\spx@boxes@border@top + \advance\spx@image@maxheight -\spx@boxes@padding@top + \advance\spx@image@maxheight -\spx@boxes@padding@bottom + \advance\spx@image@maxheight -\spx@boxes@border@bottom + \advance\spx@image@maxheight -\baselineskip +\def\sphinxVerbatim@Before{\nbsphinxfancyaddprompt}% +\def\sphinxVerbatim@After {\@empty}% +\def\FrameCommand {\sphinxVerbatim@FrameCommand}% +\def\FirstFrameCommand{\sphinxVerbatim@FirstFrameCommand}% +\def\MidFrameCommand {\sphinxVerbatim@MidFrameCommand}% +\def\LastFrameCommand {\sphinxVerbatim@LastFrameCommand}% +\MakeFramed{\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage}% +\lineskip=1ex\lineskiplimit=1ex\raggedright% +}{\par\unskip\@minipagefalse\endMakeFramed} +\def\nbsphinxfancyaddprompt{\ifvoid\nbsphinxpromptbox\else + \kern\spx@boxes@border@top\kern\spx@boxes@padding@top + \copy\nbsphinxpromptbox + \kern-\ht\nbsphinxpromptbox\kern-\dp\nbsphinxpromptbox + \kern-\spx@boxes@padding@top\kern-\spx@boxes@border@top + \nointerlineskip + \fi} +}% End of Sphinx >= 5.1.0 branch +{% This branch for Sphinx < 5.1.0 \newenvironment{nbsphinxfancyoutput}{% % Avoid fatal error with framed.sty if graphics too long to fit on one page \let\sphinxincludegraphics\nbsphinxincludegraphics @@ -343,14 +395,14 @@ \MakeFramed{\advance\hsize-\width\@totalleftmargin\z@\linewidth\hsize\@setminipage}% \lineskip=1ex\lineskiplimit=1ex\raggedright% }{\par\unskip\@minipagefalse\endMakeFramed} -\makeatother -\newbox\nbsphinxpromptbox \def\nbsphinxfancyaddprompt{\ifvoid\nbsphinxpromptbox\else \kern\fboxrule\kern\fboxsep \copy\nbsphinxpromptbox \kern-\ht\nbsphinxpromptbox\kern-\dp\nbsphinxpromptbox \kern-\fboxsep\kern-\fboxrule\nointerlineskip \fi} +}% end of Sphinx < 5.1.0 branch +\makeatother \newlength\nbsphinxcodecellspacing \setlength{\nbsphinxcodecellspacing}{0pt} @@ -404,6 +456,8 @@ }% end of \nbsphinxstopnotebook % Ensure height of an included graphics fits in nbsphinxfancyoutput frame +% The Sphinx >= 5.1.0 version of nbsphinxfancyoutput does not use this macro +% as \sphinxincludegraphics is since Sphinx 2.0 similar and slightly better. \newdimen\nbsphinx@image@maxheight % set in nbsphinxfancyoutput environment \newcommand*{\nbsphinxincludegraphics}[2][]{% \gdef\spx@includegraphics@options{#1}% @@ -551,10 +605,11 @@ } } -/* disable scrollbars on prompts */ +/* disable scrollbars and line breaks on prompts */ div.nbinput.container div.prompt pre, div.nboutput.container div.prompt pre { overflow: hidden; + white-space: pre; } /* input/output area */ @@ -1886,10 +1941,14 @@ def config_inited(app, config): - if '.ipynb' not in config.source_suffix: - app.add_source_suffix('.ipynb', 'jupyter_notebook') for suffix in config.nbsphinx_custom_formats: app.add_source_suffix(suffix, 'jupyter_notebook') + if '.ipynb' in chain(config.source_suffix, app.registry.source_suffix): + # We don't interfere if '.ipynb' has been added by the user in conf.py + # or by another Sphinx extension that has been loaded earlier. + pass + else: + app.add_source_suffix('.ipynb', 'jupyter_notebook') if '**.ipynb_checkpoints' not in config.exclude_patterns: config.exclude_patterns.append('**.ipynb_checkpoints') @@ -2174,7 +2233,6 @@ out.append('{') # Start a scope for colors if 'nbinput' in node.parent['classes']: promptcolor = 'nbsphinxin' - out.append(r'\sphinxsetup{VerbatimColor={named}{nbsphinx-code-bg}}') else: out.append(r""" \kern-\sphinxverbatimsmallskipamount\kern-\baselineskip @@ -2186,9 +2244,6 @@ out.append(r'\sphinxsetup{VerbatimColor={named}{nbsphinx-stderr}}') else: out.append(r'\sphinxsetup{VerbatimColor={named}{white}}') - - out.append( - r'\sphinxsetup{VerbatimBorderColor={named}{nbsphinx-code-border}}') if lines[0].startswith(r'\fvset{'): # Sphinx >= 1.6.6 and < 1.8.3 out.append(lines[0]) del lines[0]