Skip to content

Commit 0f0bffa

Browse files
Added automatic Jira ticket linking for ENT and CFE references
Signed-off-by: Ihor Aleksandrychiev <ihor.aleksandrychiev@northern.tech>
1 parent bdf6fa7 commit 0f0bffa

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

generator/_scripts/cfdoc_linkresolver.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
import re
2626
import cfdoc_qa as qa
2727

28+
# Jira base URL for ticket links
29+
JIRA_BASE_URL = "https://northerntech.atlassian.net/browse/"
30+
# Pattern to match Jira ticket references (ENT-1234, CFE-4567, etc.)
31+
JIRA_TICKET_PATTERN = re.compile(r'\b(ENT|CFE)-(\d+)\b')
32+
2833

2934
def run(config):
3035
markdown_files = config["markdown_files"]
@@ -115,6 +120,13 @@ def headerToAnchor(header):
115120
return anchor
116121

117122

123+
def convertJiraTicketsToLinks(line):
124+
"""Convert Jira ticket references (ENT-1234, CFE-4567) to markdown links."""
125+
return JIRA_TICKET_PATTERN.sub(
126+
lambda m: "[%s](%s%s)" % (m[0], JIRA_BASE_URL, m[0]), line
127+
)
128+
129+
118130
def parseMarkdownForAnchors(file_name, config):
119131
in_file = open(file_name, "r")
120132
lines = in_file.readlines()
@@ -305,6 +317,14 @@ def applyLinkMap(file_name, config):
305317
else:
306318
break
307319
new_line += markdown_line
320+
321+
# Convert Jira ticket references to links (only outside code blocks)
322+
if not in_pre:
323+
original_line = new_line
324+
new_line = convertJiraTicketsToLinks(new_line)
325+
if new_line != original_line:
326+
write_changes = True
327+
308328
new_lines.append(new_line)
309329
previous_empty = markdown_line.lstrip() == ""
310330

0 commit comments

Comments
 (0)