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

IndexError: pop from empty list in depart_table when using sphinx_book_theme with custom extension djangodocs.py #13122

Open
zypdominate opened this issue Nov 11, 2024 · 1 comment
Labels
awaiting:response Waiting for a response from the author of this issue html theme python Pull requests that update Python code type:bug

Comments

@zypdominate
Copy link

Describe the bug

When building documentation for Django using sphinx_book_theme, an IndexError: pop from empty list occurs in the depart_table function of a custom extension (djangodocs.py). The error seems related to table handling and compatibility with the theme or Sphinx version.

How to Reproduce

Clone the Django documentation source:

git clone https://github.com/django/django.git
cd django/docs

Install necessary dependencies:

pip install sphinx sphinx-book-theme

Build the documentation with the specified theme:

.\make.bat html

Observe the IndexError occurring in the console.

Environment Information

# Platform:         win32; (Windows-11-10.0.22631-SP0)
# Sphinx version:   8.1.3
# Python version:   3.12.0 (CPython)
# Docutils version: 0.21.2
# Jinja2 version:   3.1.1
# Pygments version: 2.18.0
Theme: sphinx_book_theme (latest version)
Django Documentation Source: Cloned from https://github.com/django/django

Sphinx extensions

No response

Additional context

Error log

# Last messages:
#   faq/help
#   
#   
#   writing output... [  1%]
#   faq/index
#   
#   
#   writing output... [  1%]
#   faq/install
#   

# Loaded extensions:
#   sphinx.ext.mathjax (8.1.3)
#   alabaster (1.0.0)
#   sphinxcontrib.applehelp (2.0.0)
#   sphinxcontrib.devhelp (2.0.0)
#   sphinxcontrib.htmlhelp (2.1.0)
#   sphinxcontrib.serializinghtml (2.0.0)
#   sphinxcontrib.qthelp (2.0.0)
#   djangodocs (unknown version)
#   sphinx.ext.extlinks (8.1.3)
#   sphinx.ext.intersphinx (8.1.3)
#   sphinx.ext.viewcode (8.1.3)
#   sphinx.ext.autosectionlabel (8.1.3)
#   sphinx_book_theme (unknown version)
#   pydata_sphinx_theme (unknown version)

# Traceback:
Traceback (most recent call last):
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\cmd\build.py", line 514, in build_main
    app.build(args.force_all, args.filenames)
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\application.py", line 381, in build
    self.builder.build_update()
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 358, in build_update
    self.build(
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 437, in build
    self.write(docnames, list(updated_docnames), method)
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 711, in write
    self.write_documents(docnames)
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 725, in write_documents
    self._write_serial(sorted_docnames)
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\builders\__init__.py", line 744, in _write_serial
    self.write_doc(docname, doctree)
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\builders\html\__init__.py", line 653, in write_doc
    self.docwriter.write(doctree, destination)
  File "D:\software\Python\Python312\Lib\site-packages\docutils\writers\__init__.py", line 80, in write
    self.translate()
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\writers\html.py", line 35, in translate
    self.document.walkabout(visitor)
  File "D:\software\Python\Python312\Lib\site-packages\docutils\nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\software\Python\Python312\Lib\site-packages\docutils\nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\software\Python\Python312\Lib\site-packages\docutils\nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\software\Python\Python312\Lib\site-packages\docutils\nodes.py", line 199, in walkabout
    visitor.dispatch_departure(self)
  File "D:\software\Python\Python312\Lib\site-packages\sphinx\util\docutils.py", line 740, in dispatch_departure
    method(node)
  File "D:\software\Python\Python312\Lib\site-packages\pydata_sphinx_theme\translator.py", line 66, in depart_table
    super().depart_table(node)
  File "D:\Download\Django-doc\django\docs\_ext\djangodocs.py", line 128, in depart_table
    self.compact_p = self.context.pop()
                     ^^^^^^^^^^^^^^^^^^
IndexError: pop from empty list
@electric-coder
Copy link

electric-coder commented Nov 11, 2024

There's something strange about that extension list wanting 3 themes (alabaster, sphinx_book_theme (unknown version) and pydata_sphinx_theme (unknown version)) - did you install all those dependencies?

IndexError: pop from empty list occurs in the depart_table function of a custom extension (djangodocs.py)

You should likely ask at that extension's repository or the Django repository how their docs are supposed to be built, because there's also no djangodocs extension on pypi...

@jayaddison jayaddison added html theme awaiting:response Waiting for a response from the author of this issue python Pull requests that update Python code labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting:response Waiting for a response from the author of this issue html theme python Pull requests that update Python code type:bug
Projects
None yet
Development

No branches or pull requests

3 participants