Skip to content

Commit 2487a27

Browse files
committed
fix(release): generate explicit versioned language anchors
1 parent 57a9c11 commit 2487a27

4 files changed

Lines changed: 13 additions & 2 deletions

File tree

‎docs/releases/TEMPLATE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<!-- 中文完整区块在前,英文完整区块在后。每种语言保留版本亮点、验证情况、已知限制、安装说明四个必需章节;按需保留新增功能与改进、修复内容两个可选章节,中英文对应。 -->
55
<!-- 首发 Previous 为 none;不手填 Source、Full Changelog 或 References,生成器会统一追加 ## Source / 源码、## References / PR 与 Commit 记录。 -->
66
<!-- Previous: vPREVIOUS -->
7+
<!-- 源文件使用标题跳转;发布生成器自动添加包含 Tag 的显式 name 锚点及对应 user-content- 跳转,避免 Releases 列表冲突。 -->
78

89
[简体中文](#简体中文) · [English](#english)
910

‎tests/run-release-notes-tests.ps1‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ foreach ($notesTestTag in @('v1.2.3-dev.1', 'v1.2.3-rc.1', 'v1.2.3')) {
8181
Assert-NotesTest ($notesTestResult.Body.Contains('independent models without a pull request')) 'Direct feature commit was omitted'
8282
Assert-NotesTest ($notesTestResult.Body.Contains("/commit/$notesTestDirect")) 'Direct commit link missing'
8383
Assert-NotesTest ([regex]::Matches($notesTestResult.Body, '/pull/7\)').Count -eq 1) 'Duplicate pull request reference'
84-
Assert-NotesTest ($notesTestResult.Body.StartsWith('[简体中文](#简体中文) · [English](#english)')) 'Top navigation missing'
84+
Assert-NotesTest ($notesTestResult.Body.StartsWith("[简体中文](#user-content-nr-nexus-$notesTestTag-zh) · [English](#user-content-nr-nexus-$notesTestTag-en)")) 'Top navigation missing'
85+
foreach ($language in @('zh', 'en')) {
86+
$anchor = "nr-nexus-$notesTestTag-$language"
87+
Assert-NotesTest ([regex]::Matches($notesTestResult.Body, [regex]::Escape("<a name=`"$anchor`"></a>")).Count -eq 1) 'Explicit language anchor must occur once'
88+
Assert-NotesTest ($notesTestResult.Body.Contains("(#user-content-$anchor)")) 'Link must target the GitHub-prefixed anchor'
89+
}
8590
Assert-NotesTest ($notesTestResult.Body.IndexOf('## 简体中文') -lt $notesTestResult.Body.IndexOf('## English')) 'Language order changed'
8691
Assert-NotesTest ($notesTestResult.Body.IndexOf('### Installation') -lt $notesTestResult.Body.IndexOf('## Source / 源码')) 'Generated content displaced language blocks'
8792
Assert-NotesTest ([regex]::Matches($notesTestResult.Body, '(?m)^## Source / 源码$').Count -eq 1) 'Source section must occur once'

‎tests/run-release-tests.ps1‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Extract the release archive.
6565
$releaseTestNotes = $releaseTestNotes.Replace('TAG', $releaseTestVersion.Tag)
6666
[IO.File]::WriteAllText($releaseTestNotesPath, $releaseTestNotes)
6767
function Assert-TestNotes([string]$Body) {
68-
Assert-Test ($Body.StartsWith('[简体中文](#简体中文) · [English](#english)')) 'Reviewed navigation missing'
68+
Assert-Test ($Body.StartsWith("[简体中文](#user-content-nr-nexus-$($releaseTestVersion.Tag)-zh) · [English](#user-content-nr-nexus-$($releaseTestVersion.Tag)-en)")) 'Reviewed navigation missing'
6969
Assert-Test ($Body.IndexOf('## 简体中文') -lt $Body.IndexOf('## English')) 'Language blocks reordered'
7070
Assert-Test ($Body.Contains('### 版本亮点') -and $Body.Contains('### Highlights') -and $Body.Contains('direct feature: add independent per-pass models')) 'Reviewed features or direct commits missing'
7171
foreach ($heading in @('Source / 源码', 'References / PR 与 Commit 记录')) {

‎tools/get-release-notes.ps1‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ foreach ($notesLine in $notesLog) {
9696
}
9797
}
9898
$notesBody = [regex]::Replace($notesText.Substring($notesTitle.Length), '(?m)^<!-- Previous: .*? -->\n?', '').Trim()
99+
# Release pages omit automatic heading IDs. GitHub prefixes explicit names with user-content-.
100+
$notesAnchor = 'nr-nexus-' + $Tag
101+
$notesBody = $notesBody.Replace($notesNavigation, "[简体中文](#user-content-$notesAnchor-zh) · [English](#user-content-$notesAnchor-en)")
102+
$notesBody = $notesBody.Replace('## 简体中文', "<a name=`"$notesAnchor-zh`"></a>`n`n## 简体中文")
103+
$notesBody = $notesBody.Replace('## English', "<a name=`"$notesAnchor-en`"></a>`n`n## English")
99104
$notesBody += "`n`n## Source / 源码`n`nTag: [$Tag](https://github.com/$Repository/tree/$Tag)`n`nSource: https://github.com/$Repository/commit/$notesSource"
100105
if ($notesPreviousTag -ne 'none') {
101106
$notesBody += "`n`n[Full Changelog](https://github.com/$Repository/compare/$notesPreviousTag...$Tag)"

0 commit comments

Comments
 (0)