Repository: numpy/numpydoc (language: python)

Issue:
BUG: Numpydoc doesn't render attributes decorated with `cached_property` in the Attributes section
Numpydoc doesn't render attributes decorated with `cached_property` in the `Attribute` section. I think it is due to this line:

https://github.com/numpy/numpydoc/blob/b138ea7758532a8b6950c4404570ab367c3919f4/numpydoc/docscrape.py#L709

which can be changed to:

```
from functools import cached_property

...


                    func is None
                    or isinstance(func, property)
                    or isinstance(func, cached_property)
                    or inspect.isdatadescriptor(func)
```

to fix the issue.

xref scipy/scipy#16002


Discussion / hints:
Seems reasonable to me, could you make a pr @tirthasheshpatel ?

Fix patch:
diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py
index 9496f9de..e5c07f59 100644
--- a/numpydoc/docscrape.py
+++ b/numpydoc/docscrape.py
@@ -12,6 +12,13 @@
 import sys
 
 
+# TODO: Remove try-except when support for Python 3.7 is dropped
+try:
+    from functools import cached_property
+except ImportError:  # cached_property added in Python 3.8
+    cached_property = property
+
+
 def strip_blank_lines(l):
     "Remove leading and trailing blank lines from a list of lines"
     while l and not l[0].strip():
@@ -706,7 +713,7 @@ def properties(self):
                 not name.startswith("_")
                 and (
                     func is None
-                    or isinstance(func, property)
+                    or isinstance(func, (property, cached_property))
                     or inspect.isdatadescriptor(func)
                 )
                 and self._is_show_member(name)


Test patch:
diff --git a/numpydoc/tests/test_docscrape.py b/numpydoc/tests/test_docscrape.py
index 049d2a28..227f8724 100644
--- a/numpydoc/tests/test_docscrape.py
+++ b/numpydoc/tests/test_docscrape.py
@@ -1,6 +1,7 @@
 from collections import namedtuple
 from copy import deepcopy
 import re
+import sys
 import textwrap
 import warnings
 
@@ -1624,6 +1625,26 @@ def __call__(self):
         nds._error_location(msg=msg)
 
 
+@pytest.mark.skipif(
+    sys.version_info < (3, 8), reason="cached_property was added in 3.8"
+)
+def test_class_docstring_cached_property():
+    """Ensure that properties marked with the `cached_property` decorator
+    are listed in the Methods section. See gh-432."""
+    from functools import cached_property
+
+    class Foo:
+        _x = [1, 2, 3]
+
+        @cached_property
+        def val(self):
+            return self._x
+
+    class_docstring = get_doc_object(Foo)
+    assert len(class_docstring["Attributes"]) == 1
+    assert class_docstring["Attributes"][0].name == "val"
+
+
 if __name__ == "__main__":
     import pytest