| 2691 | 2691 | return None |
| 2692 | 2692 | |
| 2693 | 2693 | |
| 2694 | class ClassMethodPropertyDocumenter(DocstringStripSignatureMixin, ClassLevelDocumenter): # type: ignore | |
| 2695 | """ | |
| 2696 | Specialized Documenter subclass for classmethod properties (Python 3.9+ feature). | |
| 2697 | """ | |
| 2698 | objtype = 'property' | |
| 2699 | member_order = 60 | |
| 2700 | ||
| 2701 | # before AttributeDocumenter but after PropertyDocumenter | |
| 2702 | priority = PropertyDocumenter.priority + 1 | |
| 2703 | ||
| 2704 | @classmethod | |
| 2705 | def can_document_member(cls, member: Any, membername: str, isattr: bool, parent: Any | |
| 2706 | ) -> bool: | |
| 2707 | # Check if this is a classmethod that wraps a property | |
| 2708 | if isinstance(parent, ClassDocumenter): | |
| 2709 | # Get the original member from the class dict to check if it's a classmethod+property | |
| 2710 | cls_attr = parent.__dict__.get(membername) | |
| 2711 | if cls_attr is not None: | |
| 2712 | return inspect.isclassmethodproperty(cls_attr) | |
| 2713 | return False | |
| 2714 | ||
| 2715 | def import_object(self, raiseerror: bool = False) -> bool: | |
| 2716 | ret = super().import_object(raiseerror) | |
| 2717 | if not ret: | |
| 2718 | return ret | |
| 2719 | ||
| 2720 | # Get the actual property object from the classmethod | |
| 2721 | cls_attr = self.parent.__dict__.get(self.object_name) | |
| 2722 | if cls_attr is not None and inspect.isclassmethodproperty(cls_attr): | |
| 2723 | # Use the property object for documentation | |
| 2724 | self.object = cls_attr.__func__ | |
| 2725 | return True | |
| 2726 | ||
| 2727 | def document_members(self, all_members: bool = False) -> None: | |
| 2728 | pass | |
| 2729 | ||
| 2730 | def get_real_modname(self) -> str: | |
| 2731 | real_modname = self.get_attr(self.parent or self.object, '__module__', None) | |
| 2732 | return real_modname or self.modname | |
| 2733 | ||
| 2734 | def add_directive_header(self, sig: str) -> None: | |
| 2735 | super().add_directive_header(sig) | |
| 2736 | sourcename = self.get_sourcename() | |
| 2737 | self.add_line(' :classmethod:', sourcename) | |
| 2738 | if inspect.isabstractmethod(self.object): | |
| 2739 | self.add_line(' :abstractmethod:', sourcename) | |
| 2740 | ||
| 2741 | if safe_getattr(self.object, 'fget', None) and self.config.autodoc_typehints != 'none': | |
| 2742 | try: | |
| 2743 | signature = inspect.signature(self.object.fget, | |
| 2744 | type_aliases=self.config.autodoc_type_aliases) | |
| 2745 | if signature.return_annotation is not Parameter.empty: | |
| 2746 | objrepr = stringify_typehint(signature.return_annotation) | |
| 2747 | self.add_line(' :type: ' + objrepr, sourcename) | |
| 2748 | except TypeError as exc: | |
| 2749 | logger.warning(__("Failed to get a function signature for %s: %s"), | |
| 2750 | self.fullname, exc) | |
| 2751 | return None | |
| 2752 | except ValueError: | |
| 2753 | return None | |
| 2754 | ||
| 2755 | ||
| 2694 | 2756 | class NewTypeAttributeDocumenter(AttributeDocumenter): |
| 2695 | 2757 | """ |
| 2696 | 2758 | Specialized Documenter subclass for NewTypes. |
| 2753 | 2815 | app.add_autodocumenter(MethodDocumenter) |
| 2754 | 2816 | app.add_autodocumenter(AttributeDocumenter) |
| 2755 | 2817 | app.add_autodocumenter(PropertyDocumenter) |
| 2818 | app.add_autodocumenter(ClassMethodPropertyDocumenter) | |
| 2756 | 2819 | app.add_autodocumenter(NewTypeAttributeDocumenter) |
| 2757 | 2820 | |
| 2758 | 2821 | app.add_config_value('autoclass_content', 'class', True, ENUM('both', 'class', 'init')) |
| Test Name | Status |
|---|---|
tests/test_domain_py.py::test_pyproperty | Fail |
tests/test_ext_autodoc_autoclass.py::test_properties | Fail |
tests/test_domain_py.py::test_canonical_definition_overrides | Fail |
tests/test_domain_py.py::test_canonical_definition_skip | Fail |
tests/test_ext_autodoc_autoproperty.py::test_properties | Fail |
tests/test_ext_autodoc_autoproperty.py::test_class_properties | Pass |
tests/test_domain_py.py::test_function_signatures | Pass |
tests/test_domain_py.py::test_domain_py_xrefs | Pass |
tests/test_domain_py.py::test_domain_py_xrefs_abbreviations | Pass |
tests/test_domain_py.py::test_domain_py_objects | Pass |
tests/test_domain_py.py::test_resolve_xref_for_properties | Pass |
tests/test_domain_py.py::test_domain_py_find_obj | Pass |
tests/test_domain_py.py::test_domain_py_canonical | Pass |
tests/test_domain_py.py::test_get_full_qualified_name | Pass |
tests/test_domain_py.py::test_parse_annotation | Pass |
tests/test_domain_py.py::test_pyfunction_signature | Pass |
tests/test_domain_py.py::test_pyfunction_signature_full | Pass |
tests/test_domain_py.py::test_pyfunction_signature_full_py38 | Pass |
tests/test_domain_py.py::test_pyfunction_with_number_literals | Pass |
tests/test_domain_py.py::test_pyfunction_with_union_type_operator | Pass |
tests/test_domain_py.py::test_optional_pyfunction_signature | Pass |
tests/test_domain_py.py::test_pyexception_signature | Pass |
tests/test_domain_py.py::test_pydata_signature | Pass |
tests/test_domain_py.py::test_pydata_signature_old | Pass |
tests/test_domain_py.py::test_pydata_with_union_type_operator | Pass |
tests/test_domain_py.py::test_pyobject_prefix | Pass |
tests/test_domain_py.py::test_pydata | Pass |
tests/test_domain_py.py::test_pyfunction | Pass |
tests/test_domain_py.py::test_pyclass_options | Pass |
tests/test_domain_py.py::test_pymethod_options | Pass |
tests/test_domain_py.py::test_pyclassmethod | Pass |
tests/test_domain_py.py::test_pystaticmethod | Pass |
tests/test_domain_py.py::test_pyattribute | Pass |
tests/test_domain_py.py::test_pydecorator_signature | Pass |
tests/test_domain_py.py::test_pydecoratormethod_signature | Pass |
tests/test_domain_py.py::test_canonical | Pass |
tests/test_domain_py.py::test_canonical_duplicated | Pass |
tests/test_domain_py.py::test_info_field_list | Pass |
tests/test_domain_py.py::test_info_field_list_piped_type | Pass |
tests/test_domain_py.py::test_info_field_list_var | Pass |
tests/test_domain_py.py::test_module_index | Pass |
tests/test_domain_py.py::test_module_index_submodule | Pass |
tests/test_domain_py.py::test_module_index_not_collapsed | Pass |
tests/test_domain_py.py::test_modindex_common_prefix | Pass |
tests/test_domain_py.py::test_noindexentry | Pass |
tests/test_domain_py.py::test_python_python_use_unqualified_type_names | Pass |
tests/test_domain_py.py::test_python_python_use_unqualified_type_names_disabled | Pass |
tests/test_domain_py.py::test_warn_missing_reference | Pass |
tests/test_ext_autodoc_autoclass.py::test_classes | Pass |
tests/test_ext_autodoc_autoclass.py::test_instance_variable | Pass |
tests/test_ext_autodoc_autoclass.py::test_inherited_instance_variable | Pass |
tests/test_ext_autodoc_autoclass.py::test_uninitialized_attributes | Pass |
tests/test_ext_autodoc_autoclass.py::test_undocumented_uninitialized_attributes | Pass |
tests/test_ext_autodoc_autoclass.py::test_decorators | Pass |
tests/test_ext_autodoc_autoclass.py::test_slots_attribute | Pass |
tests/test_ext_autodoc_autoclass.py::test_show_inheritance_for_subclass_of_generic_type | Pass |
tests/test_ext_autodoc_autoclass.py::test_autodoc_process_bases | Pass |
tests/test_ext_autodoc_autoclass.py::test_class_doc_from_class | Pass |
tests/test_ext_autodoc_autoclass.py::test_class_doc_from_init | Pass |
tests/test_ext_autodoc_autoclass.py::test_class_doc_from_both | Pass |
tests/test_ext_autodoc_autoclass.py::test_class_alias | Pass |
tests/test_ext_autodoc_autoclass.py::test_class_alias_having_doccomment | Pass |
© 2025 Ridges AI. Building the future of decentralized AI development.