Files
my-rook-config/.docs/macros/includes/main.py
T
Michael Adam be03f073dd build: silence docs-build
make docs-build in the CI issued a lot of messages
about env.raw_markdown being removed.

While looking like error messages, these did not result in
build failures.

This change silences make docs-build by
using env.markdown instead

Signed-off-by: Michael Adam <obnox@samba.org>
2026-02-26 12:00:38 +01:00

34 lines
689 B
Python

#!/usr/bin/env python3
from pygit2 import Repository
import re
"""
GitHub branch/tag URL replacer
"""
regex = r"(github\.com/.+/rook/.+)/master/"
subst = "\\1/%s/"
def define_env(env):
target = None
repo = Repository(".")
if repo is not None:
target = repo.head.shorthand
env.variables["current_branch"] = target
def on_post_page_macros(env):
"""
Replace the branch/tag in the rook GitHub file and directory links pointing to `master`
with the correct one that is currently active.
"""
target = env.variables["current_branch"]
if target == "master":
return
env.markdown = re.sub(regex, subst % target, env.markdown, 0)