Skip to content

Commit 3caaad7

Browse files
committed
修正 Hook 音频示例
1 parent aef5191 commit 3caaad7

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

docs/05-mcpp-toml.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,9 +2154,6 @@ build_start = "echo build started"
21542154
build_failed = "notify-send 'build failed'"
21552155
build_finished = "notify-send 'build finished'"
21562156

2157-
# Runs alongside the build and is stopped when it ends.
2158-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
2159-
21602157
# Optional; these are the defaults.
21612158
timeout_seconds = 10
21622159
enabled = true
@@ -2207,8 +2204,8 @@ build_start
22072204
└─ build fails → during_build closes → build_failed
22082205
```
22092206

2210-
`during_build` closes **before** the terminal hook, so a "build finished" sound
2211-
is not competing with the background music it replaces.
2207+
`during_build` closes **before** the terminal hook, so the two commands never
2208+
overlap.
22122209

22132210
`build_failed` and `build_finished` are mutually exclusive, and both are
22142211
reachable only after `build_start` has run. A project that cannot be *prepared*
@@ -2286,7 +2283,6 @@ than adding media handling to mcpp:
22862283

22872284
```toml
22882285
[hooks]
2289-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
22902286
build_finished = "mcpp-hooks-audioplayer niulai-mm"
22912287
build_failed = "mcpp-hooks-audioplayer niulai-niulai"
22922288
side_effect = false
@@ -2295,11 +2291,10 @@ side_effect = false
22952291
deps = ["xim:mcpp-hooks-audioplayer@0.0.1"]
22962292
```
22972293

2298-
Background music for the length of the build, and a different sound for how it
2299-
ended. `side_effect = false` is written out rather than left to the default:
2300-
it is the value this manifest wants on its own terms — a missing audio device
2301-
should never fail a build — so it will still say so once the key has more than
2302-
one accepted value.
2294+
A different sound for a successful or failed build. `side_effect = false` is
2295+
written out rather than left to the default: it is the value this manifest
2296+
wants on its own terms — a missing audio device should never fail a build — so
2297+
it will still say so once the key has more than one accepted value.
23032298

23042299
## Appendix A. Schema Ownership Principle (admission criteria for new fields)
23052300

docs/zh/05-mcpp-toml.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1845,9 +1845,6 @@ build_start = "echo build started"
18451845
build_failed = "notify-send 'build failed'"
18461846
build_finished = "notify-send 'build finished'"
18471847

1848-
# 与构建并行,构建结束时被停止。
1849-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
1850-
18511848
# 可选;以下是默认值。
18521849
timeout_seconds = 10
18531850
enabled = true
@@ -1893,8 +1890,7 @@ build_start
18931890
└─ 构建失败 → during_build 闭合 → build_failed
18941891
```
18951892

1896-
`during_build` 在终止 Hook **之前**闭合,这样"构建完成"的提示音不会和它要替换掉的
1897-
背景音乐撞在一起。
1893+
`during_build` 在终止 Hook **之前**闭合,因此两条命令不会重叠执行。
18981894

18991895
`build_failed``build_finished` 互斥,而且两者都只在 `build_start` 已经执行之后
19001896
才可达。项目**准备**阶段就失败的情况——manifest 非法、依赖无法解析、没有可用工具链
@@ -1953,7 +1949,6 @@ Hook 程序可以作为普通 xlings 依赖安装。例如,音频通知程序可
19531949

19541950
```toml
19551951
[hooks]
1956-
during_build = { cmd = "mcpp-hooks-audioplayer bgm", loop = true }
19571952
build_finished = "mcpp-hooks-audioplayer niulai-mm"
19581953
build_failed = "mcpp-hooks-audioplayer niulai-niulai"
19591954
side_effect = false
@@ -1962,9 +1957,9 @@ side_effect = false
19621957
deps = ["xim:mcpp-hooks-audioplayer@0.0.1"]
19631958
```
19641959

1965-
构建全程的背景音乐,加上一段区分结果的提示音`side_effect = false` 写出来而不是靠
1966-
默认值:它是这份 manifest 自己就想要的值——缺个音频设备不该让构建失败——所以等这个键
1967-
有了不止一个可接受的值之后,它仍然会这么写。
1960+
根据构建成功或失败播放不同提示音`side_effect = false` 写出来而不是靠默认值:它是
1961+
这份 manifest 自己就想要的值——缺个音频设备不该让构建失败——所以等这个键有了不止
1962+
一个可接受的值之后,它仍然会这么写。
19681963

19691964
## 附录 A. Schema 所有权原则(新字段准入标准)
19701965

0 commit comments

Comments
 (0)