in update-imported-docs/update-imported-docs.py [0:0]
def process_kubectl_links(content):
"""Update markdown links found in the SeeAlso section of kubectl page.
Example:[kubectl annotate](/docs/reference/generated/kubectl/kubectl-commands#annotate)
"""
def analyze(match_obj):
ankor = match_obj.group('ankor')
target = match_obj.group('target')
if target.endswith(".md") and target.startswith("kubectl"):
ankor_list = ankor.split("kubectl ")
target = "/docs/reference/generated/kubectl/kubectl-commands" + "#" + \
ankor_list[1]
return "[%s](%s)" % (ankor, target)
# Links are in the form '[text](url)'
link_regex = re.compile(r"\[(?P<ankor>.*)\]\((?P<target>.*?)\)")
content = re.sub(link_regex, analyze, content)
return content