Exemplo n.º 1
0
  def deprecated(self):
    """Checks if the module is deprecated or not.

    Special case is `tf.contrib`. It doesn't have the _tf_decorator attribute
    but that module should be marked as deprecated.

    Each deprecated function has a `_tf_decorator.decorator_name` attribute.
    Check the docstring of that function to confirm if the function was
    indeed deprecated. If a different deprecation setting was used on the
    function, then "THIS FUNCTION IS DEPRECATED" substring won't be inserted
    into the docstring of that function by the decorator.

    Returns:
      True if depreacted else False.
    """
    if doc_controls.is_deprecated(self.py_object):
      return True

    if 'tf.contrib' in self.full_name:
      return True

    try:
      # Instead of only checking the docstring, checking for the decorator
      # provides an additional level of certainty about the correctness of the
      # the application of `status: deprecated`.
      decorator_list = parser.extract_decorators(self.py_object)
      if any('deprecat' in dec for dec in decorator_list):
        return self._check_docstring()
    except AttributeError:
      pass

    return False
Exemplo n.º 2
0
    def _is_deprecated(self, api_node: doc_generator_visitor.ApiTreeNode):
        """Checks if an object is deprecated or not.

    Each deprecated function has a `_tf_decorator.decorator_name` attribute.
    Check the docstring of that function to confirm if the function was
    indeed deprecated. If a different deprecation setting was used on the
    function, then "THIS FUNCTION IS DEPRECATED" substring won't be inserted
    into the docstring of that function by the decorator.

    Args:
      api_node: The node to evaluate.

    Returns:
      True if depreacted else False.
    """
        if doc_controls.is_deprecated(api_node.py_object):
            return True

        decorator_list = signature.extract_decorators(api_node.py_object)
        if any('deprecat' in dec for dec in decorator_list):
            docstring = getattr(api_node.py_object, '__doc__') or ''
            return 'THIS FUNCTION IS DEPRECATED' in docstring

        return False