Source code for ayx_python_sdk.core.doc_utilities

# Copyright (C) 2022 Alteryx, Inc. All rights reserved.
#
# Licensed under the ALTERYX SDK AND API LICENSE AGREEMENT;
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    https://www.alteryx.com/alteryx-sdk-and-api-license-agreement
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Utility functions for documentation."""
import types
from typing import Type


[docs]def inherit_docs(cls: Type) -> Type: """ Inherit the documentation from parent classes if it doesn't exist on methods. Parameters ---------- cls The child class that inherits its parent's documentation. Returns ------- Type Child class with documentation. """ for name, func in vars(cls).items(): if isinstance(func, types.FunctionType) and not func.__doc__: for parent in cls.__bases__: parent_func = getattr(parent, name, None) if parent_func and getattr(parent_func, "__doc__", None): func.__doc__ = parent_func.__doc__ break return cls