Skip to content

Commit 9efff48

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 9efff48

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

generator/_scripts/cfdoc_linkresolver.py

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

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

2933
def run(config):
3034
markdown_files = config["markdown_files"]
@@ -115,6 +119,13 @@ def headerToAnchor(header):
115119
return anchor
116120

117121

122+
def convertJiraTicketsToLinks(line):
123+
"""Convert Jira ticket references (ENT-1234, CFE-4567) to markdown links."""
124+
return JIRA_TICKET_PATTERN.sub(
125+
lambda m: "[%s](%s%s)" % (m[0], JIRA_BASE_URL, m[0]), line
126+
)
127+
128+
118129
def parseMarkdownForAnchors(file_name, config):
119130
in_file = open(file_name, "r")
120131
lines = in_file.readlines()
@@ -305,6 +316,14 @@ def applyLinkMap(file_name, config):
305316
else:
306317
break
307318
new_line += markdown_line
319+
320+
# Convert Jira ticket references to links (only outside code blocks)
321+
if not in_pre:
322+
original_line = new_line
323+
new_line = convertJiraTicketsToLinks(new_line)
324+
if new_line != original_line:
325+
write_changes = True
326+
308327
new_lines.append(new_line)
309328
previous_empty = markdown_line.lstrip() == ""
310329

0 commit comments

Comments
 (0)