Skip to content

Commit 099160a

Browse files
authored
docs: fix images generation in release notes (#2792)
1 parent 23e87e8 commit 099160a

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

docs/docs/en/release.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The main feature of this release is the **Try It Out** feature for your **Async
2020

2121
Now you can test your developing application directly from the web, just like Swagger for HTTP. It supports in-memory publication to test a subscriber and real broker publication to verify behavior in real scenarios.
2222

23-
<img width="1467" height="640" alt="Снимок экрана 2026-03-01 в 11 16 10" src="[#>](https://github.com/user-attachments/assets/4320e674-24d5-4ead-9820-4bb979e340e7" />){.external-link target="_blank"}
23+
<img width="1467" height="640" alt="" src="https://github.com/user-attachments/assets/4320e674-24d5-4ead-9820-4bb979e340e7">
2424

2525
* feat: Add Try It Out feature for AsyncAPI documentation by [@vvlrff](https://github.com/vvlrff){.external-link target="_blank"} in [#2777](https://github.com/ag2ai/faststream/pull/2777){.external-link target="_blank"}
2626

docs/update_releases.py

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,38 @@ def get_github_releases() -> Sequence[Tuple[str, str]]:
3535
raise Exception(f"Error getting GitHub releases: {e}, {row_data}") from e
3636

3737

38-
def convert_links_and_usernames(text):
38+
def normalize_img_tag(match: re.Match) -> str:
39+
"""Extract img attributes and return a normalized <img> tag (plain src URL, empty alt)."""
40+
attrs = match.group(1)
41+
width = re.search(r'width=["\']?(\d+)', attrs)
42+
height = re.search(r'height=["\']?(\d+)', attrs)
43+
src = re.search(r'src=["\']([^"\']+)["\']', attrs)
44+
if not src:
45+
return match.group(0)
46+
parts = []
47+
if width:
48+
parts.append(f'width="{width.group(1)}"')
49+
if height:
50+
parts.append(f'height="{height.group(1)}"')
51+
parts.append('alt=""')
52+
# Use only the URL, no markdown/link wrapping
53+
parts.append(f'src="{src.group(1)}"')
54+
return "<img " + " ".join(parts) + ">"
55+
56+
57+
def convert_links_and_usernames(text: str) -> str:
58+
# Replace <img ...> tags with placeholders so their URLs are not wrapped as links
59+
img_pattern = re.compile(r"<img\s+([^>]+)>")
60+
img_placeholders: List[str] = []
61+
62+
def stash_img(match: re.Match) -> str:
63+
img_placeholders.append(normalize_img_tag(match))
64+
return f"\x00IMG_PLACEHOLDER_{len(img_placeholders) - 1}\x00"
65+
66+
text = img_pattern.sub(stash_img, text)
67+
3968
if "](" not in text:
40-
# Convert HTTP/HTTPS links
69+
# Convert HTTP/HTTPS links (img tags already stashed, so their URLs are not matched)
4170
text = re.sub(
4271
r"(https?://.*\/(.*))",
4372
r'[#\2](\1){.external-link target="_blank"}',
@@ -51,6 +80,10 @@ def convert_links_and_usernames(text):
5180
text,
5281
)
5382

83+
# Restore normalized img tags
84+
for i, img in enumerate(img_placeholders):
85+
text = text.replace(f"\x00IMG_PLACEHOLDER_{i}\x00", img)
86+
5487
return text
5588

5689

@@ -71,6 +104,7 @@ def update_release_notes(release_notes_path: Path):
71104

72105
old_versions = collect_already_published_versions(changelog)
73106

107+
added_versions: List[str] = []
74108
for version, body in filter(
75109
lambda v: v[0] not in old_versions,
76110
get_github_releases(),
@@ -79,6 +113,12 @@ def update_release_notes(release_notes_path: Path):
79113
body = convert_links_and_usernames(body)
80114
version_changelog = f"## {version}\n\n{body}\n\n"
81115
changelog = version_changelog + changelog
116+
added_versions.append(version)
117+
118+
if added_versions:
119+
print(f"Added release versions: {', '.join(added_versions)}")
120+
else:
121+
print("No new versions to add")
82122

83123
# Update the RELEASE.md file with the latest version and changelog
84124
release_notes_path.write_text(

0 commit comments

Comments
 (0)