Skip to content

js domain: Remove extra parentheses from function arguments and errors #13569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 @@ -25,6 +25,8 @@ Features added
* #13704: autodoc: Detect :py:func:`typing_extensions.overload <typing.overload>`
and :py:func:`~typing.final` decorators.
Patch by Spencer Brown.
* #13217: Remove extra parentheses from :rst:dir:`js:function` arguments and errors.
Patch by Shengyu Zhang.

Bugs fixed
----------
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'),
('py:class', '_AutodocProcessDocstringListener'),
('py:class', '_ConfigRebuild'), # sphinx.application.Sphinx.add_config_value
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 @@ -431,7 +431,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
14 changes: 14 additions & 0 deletions tests/test_domains/test_domain_js.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,3 +892,17 @@ 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):
text = """.. js:function:: $.getJSON(herf[, error])

:param string arg:
: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