diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index 52e6e6fba..d2b70b82f 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -149,11 +149,12 @@ class ObjectDescription(Directive): signode.clear() signode += addnodes.desc_name(sig, sig) continue # we don't want an index entry here - self.names.append(name) - if not noindex and name not in self.names: - # only add target and index entry if this is the first - # description of the object with this name in this desc block - self.add_target_and_index(name, sig, signode) + if name not in self.names: + self.names.append(name) + if not noindex: + # only add target and index entry if this is the first + # description of the object with this name in this desc block + self.add_target_and_index(name, sig, signode) contentnode = addnodes.desc_content() node.append(contentnode)