fix: improve doc link navigation and tree display

- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
This commit is contained in:
2026-03-19 12:44:08 +08:00
parent e003fe6513
commit 58a83f445a
1012 changed files with 56880 additions and 22 deletions

View File

@@ -0,0 +1,39 @@
# Event::Clear
```cpp
void Clear();
```
清空所有订阅。
**描述**
移除所有已订阅的回调,清空事件。线程安全。
**复杂度:** O(n) 其中 n 为订阅数量
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
Event<int> event;
// 订阅多个回调
event.Subscribe([](int v) { });
event.Subscribe([](int v) { });
event.Subscribe([](int v) { });
// 清空所有订阅
event.Clear();
// 触发(无回调被执行)
event.Invoke(42);
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [Unsubscribe](Unsubscribe.md) - 退订单个事件

View File

@@ -0,0 +1,45 @@
# Event::Invoke
```cpp
void Invoke(Args... args);
```
调用所有订阅的回调。
**描述**
依次调用所有已订阅的回调函数。在调用前会自动处理待退订的回调。回调是在锁外执行的,因此可以在回调中安全地进行订阅/退订操作。线程安全。
**参数:**
- `args` - 传递给回调的参数
**复杂度:** O(n) 其中 n 为订阅数量
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
// 无参数事件
Event<> frameEndEvent;
frameEndEvent.Subscribe([]() {
printf("Frame ended\n");
});
// 带参数事件
Event<int, const char*> playerDiedEvent;
playerDiedEvent.Subscribe([](int playerId, const char* reason) {
printf("Player %d died: %s\n", playerId, reason);
});
// 触发事件
frameEndEvent.Invoke();
playerDiedEvent.Invoke(1, "fell off a cliff");
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [Subscribe](Subscribe.md) - 订阅事件

View File

@@ -0,0 +1,39 @@
# Event::ProcessUnsubscribes
```cpp
void ProcessUnsubscribes();
```
处理积压的退订请求。
**描述**
手动处理待退订的回调,将其从订阅列表中移除。通常不需要手动调用,`Invoke` 会自动处理退订。但在某些场景下可能需要主动调用。
**复杂度:** O(n) 其中 n 为待退订数量
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
Event<int> event;
// 订阅
uint64_t id = event.Subscribe([](int value) { });
// 退订请求入队
event.Unsubscribe(id);
// 主动处理退订
event.ProcessUnsubscribes();
// 此时事件列表中已无该回调
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [Unsubscribe](Unsubscribe.md) - 退订事件

View File

@@ -0,0 +1,50 @@
# Event::Subscribe
```cpp
uint64_t Subscribe(Callback callback);
```
订阅事件回调。
**描述**
将回调函数添加到事件订阅列表中,并返回一个唯一的订阅 ID。该 ID 可用于后续退订。线程安全,可在任意线程调用。
**参数:**
- `callback` - 要订阅的回调函数,类型为 `std::function<void(Args...)>`
**返回:** `uint64_t` - 订阅 ID用于退订
**复杂度:** O(1) amortized
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
// 定义事件
Event<int, float> damageEvent;
// 订阅多个回调
uint64_t id1 = damageEvent.Subscribe([](int damage, float time) {
printf("Damage taken: %d at time %f\n", damage, time);
});
uint64_t id2 = damageEvent.Subscribe([](int damage, float time) {
// 记录伤害日志
});
// 使用 lambda 表达式
auto callback = [](int damage, float time) {
// 处理伤害
};
uint64_t id3 = damageEvent.Subscribe(callback);
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [Unsubscribe](Unsubscribe.md) - 退订事件
- [Invoke](Invoke.md) - 触发事件

View File

@@ -0,0 +1,43 @@
# Event::Unsubscribe
```cpp
void Unsubscribe(uint64_t id);
```
退订事件。
**描述**
将指定 ID 的回调从订阅列表中移除。退订是延迟生效的,在调用 `Invoke` 时会一并处理待退订的回调。线程安全,可在任意线程调用。
**参数:**
- `id` - 订阅时返回的 ID
**复杂度:** O(n) 在 Invoke 时处理
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
Event<int> someEvent;
// 订阅
uint64_t id = someEvent.Subscribe([](int value) {
printf("Value: %d\n", value);
});
// 退订
someEvent.Unsubscribe(id);
// 触发(已退订的回调不会被调用)
someEvent.Invoke(42);
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [Subscribe](Subscribe.md) - 订阅事件
- [ProcessUnsubscribes](ProcessUnsubscribes.md) - 手动处理退订

View File

@@ -0,0 +1,37 @@
# Event::begin
```cpp
Iterator begin();
```
获取开始迭代器。
**描述**
返回订阅列表的开始迭代器用于范围for循环遍历所有订阅的回调。
**返回:** `Iterator` - 指向第一个监听器的迭代器(等价于 `std::vector<Listener>::iterator`
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
Event<int> event;
event.Subscribe([](int v) { printf("Callback 1: %d\n", v); });
event.Subscribe([](int v) { printf("Callback 2: %d\n", v); });
// 遍历所有订阅
for (auto& [id, callback] : event) {
callback(100);
}
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [end](end.md) - 获取结束迭代器

View File

@@ -0,0 +1,36 @@
# Event::end
```cpp
Iterator end();
```
获取结束迭代器。
**描述**
返回订阅列表的结束迭代器用于范围for循环遍历所有订阅的回调。
**返回:** `Iterator` - 指向末尾的迭代器(等价于 `std::vector<Listener>::iterator`
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
Event<int> event;
event.Subscribe([](int v) { printf("Callback: %d\n", v); });
// 遍历所有订阅
for (auto& [id, callback] : event) {
callback(42);
}
```
## 相关文档
- [Event 总览](event.md) - 返回类总览
- [begin](begin.md) - 获取开始迭代器

View File

@@ -0,0 +1,69 @@
# Event
**命名空间**: `XCEngine::Core`
**类型**: `class` (template)
**描述**: 事件系统模板类,提供类型安全的多订阅者事件/委托系统。
## 概述
`Event<Args...>` 是一个类型安全的事件发布-订阅系统。它支持多个回调订阅、退订和线程安全的调用。非常适合用于游戏引擎中的事件驱动通信。
## 模板参数
| 参数 | 描述 |
|------|------|
| `Args...` | 事件回调的参数类型 |
## 类型别名
| 别名 | 类型 | 描述 |
|------|------|------|
| `Callback` | `std::function<void(Args...)>` | 回调函数类型 |
| `Listener` | `std::pair<uint64_t, Callback>` | 监听器条目 |
| `Iterator` | `std::vector<Listener>::iterator` | 迭代器类型 |
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Subscribe`](Subscribe.md) | 订阅事件回调,返回订阅 ID |
| [`Unsubscribe`](Unsubscribe.md) | 退订事件(延迟生效) |
| [`ProcessUnsubscribes`](ProcessUnsubscribes.md) | 处理积压的退订请求 |
| [`Clear`](Clear.md) | 清空所有订阅 |
| [`Invoke`](Invoke.md) | 调用所有订阅的回调 |
| [`begin`](begin.md) | 获取开始迭代器 |
| [`end`](end.md) | 获取结束迭代器 |
## 使用示例
```cpp
#include <XCEngine/Core/Event.h>
using namespace XCEngine::Core;
// 定义事件(无参数)
Event<> frameStartEvent;
// 定义事件(带参数)
Event<int, float> damageEvent;
// 订阅
uint64_t id = damageEvent.Subscribe([](int damage, float time) {
printf("Damage: %d at time %f\n", damage, time);
});
// 触发事件
damageEvent.Invoke(100, 3.14f);
// 退订
damageEvent.Unsubscribe(id);
// 清空
frameStartEvent.Clear();
```
## 相关文档
- [Core 模块总览](../core.md) - 返回模块总览