← All challenges
easysphinx-doc/sphinx · v3.1

overescaped trailing underscore on attribute with napoleon

docstoolingbase c087d717f6
Mode

60 minutes, the full token budget.

  • Time limit60 min
  • Token budgetup to 1M
  • Worth up to135 XP

Opens VS Code with an AI agent in a new tab. Prompts, tokens, tool calls and test runs are recorded and scored.

Problem statement

Describe the bug
Attribute name hello_ shows up as hello\_ in the html (visible backslash) with napoleon.

To Reproduce
Steps to reproduce the behavior:

empty __init__.py
a.py contains

python
class A:
    """
    Attributes
    ----------
    hello_: int
        hi
    """
    pass

run sphinx-quickstart
add 'sphinx.ext.autodoc', 'sphinx.ext.napoleon' to extensions in conf.py.
add .. autoclass:: a.A to index.rst
PYTHONPATH=. make clean html
open _build/html/index.html in web browser and see the ugly backslash.

Expected behavior
No backslash, a similar output to what I get for

rst
    .. attribute:: hello_
        :type: int

        hi

(the type shows up differently as well, but that's not the point here)
Older versions like 2.4.3 look ok to me.

Environment info

  • OS: Linux debian testing
  • Python version: 3.8.3
  • Sphinx version: 3.0.4
  • Sphinx extensions: sphinx.ext.autodoc, sphinx.ext.napoleon
  • Extra tools:
The environment starts at commit c087d717f6ed (sphinx-doc/sphinx 3.1), dependencies installed and tests runnable from the first minute. You are graded by hidden tests taken from the fix that was actually merged upstream.