def should_skip_class_attr()

in tools/tensorflow_docs/api_generator/doc_controls.py [0:0]


def should_skip_class_attr(cls, name):
  """Returns true if docs should be skipped for this class attribute.

  Args:
    cls: The class the attribute belongs to.
    name: The name of the attribute.

  Returns:
    True if the attribute should be skipped.
  """
  # Get the object with standard lookup, from the nearest
  # defining parent.
  try:
    obj = getattr(cls, name)
  except AttributeError:
    # This can fail for a variety of reasons. Always skip if `getattr` fails.
    return True

  # Unwrap fget if the object is a property
  obj = _unwrap_func(obj)

  # Skip if the object is decorated with `do_not_generate_docs` or
  # `do_not_doc_inheritable`
  if should_skip(obj):
    return True

  classes = getattr(cls, "__mro__", [cls])

  # Find where all the decorators turn docs on and off.
  # All these lists contain `(level, skip)` pairs.
  for_subclass_levels = [
      # The [1:] is because `for_subclass_implementers` turns off docs
      # one level down (and you don't want to consider level -1).
      (i, True)
      for (i, mro_cls) in enumerate(classes[1:])
      if _cls_attr_has_tag(mro_cls, name, _FOR_SUBCLASS_IMPLEMENTERS)
  ]
  not_below_levels = [
      (i, True)
      for (i, mro_cls) in enumerate(classes)
      if _cls_attr_has_tag(mro_cls, name, _DO_NOT_DOC_INHERITABLE)
  ]
  doc_below_levels = [
      (i, False)
      for (i, mro_cls) in enumerate(classes)
      if _cls_attr_has_tag(mro_cls, name, _DOC_IN_CURRENT_AND_SUBCLASSES)
  ]

  all_levels = not_below_levels + for_subclass_levels + doc_below_levels
  if all_levels:
    # Find the lowest `(level, skip)` pair, and return `skip`
    return min(all_levels)[1]

  # No decorators --> don't skip
  return False