Skip to content

Commit ad4492f

Browse files
authored
ci: validate rtd links (#338)
1 parent 10c2ab9 commit ad4492f

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

packages/nichepca/meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ name: nichepca
22
description: |
33
A Python package for PCA-based spatial domain identification in single-cell spatial transcriptomics data.
44
project_home: https://github.com/imsb-uke/nichepca
5-
documentation_home: https://nichepca.readthedocs.io/en/latest/
6-
tutorials_home: https://nichepca.readthedocs.io/en/latest/notebooks/example.html
5+
documentation_home: https://nichepca.readthedocs.io/
6+
tutorials_home: https://nichepca.readthedocs.io/page/notebooks/example.html
77
install:
88
pypi: nichepca
99
tags:

scripts/src/ecosystem_scripts/validate_registry.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import argparse
77
import json
88
import os
9+
import re
910
import shutil
1011
import sys
1112
from collections import defaultdict
@@ -48,6 +49,11 @@ def append(self, obj: Exception | None) -> None:
4849
return super().append(obj)
4950

5051

52+
RE_RTD = re.compile(
53+
r"https?://(?P<domain>.*\.(?:readthedocs\.io|rtfd\.io|readthedocs-hosted\.com))/(?P<version>en/[^/]+)(?P<path>.*)"
54+
)
55+
56+
5157
class LinkChecker:
5258
"""Track known links and validate URLs."""
5359

@@ -65,6 +71,12 @@ def check_and_register(self, url: str, context: str) -> None | ValidationError:
6571
context
6672
Context information for error messages (e.g., file being validated)
6773
"""
74+
if m := re.fullmatch(RE_RTD, url):
75+
new_url = f"https://{m['domain']}/" + (f"page{m['path']}" if m["path"].strip("/") else "")
76+
msg = (
77+
f"Please use the default version in ReadTheDocs URLs instead of {m['version']!r}:\n{url}\n->\n{new_url}"
78+
)
79+
return ValidationError(msg)
6880
if url in self.known_links:
6981
msg = f"{context}: Duplicate link: {url}"
7082
return ValidationError(msg)

0 commit comments

Comments
 (0)