Skip to content

Comments

swev-id: sphinx-doc__sphinx-9230#76

Open
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-9230from
noa/issue-70
Open

swev-id: sphinx-doc__sphinx-9230#76
casey-brooks wants to merge 1 commit intosphinx-doc__sphinx-9230from
noa/issue-70

Conversation

@casey-brooks
Copy link

@casey-brooks casey-brooks commented Dec 26, 2025

Summary

  • add a balanced delimiter splitter for typed docfield arguments so type detection ignores commas inside parentheses
  • add direct regression tests covering typed parameters with parenthesis/tuple syntax and autodoc reproduction
  • capture autodoc docstring scenario using the same legacy type strings

Reproduction Steps

Create a function with the following docstring and build docs with autodoc:

# example.py

def f(opc_meta):
    """Example function.

    :param dict(str, str) opc_meta: (optional)
    """
    return opc_meta

conf.py:

project = 'sphinx-9230-repro'
extensions = ['sphinx.ext.autodoc']
html_theme = 'alabaster'
import os, sys
sys.path.insert(0, os.path.abspath('..'))

Build:

PYTHONPATH=/workspace/sphinx python -m sphinx.cmd.build -b html /workspace/repro-9230/source /workspace/repro-9230/build

Observed Failure (before fix)

The parameter line renders incorrectly:

str) opc_meta (dict(str,) – (optional)

Expected Behavior (after fix)

opc_meta (dict(str, str)) – (optional)

Explanation of Change

Replace whitespace split with balanced-delimiter-aware split in sphinx/util/docfields.py so spaces inside parentheses/brackets are ignored while detecting the TYPE/NAME boundary.

Stack Trace

None. This is a formatting/rendering bug; no exception is raised.

Testing

  • pytest tests/test_domain_py.py -k "param_parentheses_commas or param_nested_tuple"
  • pytest tests/test_ext_autodoc.py -k "docstring_typed_params"

Resolves #70

@casey-brooks
Copy link
Author

Tests executed locally:

  • pytest tests/test_domain_py.py -k "param_parentheses_commas or param_nested_tuple" (2 selected, 2 passed)
  • pytest tests/test_ext_autodoc.py -k "docstring_typed_params" (1 selected, 1 passed)

All targeted suites passed; lint not applicable for these changes.

@rowan-stein rowan-stein changed the base branch from master to sphinx-doc__sphinx-9230 December 26, 2025 18:49
@rowan-stein rowan-stein requested a review from a team December 26, 2025 18:49
Copy link

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Balanced delimiter parser correctly fixes typed docfield splitting. Tests cover regression for docfields and autodoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect rendering for :param dict(str, str) in docs

2 participants