mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-10-12 16:32:10 -05:00
js domain: Remove extra brackets from function arguments and errors (#13569)
This commit is contained in:
1 parent
4f23c99300
commit
4a3bd13b6a
4 files changed
+28
-6
No files matched your search
@@ -191,6 +191,8 @@ Bugs fixed
|
|||||||
Patch by Akihiro Takizawa.
|
Patch by Akihiro Takizawa.
|
||||||
* #13741: text builder: fix an infinite loop when processing CSV tables.
|
* #13741: text builder: fix an infinite loop when processing CSV tables.
|
||||||
Patch by Bénédikt Tran.
|
Patch by Bénédikt Tran.
|
||||||
|
* #13217: Remove extra parentheses from :rst:dir:`js:function` arguments and errors.
|
||||||
|
Patch by Shengyu Zhang.
|
||||||
|
|
||||||
|
|
||||||
Testing
|
Testing
|
||||||
|
|||||||
+3
-3
@@ -181,9 +181,9 @@ nitpick_ignore = {
|
|||||||
'template<typename TOuter> template<typename TInner> Wrapper::Outer<TOuter>::Inner',
|
'template<typename TOuter> template<typename TInner> Wrapper::Outer<TOuter>::Inner',
|
||||||
),
|
),
|
||||||
('cpp:identifier', 'MyContainer'),
|
('cpp:identifier', 'MyContainer'),
|
||||||
('js:func', 'SomeError'),
|
('js:class', 'SomeError'),
|
||||||
('js:func', 'number'),
|
('js:class', 'number'),
|
||||||
('js:func', 'string'),
|
('js:class', 'string'),
|
||||||
('py:attr', 'srcline'),
|
('py:attr', 'srcline'),
|
||||||
# sphinx.application.Sphinx.connect
|
# sphinx.application.Sphinx.connect
|
||||||
('py:class', '_AutodocProcessDocstringListener'),
|
('py:class', '_AutodocProcessDocstringListener'),
|
||||||
|
|||||||
@@ -273,13 +273,13 @@ class JSCallable(JSObject):
|
|||||||
'arguments',
|
'arguments',
|
||||||
label=_('Arguments'),
|
label=_('Arguments'),
|
||||||
names=('argument', 'arg', 'parameter', 'param'),
|
names=('argument', 'arg', 'parameter', 'param'),
|
||||||
typerolename='func',
|
typerolename='class',
|
||||||
typenames=('paramtype', 'type'),
|
typenames=('paramtype', 'type'),
|
||||||
),
|
),
|
||||||
GroupedField(
|
GroupedField(
|
||||||
'errors',
|
'errors',
|
||||||
label=_('Throws'),
|
label=_('Throws'),
|
||||||
rolename='func',
|
rolename='class',
|
||||||
names=('throws',),
|
names=('throws',),
|
||||||
can_collapse=True,
|
can_collapse=True,
|
||||||
),
|
),
|
||||||
@@ -434,7 +434,7 @@ class JavaScriptDomain(Domain):
|
|||||||
roles = {
|
roles = {
|
||||||
'func': JSXRefRole(fix_parens=True),
|
'func': JSXRefRole(fix_parens=True),
|
||||||
'meth': JSXRefRole(fix_parens=True),
|
'meth': JSXRefRole(fix_parens=True),
|
||||||
'class': JSXRefRole(fix_parens=True),
|
'class': JSXRefRole(),
|
||||||
'data': JSXRefRole(),
|
'data': JSXRefRole(),
|
||||||
'attr': JSXRefRole(),
|
'attr': JSXRefRole(),
|
||||||
'mod': JSXRefRole(),
|
'mod': JSXRefRole(),
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ from sphinx.testing import restructuredtext
|
|||||||
from sphinx.testing.util import assert_node
|
from sphinx.testing.util import assert_node
|
||||||
from sphinx.writers.text import STDINDENT
|
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')
|
@pytest.mark.sphinx('dummy', testroot='domain-js')
|
||||||
def test_domain_js_xrefs(app):
|
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,
|
expected_f,
|
||||||
)
|
)
|
||||||
assert expected_parameter_list_foo in content
|
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