fix(docs): convert backtick relative paths to clickable GitHub links

Extend rewrite_relative_links() to also handle `../../path/to/file`
backtick code references, converting them to clickable links showing
parent/filename for context (e.g., product-analytics/SKILL.md).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Reza Rezvani
2026-03-11 15:27:32 +01:00
parent d10d324d50
commit aeab2174d2
12 changed files with 173 additions and 156 deletions

View File

@@ -173,7 +173,24 @@ def rewrite_relative_links(content, source_rel_path):
return f"[{text}]({sibling})"
return f"[{text}]({GITHUB_BASE}/{resolved})"
return re.sub(r"\[([^\]]+)\]\((\.\.[^\)]+)\)", resolve_link, content)
content = re.sub(r"\[([^\]]+)\]\((\.\.[^\)]+)\)", resolve_link, content)
# Also rewrite backtick code references like `../../product-team/foo/SKILL.md`
# Convert to clickable GitHub links
def resolve_backtick(match):
rel_target = match.group(1)
if not rel_target.startswith("../"):
return match.group(0)
resolved = os.path.normpath(os.path.join(source_dir, rel_target))
# Make the path a clickable link to the GitHub source
# Show parent/filename for context (e.g., product-analytics/SKILL.md)
parts = resolved.split("/")
display = "/".join(parts[-2:]) if len(parts) >= 2 else resolved
return f"[`{display}`]({GITHUB_BASE}/{resolved})"
content = re.sub(r"`(\.\./[^`]+)`", resolve_backtick, content)
return content
def generate_skill_page(skill, domain_key):