@@ -1353,7 +1353,7 @@ def no_period(self):
13531353 * hello
13541354 * world
13551355
1356- :obj:`an_attribute <an_attribute>` : float
1356+ :obj:`an_attribute <. an_attribute>` : float
13571357 Test attribute
13581358
13591359 **no_docstring** : str
@@ -1362,13 +1362,13 @@ def no_period(self):
13621362 **no_docstring2** : str
13631363 ..
13641364
1365- :obj:`multiline_sentence <multiline_sentence>`
1365+ :obj:`multiline_sentence <. multiline_sentence>`
13661366 This is a sentence.
13671367
1368- :obj:`midword_period <midword_period>`
1368+ :obj:`midword_period <. midword_period>`
13691369 The sentence for numpy.org.
13701370
1371- :obj:`no_period <no_period>`
1371+ :obj:`no_period <. no_period>`
13721372 This does not have a period
13731373
13741374 .. rubric:: Methods
@@ -1415,7 +1415,7 @@ def an_attribute(self):
14151415
14161416 attr_doc = """:Attributes:
14171417
1418- :obj:`an_attribute <an_attribute>`
1418+ :obj:`an_attribute <. an_attribute>`
14191419 Test attribute"""
14201420
14211421 assert attr_doc in str (SphinxClassDoc (Foo ))
@@ -1433,6 +1433,31 @@ def an_attribute(self):
14331433 assert "Another description" not in str (SphinxClassDoc (Foo , config = cfg ))
14341434
14351435
1436+ def test_attribute_link_is_class_scoped ():
1437+ class Foo :
1438+ """
1439+ Class docstring.
1440+
1441+ Attributes
1442+ ----------
1443+ identity
1444+ Another description that is not used.
1445+
1446+ """
1447+
1448+ @property
1449+ def identity (self ):
1450+ """Test attribute"""
1451+ return
1452+
1453+ attr_doc = """:Attributes:
1454+
1455+ :obj:`identity <.identity>`
1456+ Test attribute"""
1457+
1458+ assert attr_doc in str (SphinxClassDoc (Foo ))
1459+
1460+
14361461def test_templated_sections ():
14371462 doc = SphinxClassDoc (
14381463 None ,
0 commit comments