diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-03-29 20:04:29 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-29 20:04:29 +0900 |
commit | 70c61e44c34b4dadf1a7552be7c5feabd74b98bc (patch) | |
tree | 75df1e16faa935738bc293085d52d748b24727fe /sphinx/domains/python.py | |
parent | 7887615374656da0556966b8cd37d2af8dac2654 (diff) | |
parent | fe9473f42e71db5fca3281ecd09f0a39f5683385 (diff) | |
download | sphinx-git-70c61e44c34b4dadf1a7552be7c5feabd74b98bc.tar.gz |
Merge pull request #7395 from tk0miya/7219_indexentries_for_pyfunc
Fix #7219: py:function directive generates incorrect index entry
Diffstat (limited to 'sphinx/domains/python.py')
-rw-r--r-- | sphinx/domains/python.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index fae1991c7..64a19fc48 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -551,12 +551,23 @@ class PyFunction(PyObject): def needs_arglist(self) -> bool: return True - def get_index_text(self, modname: str, name_cls: Tuple[str, str]) -> str: + def add_target_and_index(self, name_cls: Tuple[str, str], sig: str, + signode: desc_signature) -> None: + super().add_target_and_index(name_cls, sig, signode) + modname = self.options.get('module', self.env.ref_context.get('py:module')) + node_id = signode['ids'][0] + name, cls = name_cls if modname: - return _('%s() (in module %s)') % (name, modname) + text = _('%s() (in module %s)') % (name, modname) + self.indexnode['entries'].append(('single', text, node_id, '', None)) else: - return _('%s() (built-in function)') % name + text = '%s; %s()' % (pairindextypes['builtin'], name) + self.indexnode['entries'].append(('pair', text, node_id, '', None)) + + def get_index_text(self, modname: str, name_cls: Tuple[str, str]) -> str: + # add index in own add_target_and_index() instead. + return None class PyDecoratorFunction(PyFunction): @@ -915,8 +926,8 @@ class PyModule(SphinxDirective): # the platform and synopsis aren't printed; in fact, they are only # used in the modindex currently ret.append(target) - indextext = _('%s (module)') % modname - inode = addnodes.index(entries=[('single', indextext, node_id, '', None)]) + indextext = '%s; %s' % (pairindextypes['module'], modname) + inode = addnodes.index(entries=[('pair', indextext, node_id, '', None)]) ret.append(inode) return ret |