Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@
'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'),
Expand Down
6 changes: 3 additions & 3 deletions sphinx/domains/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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(),
Expand Down
20 changes: 20 additions & 0 deletions tests/test_domains/test_domain_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
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):
Expand Down Expand Up @@ -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'])
Loading