def check_path()

in tools/check_documentation.py [0:0]


def check_path(pathname):
  path = BASEDIR / pathname
  subpaths = sorted(list(path.iterdir()))
  for subpath in subpaths:
    errors = []
    if not subpath.is_dir():
      continue
    if subpath.stem.startswith('_'):
      continue

    doc = subpath / 'README.md'
    if not doc.exists():
      errors.append(f'{doc} does not exist')

    variables = tfdoc.get_variables(subpath)
    variable_names = [v.name for v in variables]
    for variable in variables:
      if not variable.description:
        errors.append(f'variable {variable.name} has no description')
    if sorted(variable_names) != variable_names:
      message = f'variable order should be: {sorted(variable_names)}'
      errors.append(message)

    outputs = tfdoc.get_outputs(subpath)
    output_names = [v.name for v in outputs]
    for output in outputs:
      if not output.description:
        errors.append(f'output {output.name} has no description')
    if sorted(output_names) != output_names:
      message = f'output order should be: {sorted(output_names)}'
      errors.append(message)

    state = tfdoc.check_state(subpath)
    if state is False:
      errors.append("documentation is out of date")
    elif state:
      pass
    else:
      yield DocState.UNKNOWN, subpath.stem, errors
      continue

    yield DocState.FAIL if errors else DocState.OK, subpath.stem, errors