@@ -0,0 +1,1208 @@
+from pathlib import Path%0Afrom typing import List, Text%0Aimport re%0A%0Aimport pytest%0A%0A%0ADOCS_BASE_DIR = Path(%22docs/%22)%0AMDX_DOCS_FILES = list((DOCS_BASE_DIR / %22docs%22).glob(%22**/*.mdx%22))%0A# we're matching anchors with href containing strings, but not starting%0A# with %22http%22. This also exclude local href already configured using %60useBaseUrl()%60%0AANCHOR_RE = re.compile(%0A    r%22%3Ca%5B%5E%3E%5D*href=%5C%22(?P%3Chref%3E(?!http).+?)%5C%22%5B%5E%3E%5D*%3E%22,%0A    re.DOTALL,%0A)%0A%0A%0A@pytest.mark.parametrize(%22mdx_file_path%22, MDX_DOCS_FILES)%0Adef test_docs_anchors_base_url(mdx_file_path: Path):%0A    with mdx_file_path.open(%22r%22) as handle:%0A        mdx_content = handle.read()%0A%0A    matches = ANCHOR_RE.finditer(mdx_content)%0A    lines_with_errors: List%5BText%5D = %5B%5D%0A%0A    for match in matches:%0A        href = match.group(%22href%22)%0A        start_index = match.span()%5B0%5D%0A        line_number = mdx_content.count(%22%5Cn%22, 0, start_index) + 1%0A        lines_with_errors.append(f%22%7Bline_number%7D with href=%7Bhref%7D%22)%0A%0A    if lines_with_errors:%0A        plural = %22s%22 if len(lines_with_errors) %3E 1 else %22%22%0A        raise AssertionError(%0A            f%22(%7Bmdx_file_path%7D): Invalid anchor%7Bplural%7D not using useBaseUrl() %22%0A            f%22at line%7Bplural%7D %7B', '.join(lines_with_errors)%7D%22%0A        )%0A

add test case for missing useBaseUrl()