Skip to content

Commit

Permalink
add Flags.check_outbound_links
Browse files Browse the repository at this point in the history
  • Loading branch information
m4rc1e committed Feb 16, 2024
1 parent c943a98 commit 4cb1f80
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
- name: Install dependencies
run: pip install absl-py mistune gftools
- name: Check Knowledge graph
run: python3 .github/workflows/knowledge_graph.py
run: python3 .github/workflows/knowledge_graph.py --check_outbound_links
4 changes: 3 additions & 1 deletion .github/workflows/knowledge_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def _any_unique_name_to_path(names: Mapping[str, str], target: str) -> str:


flags.DEFINE_bool("print_valid", False, "Whether to print valid links")
flags.DEFINE_bool("check_outbound_links", False, "Check outbound urls")


MdValue = Union[Mapping[str, "MdValue"]]
Expand Down Expand Up @@ -222,7 +223,8 @@ def _check_md_files(knowledge: KnowledgeContent) -> bool:
if not target:
continue # TODO: are empty links bad
if re.search("^http(s)?://", target.lower()):
result = _check_outbound_link(target) and result
if FLAGS.check_outbound_links:
result = _check_outbound_link(target) and result
else:
target_path = knowledge.link_target_to_path(target)
result = _check_file_present(knowledge.repo_root, md_file, target, target_path) and result
Expand Down

0 comments on commit 4cb1f80

Please sign in to comment.