Hello community,

here is the log from the commit of package python-nbsphinx-link for 
openSUSE:Factory checked in at 2019-11-29 15:57:42
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-nbsphinx-link (Old)
 and      /work/SRC/openSUSE:Factory/.python-nbsphinx-link.new.26869 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-nbsphinx-link"

Fri Nov 29 15:57:42 2019 rev:2 rq:748500 version:1.3.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-nbsphinx-link/python-nbsphinx-link.changes    
    2019-05-22 11:11:07.702598550 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-nbsphinx-link.new.26869/python-nbsphinx-link.changes
     2019-11-29 16:01:58.216828726 +0100
@@ -1,0 +2,11 @@
+Wed Nov 13 16:40:01 UTC 2019 - Todd R <[email protected]>
+
+- Drop python2 support due to python-nbsphinx dropping python2 support
+
+-------------------------------------------------------------------
+Tue Nov 12 16:50:17 UTC 2019 - Todd R <[email protected]>
+
+- Update to 1.3.0
+  * Added media collection feature
+
+-------------------------------------------------------------------

Old:
----
  nbsphinx-link-1.2.0.tar.gz

New:
----
  nbsphinx-link-1.3.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-nbsphinx-link.spec ++++++
--- /var/tmp/diff_new_pack.ckmuNO/_old  2019-11-29 16:01:59.600828159 +0100
+++ /var/tmp/diff_new_pack.ckmuNO/_new  2019-11-29 16:01:59.604828157 +0100
@@ -17,8 +17,9 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define         skip_python2 1
 Name:           python-nbsphinx-link
-Version:        1.2.0
+Version:        1.3.0
 Release:        0
 Summary:        Sphinx extension for including notebook files outside sphinx 
source root
 License:        BSD-3-Clause

++++++ nbsphinx-link-1.2.0.tar.gz -> nbsphinx-link-1.3.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/PKG-INFO 
new/nbsphinx-link-1.3.0/PKG-INFO
--- old/nbsphinx-link-1.2.0/PKG-INFO    2019-01-28 17:24:04.000000000 +0100
+++ new/nbsphinx-link-1.3.0/PKG-INFO    2019-10-01 16:15:30.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: nbsphinx-link
-Version: 1.2.0
+Version: 1.3.0
 Summary: A sphinx extension for including notebook files outside sphinx source 
root
 Home-page: https://github.com/vidartf/nbsphinx-link
 Author: Vidar Tonaas Fauske
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/README.rst 
new/nbsphinx-link-1.3.0/README.rst
--- old/nbsphinx-link-1.2.0/README.rst  2019-01-28 15:03:06.000000000 +0100
+++ new/nbsphinx-link-1.3.0/README.rst  2019-09-27 14:50:52.000000000 +0200
@@ -24,6 +24,12 @@
         "path": "relative/path/to/notebook"
     }
 
+Optionally the "extra-media" key can be added, if your notebook includes
+any media, i.e. images. The value needs to be an array of strings,
+which are paths to the media files or directories to include. Note that
+this is not needed if the images are added as attachments to markdown
+cells.
+
 Further keys might be added in the future.
 
 Note that the documentation of this project might serve as a
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/docs/source/conf.py 
new/nbsphinx-link-1.3.0/docs/source/conf.py
--- old/nbsphinx-link-1.2.0/docs/source/conf.py 2018-05-25 15:37:27.000000000 
+0200
+++ new/nbsphinx-link-1.3.0/docs/source/conf.py 2019-09-27 13:07:23.000000000 
+0200
@@ -114,11 +114,6 @@
 #
 # html_theme_options = {}
 
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-html_static_path = ['_static']
-
 # Custom sidebar templates, must be a dictionary that maps document names
 # to template names.
 #
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/docs/source/introduction.nblink 
new/nbsphinx-link-1.3.0/docs/source/introduction.nblink
--- old/nbsphinx-link-1.2.0/docs/source/introduction.nblink     2018-05-23 
17:44:59.000000000 +0200
+++ new/nbsphinx-link-1.3.0/docs/source/introduction.nblink     2019-09-27 
13:07:23.000000000 +0200
@@ -1,3 +1,8 @@
 {
-  "path": "../../notebooks/introduction.ipynb"
+  "path": "../../notebooks/introduction.ipynb",
+  "extra-media": [
+    "../../notebooks/images",
+    "../../notebooks/smile.png",
+    "not_a_path"
+  ]
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/nbsphinx_link/__init__.py 
new/nbsphinx-link-1.3.0/nbsphinx_link/__init__.py
--- old/nbsphinx-link-1.2.0/nbsphinx_link/__init__.py   2019-01-28 
17:22:33.000000000 +0100
+++ new/nbsphinx-link-1.3.0/nbsphinx_link/__init__.py   2019-09-27 
14:56:30.000000000 +0200
@@ -11,27 +11,155 @@
     "path": "relative/path/to/notebook"
 }
 
+
+Optionally the "extra-media" key can be added, if your notebook includes
+any media, i.e. images. The value needs to be an array of strings,
+which are paths to the media files or directories.
+
 Further keys might be added in the future.
 """
 
-
 import json
 import os
+import shutil
 
 from docutils import io, nodes, utils
 from docutils.utils.error_reporting import SafeString, ErrorString
+import docutils  # noqa: F401
 from nbsphinx import NotebookParser, NotebookError, _ipynbversion
 import nbformat
+from sphinx.util.logging import getLogger
 
 from ._version import __version__
 
 
+def register_dependency(file_path, document):
+    """
+    Registers files as dependency, so sphinx rebuilds the docs
+    when they changed.
+
+    Parameters
+    ----------
+    file_path : str
+        [description]
+    document: docutils.nodes.document
+        Parsed document instance.
+    """
+    document.settings.record_dependencies.add(file_path)
+    document.settings.env.note_dependency(file_path)
+
+
+def copy_file(src, dest, document):
+    """
+    Copies a singe file from ``src`` to ``dest``.
+
+    Parameters
+    ----------
+    src : str
+        Path to the source file.
+    dest : str
+        Path to the destination file or directory.
+    document: docutils.nodes.document
+        Parsed document instance.
+    """
+    logger = getLogger(__name__)
+    try:
+        shutil.copy(src, dest)
+        register_dependency(src, document)
+    except (OSError) as e:
+        logger.warning(
+            "The the file {} couldn't be copied. "
+            "Error:\n {}".format(src, e)
+        )
+
+
+def copy_and_register_files(src, dest, document):
+    """
+    Copies a directory or file from the path ``src`` to ``dest``
+    and registers all files as dependency,
+    so sphinx rebuilds the docs when they changed.
+
+    Parameters
+    ----------
+    src : str
+        Path to the source directory or file
+    dest : str
+        Path to the destination directory or file
+    document: docutils.nodes.document
+        Parsed document instance.
+    """
+    if os.path.isdir(src):
+        for root, _, filenames in os.walk(src):
+            dst_root = os.path.join(dest, os.path.relpath(root, src))
+            if filenames and not os.path.exists(dst_root):
+                os.makedirs(dst_root)
+            for filename in filenames:
+                src_path = os.path.abspath(os.path.join(root, filename))
+                copy_file(src_path, dst_root, document)
+    else:
+        copy_file(src, dest, document)
+
+
+def collect_extra_media(extra_media, source_file, nb_path, document):
+    """
+    Collects extra media defined in the .nblink file,  with the key
+    'extra-media'. The extra media (i.e. images) need to be copied
+    in order for nbsphinx to properly render the notebooks, since
+    nbsphinx assumes that the files are relative to the .nblink.
+
+    Parameters
+    ----------
+    extra_media : list
+        Paths to directories and/or files with extra media.
+    source_file : str
+        Path to the .nblink file.
+    nb_path : str
+        Path to the notebook defined in the .nblink file , with the key 'path'.
+    document: docutils.nodes.document
+        Parsed document instance.
+
+    """
+    any_dirs = False
+    logger = getLogger(__name__)
+    source_dir = os.path.dirname(source_file)
+    if not isinstance(extra_media, list):
+        logger.warning(
+            'The "extra-media", defined in {} needs to be a list of paths. '
+            'The current value is:\n{}'.format(source_file, extra_media)
+        )
+    for extract_media_path in extra_media:
+        if os.path.isabs(extract_media_path):
+            src_path = extract_media_path
+        else:
+            extract_media_relpath = os.path.join(
+                source_dir, extract_media_path
+            )
+            src_path = os.path.normpath(
+                os.path.join(source_dir, extract_media_relpath)
+            )
+
+        dest_path = utils.relative_path(nb_path, src_path)
+        dest_path = os.path.normpath(os.path.join(source_dir, dest_path))
+        if os.path.exists(src_path):
+            any_dirs = any_dirs or os.path.isdir(src_path)
+            copy_and_register_files(src_path, dest_path, document)
+        else:
+            logger.warning(
+                'The path "{}", defined in {} "extra-media", '
+                'isn\'t a valid path.'.format(
+                    extract_media_path, source_file
+                )
+            )
+        if any_dirs:
+            document.settings.env.note_reread()
+
+
 class LinkedNotebookParser(NotebookParser):
     """A parser for .nblink files.
 
     The parser will replace the link file with the output from
     nbsphinx on the linked notebook. It will also add the linked
-    file as a dependency, so that sphinx will take it into acount
+    file as a dependency, so that sphinx will take it into account
     when figuring out whether it should be rebuilt.
 
     The .nblink file is a JSON file with the following structure:
@@ -40,6 +168,10 @@
         "path": "relative/path/to/notebook"
     }
 
+    Optionally the "extra-media" key can be added, if your notebook includes
+    any media, i.e. images. The value needs to be an array of strings,
+    which are paths to the media files or directories.
+
     Further keys might be added in the future.
     """
 
@@ -59,8 +191,12 @@
         path = utils.relative_path(None, abs_path)
         path = nodes.reprunicode(path)
 
-        document.settings.record_dependencies.add(path)
-        env.note_dependency(path)
+        extra_media = link.get('extra-media', None)
+        if extra_media:
+            source_file = env.doc2path(env.docname)
+            collect_extra_media(extra_media, source_file, path, document)
+
+        register_dependency(path, document)
 
         target_root = env.config.nbsphinx_link_target_root
         target = utils.relative_path(target_root, abs_path)
@@ -96,7 +232,6 @@
         return super(LinkedNotebookParser, self).parse(rawtext, document)
 
 
-
 def setup(app):
     """Initialize Sphinx extension."""
     app.setup_extension('nbsphinx')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/nbsphinx_link/_version.py 
new/nbsphinx-link-1.3.0/nbsphinx_link/_version.py
--- old/nbsphinx-link-1.2.0/nbsphinx_link/_version.py   2019-01-28 
17:22:53.000000000 +0100
+++ new/nbsphinx-link-1.3.0/nbsphinx_link/_version.py   2019-10-01 
16:15:04.000000000 +0200
@@ -1,2 +1,2 @@
-version_info = (1, 2, 0)
+version_info = (1, 3, 0)
 __version__ = ".".join(map(str, version_info))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/nbsphinx_link.egg-info/PKG-INFO 
new/nbsphinx-link-1.3.0/nbsphinx_link.egg-info/PKG-INFO
--- old/nbsphinx-link-1.2.0/nbsphinx_link.egg-info/PKG-INFO     2019-01-28 
17:24:03.000000000 +0100
+++ new/nbsphinx-link-1.3.0/nbsphinx_link.egg-info/PKG-INFO     2019-10-01 
16:15:30.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: nbsphinx-link
-Version: 1.2.0
+Version: 1.3.0
 Summary: A sphinx extension for including notebook files outside sphinx source 
root
 Home-page: https://github.com/vidartf/nbsphinx-link
 Author: Vidar Tonaas Fauske
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/nbsphinx-link-1.2.0/nbsphinx_link.egg-info/SOURCES.txt 
new/nbsphinx-link-1.3.0/nbsphinx_link.egg-info/SOURCES.txt
--- old/nbsphinx-link-1.2.0/nbsphinx_link.egg-info/SOURCES.txt  2019-01-28 
17:24:03.000000000 +0100
+++ new/nbsphinx-link-1.3.0/nbsphinx_link.egg-info/SOURCES.txt  2019-10-01 
16:15:30.000000000 +0200
@@ -17,4 +17,7 @@
 nbsphinx_link.egg-info/dependency_links.txt
 nbsphinx_link.egg-info/requires.txt
 nbsphinx_link.egg-info/top_level.txt
-notebooks/introduction.ipynb
\ No newline at end of file
+notebooks/introduction.ipynb
+notebooks/smile.png
+notebooks/images/smile.png
+notebooks/images/subsubdir/smile.png
\ No newline at end of file
Binary files old/nbsphinx-link-1.2.0/notebooks/images/smile.png and 
new/nbsphinx-link-1.3.0/notebooks/images/smile.png differ
Binary files old/nbsphinx-link-1.2.0/notebooks/images/subsubdir/smile.png and 
new/nbsphinx-link-1.3.0/notebooks/images/subsubdir/smile.png differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-link-1.2.0/notebooks/introduction.ipynb 
new/nbsphinx-link-1.3.0/notebooks/introduction.ipynb
--- old/nbsphinx-link-1.2.0/notebooks/introduction.ipynb        2018-05-23 
19:13:55.000000000 +0200
+++ new/nbsphinx-link-1.3.0/notebooks/introduction.ipynb        2019-09-27 
14:35:18.000000000 +0200
@@ -1,79 +1,103 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Introduction"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "For a start, consider the documentation folder of the nbsphinx-link 
repository. This documentation page itself comes from a linked notebook:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 1,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "foobar\n"
-     ]
-    }
-   ],
-   "source": [
-    "def foo(a):\n",
-    "    return 'foo' + a\n",
-    "\n",
-    "print(foo('bar'))"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "After the installation steps (installing the package, and adding 
`nbsphinx_link` as an extension in the Sphinx config), you can link external 
notebooks by including `.nblink` files in your documentation source tree. The 
format of the link file is as follows:\n",
-    "\n",
-    "```json\n",
-    "{\n",
-    "    \"path\": \"relative/path/to/notebook\"\n",
-    "}\n",
-    "```"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "It should then Just Work. For further information and examples, consider 
inspecting the Sphinx config file of the nbsphinx-link repository!"
-   ]
-  }
- ],
- "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.6.5"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Introduction"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "For a start, consider the documentation folder of the nbsphinx-link 
repository. This documentation page itself comes from a linked notebook:"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "foobar\n"
+     ]
+    }
+   ],
+   "source": [
+    "def foo(a):\n",
+    "    return 'foo' + a\n",
+    "\n",
+    "print(foo('bar'))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "After the installation steps (installing the package, and adding 
`nbsphinx_link` as an extension in the Sphinx config), you can link external 
notebooks by including `.nblink` files in your documentation source tree. The 
format of the link file is as follows:\n",
+    "\n",
+    "```json\n",
+    "{\n",
+    "    \"path\": \"relative/path/to/notebook\"\n",
+    "}\n",
+    "```"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "It should then Just Work. For further information and examples, consider 
inspecting the Sphinx config file of the nbsphinx-link repository!"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Image including example\n",
+    "Look at this happy smile, because the notebook made it in the docs.\n",
+    "\n",
+    "### Image path next to notebook\n",
+    "![python logo 1](smile.png)\n",
+    "\n",
+    "### Image path in subdirectory notebook\n",
+    "![python logo 2](images/smile.png)\n",
+    "\n",
+    "### Image path in sub-subdirectory notebook\n",
+    "![python logo 3](images/subsubdir/smile.png)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "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.7.3"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
Binary files old/nbsphinx-link-1.2.0/notebooks/smile.png and 
new/nbsphinx-link-1.3.0/notebooks/smile.png differ


Reply via email to