Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subclassing xarray.DataArray with autodoc flag :inherited-members: raises opaque error in sphinx 1.6+ #3885

Closed
hazbottles opened this issue Jun 23, 2017 · 3 comments

Comments

@hazbottles
Copy link

hazbottles commented Jun 23, 2017

Subject: subclassing xarray.DataArray with autodoc flag :inherited-members: raises opaque error in sphinx 1.6+

Problem

using :inherited-members: as an autodoc flag raises an opaque error when subclassing xarray.DataArray (http://xarray.pydata.org/en/stable/generated/xarray.DataArray.html) in Sphinx 1.6. This did not occur in Sphinx 1.5.

Procedure to reproduce the problem

see: https://github.com/hazbottles/sphinx_bug_with_xarray_subclass

Error logs / results

# Sphinx version: 1.6.2
# Python version: 3.6.1 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.6
# Last messages:
#   building [html]: targets for 2 source files that are out of date
#
#   updating environment:
#
#   2 added, 0 changed, 0 removed
#
#   reading sources... [ 50%] index
#
#   reading sources... [100%] my_module
#
# Loaded extensions:
#   alabaster (0.7.10) from /home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/alabaster/__init__.py
#   sphinx.ext.autodoc (1.6.2) from /home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/ext/autodoc.py
Traceback (most recent call last):
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/cmdline.py", line 306, in main
    app.build(opts.force_all, filenames)
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/application.py", line 339, in build
    self.builder.build_update()
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/builders/__init__.py", line 328, in build_update
    'out of date' % len(to_build))
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/builders/__init__.py", line 341, in build
    updated_docnames = set(self.env.update(self.config, self.srcdir, self.doctreedir))
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/environment/__init__.py", line 584, in update
    self._read_serial(docnames, self.app)
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/environment/__init__.py", line 603, in _read_serial
    self.read_doc(docname, app)
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/environment/__init__.py", line 724, in read_doc
    pub.publish()
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/docutils/core.py", line 218, in publish
    self.apply_transforms()
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/docutils/core.py", line 199, in apply_transforms
    self.document.transformer.apply_transforms()
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/home/accounts/this_user/local/miniconda2/envs/sphinx_test/lib/python3.6/site-packages/Sphinx-1.6.2-py3.6.egg/sphinx/transforms/__init__.py", line 292, in apply
    if node['names'][0] not in self.document.footnote_refs:
IndexError: list index out of range

Expected results

Raise a warning, but render as it did in sphinx 1.5, or even just a more informative error message (took me a long time to chase down it was a problem with :inherited-members: interacting with xarray's documentation)

Reproducible project / your project

https://github.com/hazbottles/sphinx_bug_with_xarray_subclass

Environment info

  • OS: Fedora 23
  • Python version: 3.6.1
  • Sphinx version: 1.6.2
@tk0miya
Copy link
Member

tk0miya commented Jun 24, 2017

I just reproduced with following code:

.. automodule:: example
   :members:
class Foo(object):
    """Foo class! [1]_

    .. [1] foo
    """

    def bar(self, *args, **kwargs):
        """Foo.bar method! [1]_

        .. [1] bar
        """

@tk0miya
Copy link
Member

tk0miya commented Jun 24, 2017

This is minimal reproducible example. This is not related with autodoc.

# index.rst

.. [1] foo
.. [1] foo

Note:

/Users/tkomiya/work/tmp/doc/index.rst:10: WARNING: Duplicate explicit target name: "1".

@tk0miya
Copy link
Member

tk0miya commented Jun 24, 2017

Fixed at 5123dad.
Thank you for reporting!

@tk0miya tk0miya closed this as completed Jun 24, 2017
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants