Hello community, here is the log from the commit of package python-jupyter_nbsphinx for openSUSE:Factory checked in at 2018-04-19 15:32:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-jupyter_nbsphinx (Old) and /work/SRC/openSUSE:Factory/.python-jupyter_nbsphinx.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jupyter_nbsphinx" Thu Apr 19 15:32:25 2018 rev:6 rq:597932 version:0.3.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-jupyter_nbsphinx/python-jupyter_nbsphinx.changes 2018-02-19 13:01:01.941937615 +0100 +++ /work/SRC/openSUSE:Factory/.python-jupyter_nbsphinx.new/python-jupyter_nbsphinx.changes 2018-04-19 15:32:30.111630378 +0200 @@ -1,0 +2,7 @@ +Thu Apr 19 05:06:27 UTC 2018 - toddrme2...@gmail.com + +- Update to version 0.3.2 + * Links to local files are rewritten for all Sphinx source files (not only + Jupyter notebooks) + +------------------------------------------------------------------- Old: ---- nbsphinx-0.3.1.tar.gz New: ---- nbsphinx-0.3.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-jupyter_nbsphinx.spec ++++++ --- /var/tmp/diff_new_pack.14bYrQ/_old 2018-04-19 15:32:31.251583425 +0200 +++ /var/tmp/diff_new_pack.14bYrQ/_new 2018-04-19 15:32:31.255583261 +0200 @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-jupyter_nbsphinx -Version: 0.3.1 +Version: 0.3.2 Release: 0 Summary: Jupyter Notebook Tools for Sphinx License: MIT ++++++ nbsphinx-0.3.1.tar.gz -> nbsphinx-0.3.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/NEWS.rst new/nbsphinx-0.3.2/NEWS.rst --- old/nbsphinx-0.3.1/NEWS.rst 2018-01-17 14:09:56.000000000 +0100 +++ new/nbsphinx-0.3.2/NEWS.rst 2018-03-28 13:44:00.000000000 +0200 @@ -1,3 +1,7 @@ +Version 0.3.2 (2018-03-28): + * Links to local files are rewritten for all Sphinx source files (not only + Jupyter notebooks) + Version 0.3.1 (2018-01-17): * Enable notebook translations (NB: The use of reST strings is temporary!) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/PKG-INFO new/nbsphinx-0.3.2/PKG-INFO --- old/nbsphinx-0.3.1/PKG-INFO 2018-01-17 14:11:40.000000000 +0100 +++ new/nbsphinx-0.3.2/PKG-INFO 2018-03-28 13:46:05.000000000 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: nbsphinx -Version: 0.3.1 +Version: 0.3.2 Summary: Jupyter Notebook Tools for Sphinx Home-page: http://nbsphinx.readthedocs.io/ Author: Matthias Geier Author-email: matthias.ge...@gmail.com License: MIT -Description-Content-Type: UNKNOWN Description: Jupyter Notebook Tools for Sphinx ================================= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/doc/a-normal-rst-file.rst new/nbsphinx-0.3.2/doc/a-normal-rst-file.rst --- old/nbsphinx-0.3.1/doc/a-normal-rst-file.rst 2018-01-02 12:04:07.000000000 +0100 +++ new/nbsphinx-0.3.2/doc/a-normal-rst-file.rst 2018-03-26 12:31:38.000000000 +0200 @@ -5,21 +5,122 @@ .. note:: Those still work! -Links to Notebooks ------------------- +Links to Notebooks (and Other Sphinx Source Files) +-------------------------------------------------- -Links to notebooks can be easily created: -:ref:`/subdir/a-notebook-in-a-subdir.ipynb` -(the notebook title is used as link text). -You can also use -:ref:`an alternative text </subdir/a-notebook-in-a-subdir.ipynb>`. +Links to Sphinx source files can be created like normal `Sphinx hyperlinks`_, +just using a relative path to the local file: link_. -The above links were created with: +.. _Sphinx hyperlinks: http://www.sphinx-doc.org/en/stable/rest.html + #external-links +.. _link: subdir/a-notebook-in-a-subdir.ipynb + +.. code-block:: rst + + using a relative path to the local file: link_. + + .. _link: subdir/a-notebook-in-a-subdir.ipynb + +If the link text has a space (or some other strange character) in it, you have +to surround it with backticks: `a notebook link`_. + +.. _a notebook link: subdir/a-notebook-in-a-subdir.ipynb + +.. code-block:: rst + + surround it with backticks: `a notebook link`_. + + .. _a notebook link: subdir/a-notebook-in-a-subdir.ipynb + +You can also use an `anonymous hyperlink target`_, like this: link__. +If you have multiple of those, their order matters! + +.. _anonymous hyperlink target: http://docutils.sourceforge.net/docs/ref/rst/ + restructuredtext.html#anonymous-hyperlinks + +__ subdir/a-notebook-in-a-subdir.ipynb + +.. code-block:: rst + + like this: link__. + + __ subdir/a-notebook-in-a-subdir.ipynb + +Finally, you can use `Embedded URIs`_, like this +`link <subdir/a-notebook-in-a-subdir.ipynb>`_. + +.. _Embedded URIs: http://docutils.sourceforge.net/docs/ref/rst/ + restructuredtext.html#embedded-uris-and-aliases + +.. code-block:: rst + + like this `link <subdir/a-notebook-in-a-subdir.ipynb>`_. + +.. note:: + + These links should also work on Github and in other rendered + reStructuredText pages. + +Links to subsections are also possible by adding a hash sign (``#``) and the +section title to any of the above-mentioned link variants. +You have to replace spaces in the section titles by hyphens. +For example, see this subsection_. + +.. _subsection: subdir/a-notebook-in-a-subdir.ipynb#A-Sub-Section + +.. code-block:: rst + + For example, see this subsection_. + + .. _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 +------------------------------- + +In addition to the way shown above, you can also create links to notebooks (and +other Sphinx source files) with +`:ref: <http://www.sphinx-doc.org/en/stable/markup/inline.html#role-ref>`_. +This has some disadvantages: + +* It is arguably a bit more clunky. +* Because ``:ref:`` is a Sphinx feature, the links don't work on Github and + other rendered reStructuredText pages that use plain old ``docutils``. + +It also has one important advantage: + +* The link text can automatically be taken from the actual section title. + +A link with automatic title looks like this: +:ref:`/subdir/a-notebook-in-a-subdir.ipynb`. .. code-block:: rst :ref:`/subdir/a-notebook-in-a-subdir.ipynb` - :ref:`an alternative text </subdir/a-notebook-in-a-subdir.ipynb>` + +But you can also provide +:ref:`your own link title </subdir/a-notebook-in-a-subdir.ipynb>`. + +.. code-block:: rst + + :ref:`your own link title </subdir/a-notebook-in-a-subdir.ipynb>` + +However, if you want to use your own title, you are probably better off using +the method described above in +`Links to Notebooks (and Other Sphinx Source Files)`_. Links to subsections are also possible, e.g. :ref:`/subdir/a-notebook-in-a-subdir.ipynb#A-Sub-Section` @@ -35,9 +136,9 @@ .. note:: + * The paths have to be relative to the top source directory and they have to + start with a slash (``/``). * Spaces in the section title have to be replaced by hyphens! - * Notebook paths have to be relative to the top source directory and they - have to start with a slash (``/``). Sphinx Directives for Info/Warning Boxes ---------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/doc/markdown-cells.ipynb new/nbsphinx-0.3.2/doc/markdown-cells.ipynb --- old/nbsphinx-0.3.1/doc/markdown-cells.ipynb 2018-01-16 11:44:50.000000000 +0100 +++ new/nbsphinx-0.3.2/doc/markdown-cells.ipynb 2018-03-19 09:36:55.000000000 +0100 @@ -263,7 +263,6 @@ "\n", "Sphinx section anchors are different from Jupyter section anchors!\n", "To create a link to a subsection in an `.rst` file (or another non-notebook source file), you not only have to replace spaces with hyphens, but also slashes and some other characters.\n", - "Furthermore, you have to change the whole section title to lowercase letters.\n", "In case of doubt, just check the target HTML page generated by Sphinx.\n", "\n", "</div>" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/doc/orphan.ipynb new/nbsphinx-0.3.2/doc/orphan.ipynb --- old/nbsphinx-0.3.1/doc/orphan.ipynb 2018-01-16 11:44:50.000000000 +0100 +++ new/nbsphinx-0.3.2/doc/orphan.ipynb 2018-03-26 12:31:38.000000000 +0200 @@ -23,16 +23,10 @@ " [some link text](notebookname.ipynb)\n", " ```\n", "\n", - "* ... from a [reST page](a-normal-rst-file.rst#Links-to-Notebooks) using\n", + "* ... from a [reST page](a-normal-rst-file.rst#links-to-notebooks-and-other-sphinx-source-files) using\n", "\n", " ```rst\n", - " :ref:`/notebookname.ipynb`\n", - " ```\n", - "\n", - " or\n", - "\n", - " ```rst\n", - " :ref:`alternative link text </notebookname.ipynb>`\n", + " `some link text <notebookname.ipynb>`_\n", " ```\n", "\n", "Sphinx raises a warning in case of orphaned documents:\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/doc/prolog-and-epilog.ipynb new/nbsphinx-0.3.2/doc/prolog-and-epilog.ipynb --- old/nbsphinx-0.3.1/doc/prolog-and-epilog.ipynb 2018-01-16 11:44:50.000000000 +0100 +++ new/nbsphinx-0.3.2/doc/prolog-and-epilog.ipynb 2018-03-03 17:25:10.000000000 +0100 @@ -19,7 +19,7 @@ "This can be done with the configuration values `nbsphinx_prolog` and `nbsphinx_epilog` in the file `conf.py`.\n", "\n", "The prolog and epilog strings can hold arbitrary [reST](http://sphinx-doc.org/rest.html) markup.\n", - "Particularly, the [only](http://www.sphinx-doc.org/markup/misc.html#directive-only) and [raw](http://docutils.sourceforge.net/docs/ref/rst/directives.html#raw-data-pass-through) directives can be used to have different content for HTML and LaTeX output.\n", + "Particularly, the [only](http://www.sphinx-doc.org/markup/misc.html#directive-only) and [raw](https://docutils.readthedocs.io/en/sphinx-docs/ref/rst/directives.html#raw-data-pass-through) directives can be used to have different content for HTML and LaTeX output.\n", "\n", "Those strings are also processed by the [Jinja2](http://jinja.pocoo.org/) templating engine.\n", "This means you can run Python-like code within those strings.\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/doc/subdir/a-notebook-in-a-subdir.ipynb new/nbsphinx-0.3.2/doc/subdir/a-notebook-in-a-subdir.ipynb --- old/nbsphinx-0.3.1/doc/subdir/a-notebook-in-a-subdir.ipynb 2018-01-08 13:34:36.000000000 +0100 +++ new/nbsphinx-0.3.2/doc/subdir/a-notebook-in-a-subdir.ipynb 2018-03-19 09:36:55.000000000 +0100 @@ -42,6 +42,8 @@ "\n", "</div>\n", "\n", + "A link to a notebook in the same sub-directory: [link](toctree.ipynb).\n", + "\n", "A link to a notebook in the parent directory: [link](../markdown-cells.ipynb).\n", "\n", "A link to a local file: [link](../images/notebook_icon.png).\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/doc/usage.ipynb new/nbsphinx-0.3.2/doc/usage.ipynb --- old/nbsphinx-0.3.1/doc/usage.ipynb 2018-01-16 11:44:50.000000000 +0100 +++ new/nbsphinx-0.3.2/doc/usage.ipynb 2018-03-10 11:02:18.000000000 +0100 @@ -298,8 +298,8 @@ " [usage](https://github.com/spatialaudio/nbsphinx/compare/cloud-theme^...cloud-theme)\n", "\n", "* [sphinx_py3doc_enhanced_theme](https://github.com/ionelmc/sphinx-py3doc-enhanced-theme):\n", - " [example](http://nbsphinx.readthedocs.io/en/py3doc-enh-theme/),\n", - " [usage](https://github.com/spatialaudio/nbsphinx/compare/py3doc-enh-theme^...py3doc-enh-theme)\n", + " [example](http://nbsphinx.readthedocs.io/en/py3doc-enhanced-theme/),\n", + " [usage](https://github.com/spatialaudio/nbsphinx/compare/py3doc-enhanced-theme^...py3doc-enhanced-theme)\n", "\n", "* [basicstrap](http://pythonhosted.org/sphinxjp.themes.basicstrap/):\n", " [example](http://nbsphinx.readthedocs.io/en/basicstrap-theme/),\n", @@ -329,7 +329,8 @@ " [example](http://nbsphinx.readthedocs.io/en/jupyter-alabaster-theme/),\n", " [usage](https://github.com/spatialaudio/nbsphinx/compare/jupyter-alabaster-theme^...jupyter-alabaster-theme)\n", "\n", - "If you know of another Sphinx theme that should be included here, please open an [issue on Github](https://github.com/spatialaudio/nbsphinx/issues)." + "If you know of another Sphinx theme that should be included here, please open an [issue on Github](https://github.com/spatialaudio/nbsphinx/issues).\n", + "An overview of many more themes can be found at https://sphinx-themes.org/." ] }, { @@ -361,7 +362,7 @@ "* http://tillahoffmann.github.io/2017/04/17/versioning-jupyter-notebooks-with-git.html\n", "* http://timstaley.co.uk/posts/making-git-and-jupyter-notebooks-play-nice/\n", "* http://pascalbugnion.net/blog/ipython-notebooks-and-git.html\n", - "\n" + "* https://github.com/choldgraf/nbclean" ] } ], @@ -381,9 +382,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.4rc1" + "version": "3.6.4+" } }, "nbformat": 4, - "nbformat_minor": 1 + "nbformat_minor": 2 } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/src/nbsphinx.egg-info/PKG-INFO new/nbsphinx-0.3.2/src/nbsphinx.egg-info/PKG-INFO --- old/nbsphinx-0.3.1/src/nbsphinx.egg-info/PKG-INFO 2018-01-17 14:11:40.000000000 +0100 +++ new/nbsphinx-0.3.2/src/nbsphinx.egg-info/PKG-INFO 2018-03-28 13:46:05.000000000 +0200 @@ -1,12 +1,11 @@ Metadata-Version: 1.1 Name: nbsphinx -Version: 0.3.1 +Version: 0.3.2 Summary: Jupyter Notebook Tools for Sphinx Home-page: http://nbsphinx.readthedocs.io/ Author: Matthias Geier Author-email: matthias.ge...@gmail.com License: MIT -Description-Content-Type: UNKNOWN Description: Jupyter Notebook Tools for Sphinx ================================= diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/nbsphinx-0.3.1/src/nbsphinx.py new/nbsphinx-0.3.2/src/nbsphinx.py --- old/nbsphinx-0.3.1/src/nbsphinx.py 2018-01-17 14:06:38.000000000 +0100 +++ new/nbsphinx-0.3.2/src/nbsphinx.py 2018-03-28 13:41:57.000000000 +0200 @@ -23,7 +23,7 @@ http://nbsphinx.rtfd.org/ """ -__version__ = '0.3.1' +__version__ = '0.3.2' import copy import json @@ -616,7 +616,9 @@ def get_transforms(self): """List of transforms for documents parsed by this parser.""" return rst.Parser.get_transforms(self) + [ - ProcessLocalLinks, ReplaceAlertDivs] + CreateNotebookSectionAnchors, + ReplaceAlertDivs, + ] def parse(self, inputstring, document): """Parse *inputstring*, write results to *document*. @@ -1005,12 +1007,12 @@ """Process links to local files. Marks local files to be copied to the HTML output directory and - turns links to local notebooks into ``:doc:``/``:ref:`` links. + turns links to source files into ``:doc:``/``:ref:`` links. Links to subsections are possible with ``...#Subsection-Title``. These links use the labels created by CreateSectionLabels. - Links to subsections use ``:ref:``, links to whole notebooks use + Links to subsections use ``:ref:``, links to whole source files use ``:doc:``. Latter can be useful if you have an ``index.rst`` but also want a distinct ``index.ipynb`` for use with Jupyter. In this case you can use such a link in a notebook:: @@ -1023,42 +1025,58 @@ """ - default_priority = 400 # Should probably be adjusted? + default_priority = 500 # After AnonymousHyperlinks (440) - _subsection_re = re.compile(r'^(.+)(\..+#.+)$') + _subsection_re = re.compile(r'^([^#]+)((\.[^#]+)#.+)$') def apply(self): env = self.document.settings.env for node in self.document.traverse(docutils.nodes.reference): - uri = node.get('refuri', '') - if not uri: - continue # No URI (e.g. named reference) - elif '://' in uri: + # 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 uri.startswith('#') or uri.startswith('mailto:'): + elif refuri.startswith('#') or refuri.startswith('mailto:'): continue # Nothing to be done - unquoted_uri = unquote(uri) + # 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 unquoted_uri.lower().endswith(suffix.lower()): - target = unquoted_uri[:-len(suffix)] - break - else: - target = '' - - subsection_matches = self._subsection_re.match(uri) - if target: - target_ext = '' - reftype = 'doc' - refdomain = None - elif subsection_matches: - target = subsection_matches.group(1) - target_ext = subsection_matches.group(2) - reftype = 'ref' - refdomain = 'std' + 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) + reftype = 'ref' + refdomain = 'std' + break + else: + if refuri.lower().endswith(suffix.lower()): + target = refuri[:-len(suffix)] + target_ext = '' + reftype = 'doc' + refdomain = None + break else: + if fragment: + refuri = unquote(fragment.group(1)) + fragment.group(3) file = os.path.normpath( - os.path.join(os.path.dirname(env.docname), unquoted_uri)) + 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)) @@ -1073,30 +1091,41 @@ env.nbsphinx_files.setdefault(env.docname, []).append(file) continue # We're done here - target_docname = os.path.normpath( - os.path.join(os.path.dirname(env.docname), target)) + target_docname = nbconvert.filters.posix_path(os.path.normpath( + os.path.join(os.path.dirname(env.docname), target))) if target_docname in env.found_docs: - if target_ext: - target = target_docname + target_ext - target = target.lower() - target = '/' + target + reftarget = target_docname + target_ext + reftarget = '/' + reftarget.lower() linktext = node.astext() xref = sphinx.addnodes.pending_xref( - reftype=reftype, reftarget=target, refdomain=refdomain, + reftype=reftype, reftarget=reftarget, refdomain=refdomain, refwarn=True, refexplicit=True, refdoc=env.docname) xref += docutils.nodes.Text(linktext, linktext) node.replace_self(xref) -class CreateSectionLabels(docutils.transforms.Transform): - """Make labels for each document parsed by Sphinx, each section thereof, - and each Sphinx domain object. - - These labels are referenced in ProcessLocalLinks. +class CreateNotebookSectionAnchors(docutils.transforms.Transform): + """Create section anchors for Jupyter notebooks. Note: Sphinx lower-cases the HTML section IDs, Jupyter doesn't. - This transform creates labels in the Jupyter style for Jupyter - notebooks, but keeps the Sphinx style for all other source files. + This transform creates anchors in the Jupyter style. + + """ + + default_priority = 200 # Before CreateSectionLabels (250) + + def apply(self): + for section in self.document.traverse(docutils.nodes.section): + title = section.children[0].astext() + link_id = title.replace(' ', '-') + section['ids'] = [link_id] + + +class CreateSectionLabels(docutils.transforms.Transform): + """Make labels for each document and each section thereof. + + These labels are referenced in ProcessLocalLinks but can also be + used manually with ``:ref:``. """ @@ -1110,11 +1139,7 @@ assert section.children assert isinstance(section.children[0], docutils.nodes.title) title = section.children[0].astext() - if file_ext.lower() == '.ipynb': - link_id = title.replace(' ', '-') - section['ids'] = [link_id] - else: - link_id = section['ids'][0] + link_id = section['ids'][0] label = '/' + env.docname + file_ext + '#' + link_id label = label.lower() env.domaindata['std']['labels'][label] = ( @@ -1131,7 +1156,15 @@ env.docname, '') i_still_have_to_create_the_document_label = False - # Create labels for domain-specific object signatures + +class CreateDomainObjectLabels(docutils.transforms.Transform): + """Create labels for domain-specific object signatures.""" + + default_priority = 250 # About the same as CreateSectionLabels + + def apply(self): + env = self.document.settings.env + file_ext = os.path.splitext(env.doc2path(env.docname))[1] for sig in self.document.traverse(sphinx.addnodes.desc_signature): try: title = sig['ids'][0] @@ -1419,6 +1452,8 @@ app.connect('html-collect-pages', html_collect_pages) app.connect('env-purge-doc', env_purge_doc) app.add_transform(CreateSectionLabels) + app.add_transform(CreateDomainObjectLabels) + app.add_transform(ProcessLocalLinks) # Make docutils' "code" directive (generated by markdown2rst/pandoc) # behave like Sphinx's "code-block",