mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-08-26 05:07:35 -05:00
js domain: Remove extra brackets from function arguments and errors (#13569)
This commit is contained in:
@@ -191,6 +191,8 @@ Bugs fixed
|
||||
Patch by Akihiro Takizawa.
|
||||
* #13741: text builder: fix an infinite loop when processing CSV tables.
|
||||
Patch by Bénédikt Tran.
|
||||
* #13217: Remove extra parentheses from :rst:dir:`js:function` arguments and errors.
|
||||
Patch by Shengyu Zhang.
|
||||
|
||||
|
||||
Testing
|
||||
|
||||
+3
-3
@@ -181,9 +181,9 @@ nitpick_ignore = {
|
||||
'template<typename TOuter> template<typename TInner> Wrapper::Outer<TOuter>::Inner',
|
||||
),
|
||||
('cpp:identifier', 'MyContainer'),
|
||||
('js:func', 'SomeError'),
|
||||
('js:func', 'number'),
|
||||
('js:func', 'string'),
|
||||
('js:class', 'SomeError'),
|
||||
('js:class', 'number'),
|
||||
('js:class', 'string'),
|
||||
('py:attr', 'srcline'),
|
||||
# sphinx.application.Sphinx.connect
|
||||
('py:class', '_AutodocProcessDocstringListener'),
|
||||
|
||||
@@ -273,13 +273,13 @@ class JSCallable(JSObject):
|
||||
'arguments',
|
||||
label=_('Arguments'),
|
||||
names=('argument', 'arg', 'parameter', 'param'),
|
||||
typerolename='func',
|
||||
typerolename='class',
|
||||
typenames=('paramtype', 'type'),
|
||||
),
|
||||
GroupedField(
|
||||
'errors',
|
||||
label=_('Throws'),
|
||||
rolename='func',
|
||||
rolename='class',
|
||||
names=('throws',),
|
||||
can_collapse=True,
|
||||
),
|
||||
@@ -434,7 +434,7 @@ class JavaScriptDomain(Domain):
|
||||
roles = {
|
||||
'func': JSXRefRole(fix_parens=True),
|
||||
'meth': JSXRefRole(fix_parens=True),
|
||||
'class': JSXRefRole(fix_parens=True),
|
||||
'class': JSXRefRole(),
|
||||
'data': JSXRefRole(),
|
||||
'attr': JSXRefRole(),
|
||||
'mod': JSXRefRole(),
|
||||
|
||||
@@ -26,6 +26,10 @@ from sphinx.testing import restructuredtext
|
||||
from sphinx.testing.util import assert_node
|
||||
from sphinx.writers.text import STDINDENT
|
||||
|
||||
TYPE_CHECKING = False
|
||||
if TYPE_CHECKING:
|
||||
from sphinx.testing.util import SphinxTestApp
|
||||
|
||||
|
||||
@pytest.mark.sphinx('dummy', testroot='domain-js')
|
||||
def test_domain_js_xrefs(app):
|
||||
@@ -892,3 +896,19 @@ def test_domain_js_javascript_trailing_comma_in_multi_line_signatures_in_text(ap
|
||||
expected_f,
|
||||
)
|
||||
assert expected_parameter_list_foo in content
|
||||
|
||||
|
||||
# See: https://github.com/sphinx-doc/sphinx/issues/13217
|
||||
@pytest.mark.sphinx('html', testroot='_blank')
|
||||
def test_js_function_parentheses_in_arguments_and_errors(app: SphinxTestApp) -> None:
|
||||
text = """\
|
||||
.. js:function:: $.getJSON(href)
|
||||
|
||||
:param string href:
|
||||
:throws err:
|
||||
"""
|
||||
doctree = restructuredtext.parse(app, text)
|
||||
refnodes = list(doctree.findall(addnodes.pending_xref))
|
||||
assert len(refnodes) == 2
|
||||
assert_node(refnodes[0], [addnodes.pending_xref, nodes.literal, 'string'])
|
||||
assert_node(refnodes[1], [addnodes.pending_xref, nodes.literal, 'err'])
|
||||
|
||||
Reference in New Issue
Block a user