in tools/validator.py [0:0]
def assert_correct_content(self, documentation_dir: str,
lines: Sequence[str]) -> None:
"""Checks that referenced model pages have existing documentation files.
A collection should contain at least one link of the form
https://tfhub.dev/PUBLISHER/((tfjs|lite|coral)-model/)NAME(/VERSION).
For each URL, the corresponding model should have a documentation file.
Args:
documentation_dir: Absolute path to the `assets/docs` directory.
lines: Sequence of strings representing the file content.
Raises:
MarkdownDocumentationError:
- if no model URL is contained in the collection.
- if a model URL is contained whose model does not have a documentation.
"""
super().assert_correct_content(documentation_dir, lines)
found_one_model = False
for line in lines:
for policy in _get_policies_for_line_with_model_urls(line):
found_one_model = True
maybe_wildcard_paths = policy.get_allowed_file_paths(documentation_dir)
absolute_paths = map(tf.io.gfile.glob, maybe_wildcard_paths)
for absolute_path in itertools.chain.from_iterable(absolute_paths):
if tf.io.gfile.exists(absolute_path):
break
else:
raise MarkdownDocumentationError("No documentation file found in "
f"{maybe_wildcard_paths}.")
if not found_one_model:
raise MarkdownDocumentationError(
"A collection needs to contain at least one model URL.")