diff options
author | TLouf <31036680+TLouf@users.noreply.github.com> | 2023-05-11 15:28:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-11 14:28:57 +0100 |
commit | 86b07d4a97a225e79150d14e25a768ebc4c087cc (patch) | |
tree | 2c0c8691fff120604b9071cb24019ed1d49986a6 /sphinx/domains/javascript.py | |
parent | c73628dfcac844f89198ccd805e8e35609b37636 (diff) | |
download | sphinx-git-86b07d4a97a225e79150d14e25a768ebc4c087cc.tar.gz |
Allow multi-line object description signatures (#11011)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
Co-authored-by: Jean-François B <2589111+jfbu@users.noreply.github.com>
Co-authored-by: TLouf <loufthomas@gmail.com>
Diffstat (limited to 'sphinx/domains/javascript.py')
-rw-r--r-- | sphinx/domains/javascript.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/sphinx/domains/javascript.py b/sphinx/domains/javascript.py index 093e291ca..c6baab8a9 100644 --- a/sphinx/domains/javascript.py +++ b/sphinx/domains/javascript.py @@ -43,6 +43,7 @@ class JSObject(ObjectDescription[Tuple[str, str]]): 'noindex': directives.flag, 'noindexentry': directives.flag, 'nocontentsentry': directives.flag, + 'single-line-parameter-list': directives.flag, } def get_display_prefix(self) -> list[Node]: @@ -88,6 +89,14 @@ class JSObject(ObjectDescription[Tuple[str, str]]): signode['object'] = prefix signode['fullname'] = fullname + max_len = (self.env.config.javascript_maximum_signature_line_length + or self.env.config.maximum_signature_line_length + or 0) + multi_line_parameter_list = ( + 'single-line-parameter-list' not in self.options + and (len(sig) > max_len > 0) + ) + display_prefix = self.get_display_prefix() if display_prefix: signode += addnodes.desc_annotation('', '', *display_prefix) @@ -108,7 +117,7 @@ class JSObject(ObjectDescription[Tuple[str, str]]): if not arglist: signode += addnodes.desc_parameterlist() else: - _pseudo_parse_arglist(signode, arglist) + _pseudo_parse_arglist(signode, arglist, multi_line_parameter_list) return fullname, prefix def _object_hierarchy_parts(self, sig_node: desc_signature) -> tuple[str, ...]: @@ -473,10 +482,12 @@ class JavaScriptDomain(Domain): def setup(app: Sphinx) -> dict[str, Any]: app.add_domain(JavaScriptDomain) - + app.add_config_value( + 'javascript_maximum_signature_line_length', None, 'env', types={int, None}, + ) return { 'version': 'builtin', - 'env_version': 2, + 'env_version': 3, 'parallel_read_safe': True, 'parallel_write_safe': True, } |