Skip to content

Commit 8a50be5

Browse files
authored
Merge pull request #88 from jabraham17/fix-return-intent
Add fix for return intent formatting in chromium browsers
2 parents f652bb9 + 515d516 commit 8a50be5

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

Diff for: sphinxcontrib/chapeldomain/__init__.py

+29-14
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,32 @@ def _pseudo_parse_arglist(signode, arglist):
205205
else:
206206
signode += paramlist
207207

208+
@staticmethod
209+
def _handle_signature_suffix(signode, retann, anno, where_clause):
210+
"""
211+
handle the signature suffix items like return intent, return type,
212+
where clause, annotation, etc.
213+
"""
214+
if retann:
215+
if ':' in retann:
216+
retintent, _, rettype = retann.partition(':')
217+
rettype = rettype.strip()
218+
else:
219+
retintent, rettype = retann, None
220+
retintent = retintent.strip()
221+
if retintent:
222+
signode += addnodes.desc_sig_space(' ', ' ')
223+
signode += addnodes.desc_annotation(' ' + retintent,
224+
' ' + retintent)
225+
if rettype:
226+
signode += addnodes.desc_annotation(' : ' + rettype,
227+
' : ' + rettype)
228+
if anno:
229+
signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
230+
if where_clause:
231+
signode += addnodes.desc_annotation(' ' + where_clause,
232+
' ' + where_clause)
233+
208234
def _get_attr_like_prefix(self, sig):
209235
"""Return prefix text for attribute or data directive."""
210236
sig_match = chpl_attr_sig_pattern.match(sig)
@@ -355,23 +381,12 @@ def handle_signature(self, sig, signode):
355381
if self.needs_arglist() and arglist is not None:
356382
# for callables, add an empty parameter list
357383
signode += addnodes.desc_parameterlist()
358-
if retann:
359-
signode += addnodes.desc_type(retann, retann)
360-
if anno:
361-
signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
362-
if where_clause:
363-
signode += addnodes.desc_annotation(' ' + where_clause,
364-
' ' + where_clause)
384+
self._handle_signature_suffix(signode, retann, anno, where_clause)
365385
return fullname, name_prefix
366386

367387
self._pseudo_parse_arglist(signode, arglist)
368-
if retann:
369-
signode += addnodes.desc_type(retann, retann)
370-
if anno:
371-
signode += addnodes.desc_annotation(' ' + anno, ' ' + anno)
372-
if where_clause:
373-
signode += addnodes.desc_annotation(' ' + where_clause,
374-
' ' + where_clause)
388+
self._handle_signature_suffix(signode, retann, anno, where_clause)
389+
375390
return fullname, name_prefix
376391

377392
def get_index_text(self, modname, name):

0 commit comments

Comments
 (0)