Hello community,

here is the log from the commit of package python-jupyter_nbsphinx for 
openSUSE:Factory checked in at 2018-04-30 22:56:38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-jupyter_nbsphinx (Old)
 and      /work/SRC/openSUSE:Factory/.python-jupyter_nbsphinx.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-jupyter_nbsphinx"

Mon Apr 30 22:56:38 2018 rev:7 rq:602304 version:0.3.3

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-jupyter_nbsphinx/python-jupyter_nbsphinx.changes
  2018-04-19 15:32:30.111630378 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-jupyter_nbsphinx.new/python-jupyter_nbsphinx.changes
     2018-04-30 22:58:59.180356787 +0200
@@ -1,0 +2,7 @@
+Sat Apr 28 19:29:14 UTC 2018 - toddrme2...@gmail.com
+
+- Update to version 0.3.3
+  * Locally linked files are only copied for Jupyter notebooks
+    (and not anymore for other Sphinx source files)
+
+-------------------------------------------------------------------

Old:
----
  nbsphinx-0.3.2.tar.gz

New:
----
  nbsphinx-0.3.3.tar.gz

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

Other differences:
------------------
++++++ python-jupyter_nbsphinx.spec ++++++
--- /var/tmp/diff_new_pack.rw2Wmb/_old  2018-04-30 22:58:59.668338981 +0200
+++ /var/tmp/diff_new_pack.rw2Wmb/_new  2018-04-30 22:58:59.672338835 +0200
@@ -18,7 +18,7 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-jupyter_nbsphinx
-Version:        0.3.2
+Version:        0.3.3
 Release:        0
 Summary:        Jupyter Notebook Tools for Sphinx
 License:        MIT

++++++ nbsphinx-0.3.2.tar.gz -> nbsphinx-0.3.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-0.3.2/NEWS.rst new/nbsphinx-0.3.3/NEWS.rst
--- old/nbsphinx-0.3.2/NEWS.rst 2018-03-28 13:44:00.000000000 +0200
+++ new/nbsphinx-0.3.3/NEWS.rst 2018-04-25 10:02:27.000000000 +0200
@@ -1,3 +1,7 @@
+Version 0.3.3 (2018-04-25):
+ * Locally linked files are only copied for Jupyter notebooks (and not anymore
+   for other Sphinx source files)
+
 Version 0.3.2 (2018-03-28):
  * Links to local files are rewritten for all Sphinx source files (not only
    Jupyter notebooks)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-0.3.2/PKG-INFO new/nbsphinx-0.3.3/PKG-INFO
--- old/nbsphinx-0.3.2/PKG-INFO 2018-03-28 13:46:05.000000000 +0200
+++ new/nbsphinx-0.3.3/PKG-INFO 2018-04-25 10:05:36.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: nbsphinx
-Version: 0.3.2
+Version: 0.3.3
 Summary: Jupyter Notebook Tools for Sphinx
 Home-page: http://nbsphinx.readthedocs.io/
 Author: Matthias Geier
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-0.3.2/doc/a-normal-rst-file.rst 
new/nbsphinx-0.3.3/doc/a-normal-rst-file.rst
--- old/nbsphinx-0.3.2/doc/a-normal-rst-file.rst        2018-03-26 
12:31:38.000000000 +0200
+++ new/nbsphinx-0.3.3/doc/a-normal-rst-file.rst        2018-04-18 
11:15:24.000000000 +0200
@@ -75,19 +75,6 @@
     .. _subsection: subdir/a-notebook-in-a-subdir.ipynb#A-Sub-Section
 
 
-Links to Local Files (HTML only)
---------------------------------
-
-If you use any of the above-mentioned methods to link to a local file that
-*isn't* a Sphinx source file, it will be automatically copied to the HTML 
output
-directory, like it would if you `link from a notebook`__.
-
-Alternatively, you can of course as always use Sphinx's download__ role.
-
-__ markdown-cells.ipynb#Links-to-Local-Files-(HTML-only)
-__ http://www.sphinx-doc.org/en/stable/markup/inline.html#role-download
-
-
 Links to Notebooks, Ye Olde Way
 -------------------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-0.3.2/src/nbsphinx.egg-info/PKG-INFO 
new/nbsphinx-0.3.3/src/nbsphinx.egg-info/PKG-INFO
--- old/nbsphinx-0.3.2/src/nbsphinx.egg-info/PKG-INFO   2018-03-28 
13:46:05.000000000 +0200
+++ new/nbsphinx-0.3.3/src/nbsphinx.egg-info/PKG-INFO   2018-04-25 
10:05:36.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: nbsphinx
-Version: 0.3.2
+Version: 0.3.3
 Summary: Jupyter Notebook Tools for Sphinx
 Home-page: http://nbsphinx.readthedocs.io/
 Author: Matthias Geier
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbsphinx-0.3.2/src/nbsphinx.py 
new/nbsphinx-0.3.3/src/nbsphinx.py
--- old/nbsphinx-0.3.2/src/nbsphinx.py  2018-03-28 13:41:57.000000000 +0200
+++ new/nbsphinx-0.3.3/src/nbsphinx.py  2018-04-25 10:00:30.000000000 +0200
@@ -23,7 +23,7 @@
 http://nbsphinx.rtfd.org/
 
 """
-__version__ = '0.3.2'
+__version__ = '0.3.3'
 
 import copy
 import json
@@ -476,21 +476,6 @@
     margin-top: -19px;
 }
 
-/* nice headers on first paragraph of info/warning boxes */
-.admonition .first {
-    margin: -12px;
-    padding: 6px 12px;
-    margin-bottom: 12px;
-    color: #fff;
-    line-height: 1;
-    display: block;
-}
-.admonition.warning .first {
-    background: #f0b37e;
-}
-.admonition.note .first {
-    background: #6ab0de;
-}
 .admonition > p:before {
     margin-right: 4px;  /* make room for the exclamation icon */
 }
@@ -501,7 +486,7 @@
 
 /* nicer titles and more space for info and warning logos */
 
-div.admonition > .first {
+div.admonition p.admonition-title {
     background: rgba(0, 0, 0, .05);
     margin: .5em -1em;
     margin-top: -.5em !important;
@@ -618,6 +603,7 @@
         return rst.Parser.get_transforms(self) + [
             CreateNotebookSectionAnchors,
             ReplaceAlertDivs,
+            CopyLinkedFiles,
         ]
 
     def parse(self, inputstring, document):
@@ -1003,11 +989,48 @@
             node.attributes[attr] = value
 
 
-class ProcessLocalLinks(docutils.transforms.Transform):
-    """Process links to local files.
+def _local_file_from_reference(node, document):
+    """Get local file path from reference and split it into components."""
+    # NB: Anonymous hyperlinks must be already resolved at this point!
+    refuri = node.get('refuri')
+    if not refuri:
+        refname = node.get('refname')
+        if refname:
+            refid = document.nameids.get(refname)
+        else:
+            # NB: This can happen for anonymous hyperlinks
+            refid = node.get('refid')
+        target = document.ids.get(refid)
+        if not target:
+            # No corresponding target, Sphinx may warn later
+            return '', '', ''
+        refuri = target.get('refuri')
+        if not refuri:
+            # Target doesn't have URI
+            return '', '', ''
+    if '://' in refuri:
+        # Not a local link
+        return '', '', ''
+    elif refuri.startswith('#') or refuri.startswith('mailto:'):
+        # Not a local link
+        return '', '', ''
+
+    # NB: We look for "fragment identifier" before unquoting
+    match = re.match(r'^([^#]+)(\.[^#]+)(#.+)$', refuri)
+    if match:
+        base = unquote(match.group(1))
+        # NB: The suffix and "fragment identifier" are not unquoted
+        suffix = match.group(2)
+        fragment = match.group(3)
+    else:
+        base, suffix = os.path.splitext(refuri)
+        base = unquote(base)
+        fragment = ''
+    return base, suffix, fragment
+
 
-    Marks local files to be copied to the HTML output directory and
-    turns links to source files into ``:doc:``/``:ref:`` links.
+class RewriteLocalLinks(docutils.transforms.Transform):
+    """Turn links to source files into ``:doc:``/``:ref:`` links.
 
     Links to subsections are possible with ``...#Subsection-Title``.
     These links use the labels created by CreateSectionLabels.
@@ -1027,69 +1050,28 @@
 
     default_priority = 500  # After AnonymousHyperlinks (440)
 
-    _subsection_re = re.compile(r'^([^#]+)((\.[^#]+)#.+)$')
-
     def apply(self):
         env = self.document.settings.env
         for node in self.document.traverse(docutils.nodes.reference):
-            # NB: Anonymous hyperlinks must be already resolved at this point!
-            refuri = node.get('refuri')
-            if not refuri:
-                refname = node.get('refname')
-                if refname:
-                    refid = self.document.nameids.get(refname)
-                else:
-                    # NB: This can happen for anonymous hyperlinks
-                    refid = node.get('refid')
-                target = self.document.ids.get(refid)
-                if not target:
-                    continue  # No corresponding target, Sphinx may warn later
-                refuri = target.get('refuri')
-                if not refuri:
-                    continue  # Target doesn't have URI
-
-            if '://' in refuri:
-                continue  # Not a local link
-            elif refuri.startswith('#') or refuri.startswith('mailto:'):
-                continue  # Nothing to be done
+            base, suffix, fragment = _local_file_from_reference(node,
+                                                                self.document)
+            if not base:
+                continue
 
-            # NB: We look for "fragment identifier" before unquoting
-            fragment = self._subsection_re.match(refuri)
-            refuri = unquote(refuri)
-            for suffix in env.config.source_suffix:
-                if fragment:
-                    if fragment.group(3).lower() == suffix.lower():
-                        target = unquote(fragment.group(1))
-                        # NB: The "fragment identifier" is not unquoted
-                        target_ext = fragment.group(2)
+            for s in env.config.source_suffix:
+                if suffix.lower() == s.lower():
+                    target = base
+                    if fragment:
+                        target_ext = suffix + fragment
                         reftype = 'ref'
                         refdomain = 'std'
-                        break
-                else:
-                    if refuri.lower().endswith(suffix.lower()):
-                        target = refuri[:-len(suffix)]
+                    else:
                         target_ext = ''
                         reftype = 'doc'
                         refdomain = None
-                        break
+                    break
             else:
-                if fragment:
-                    refuri = unquote(fragment.group(1)) + fragment.group(3)
-                file = os.path.normpath(
-                    os.path.join(os.path.dirname(env.docname), refuri))
-                if not os.path.isfile(os.path.join(env.srcdir, file)):
-                    env.app.warn('file not found: {!r}'.format(file),
-                                 env.doc2path(env.docname))
-                    continue  # Link is ignored
-                elif file.startswith('..'):
-                    env.app.warn(
-                        'link outside of source directory: {!r}'.format(file),
-                        env.doc2path(env.docname))
-                    continue  # Link is ignored
-                if not hasattr(env, 'nbsphinx_files'):
-                    env.nbsphinx_files = {}
-                env.nbsphinx_files.setdefault(env.docname, []).append(file)
-                continue  # We're done here
+                continue  # Not a link to a potential Sphinx source file
 
             target_docname = nbconvert.filters.posix_path(os.path.normpath(
                 os.path.join(os.path.dirname(env.docname), target)))
@@ -1124,7 +1106,7 @@
 class CreateSectionLabels(docutils.transforms.Transform):
     """Make labels for each document and each section thereof.
 
-    These labels are referenced in ProcessLocalLinks but can also be
+    These labels are referenced in RewriteLocalLinks but can also be
     used manually with ``:ref:``.
 
     """
@@ -1235,6 +1217,35 @@
                     content.append(sibling)
 
 
+class CopyLinkedFiles(docutils.transforms.Transform):
+    """Mark linked (local) files to be copied to the HTML output."""
+
+    default_priority = 600  # After RewriteLocalLinks
+
+    def apply(self):
+        env = self.document.settings.env
+        for node in self.document.traverse(docutils.nodes.reference):
+            base, suffix, fragment = _local_file_from_reference(node,
+                                                                self.document)
+            if not base:
+                continue  # Not a local link
+            relpath = base + suffix + fragment
+            file = os.path.normpath(
+                os.path.join(os.path.dirname(env.docname), relpath))
+            if not os.path.isfile(os.path.join(env.srcdir, file)):
+                env.app.warn('file not found: {!r}'.format(file),
+                             env.doc2path(env.docname))
+                continue  # Link is ignored
+            elif file.startswith('..'):
+                env.app.warn(
+                    'link outside of source directory: {!r}'.format(file),
+                    env.doc2path(env.docname))
+                continue  # Link is ignored
+            if not hasattr(env, 'nbsphinx_files'):
+                env.nbsphinx_files = {}
+            env.nbsphinx_files.setdefault(env.docname, []).append(file)
+
+
 def builder_inited(app):
     # Add LaTeX definitions to preamble
     latex_elements = app.builder.config.latex_elements
@@ -1373,12 +1384,11 @@
 
 def visit_admonition_html(self, node):
     self.body.append(self.starttag(node, 'div'))
-    self.set_first_last(node)
-    if self.settings.env.config.html_theme in ('sphinx_rtd_theme', 'julia'):
-        if node.children:
-            classes = node.children[0]['classes']
-            if 'last' not in classes:
-                classes.extend(['fa', 'fa-exclamation-circle'])
+    if len(node.children) >= 2:
+        node[0]['classes'].append('admonition-title')
+        html_theme = self.settings.env.config.html_theme
+        if html_theme in ('sphinx_rtd_theme', 'julia'):
+            node.children[0]['classes'].extend(['fa', 'fa-exclamation-circle'])
 
 
 def depart_admonition_html(self, node):
@@ -1453,7 +1463,7 @@
     app.connect('env-purge-doc', env_purge_doc)
     app.add_transform(CreateSectionLabels)
     app.add_transform(CreateDomainObjectLabels)
-    app.add_transform(ProcessLocalLinks)
+    app.add_transform(RewriteLocalLinks)
 
     # Make docutils' "code" directive (generated by markdown2rst/pandoc)
     # behave like Sphinx's "code-block",


Reply via email to