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,51 @@
# SmartPtr::MakeRef
```cpp
template<typename T, typename... Args>
Ref<T> MakeRef(Args&&... args);
```
创建共享指针的工厂函数。
**描述**
`MakeRef` 是创建 `Ref<T>` 的工厂函数,使用完美转发将参数传递给 `T` 的构造函数。相比直接使用 `std::make_shared`,代码更简洁。
**模板参数:**
- `T` - 被创建对象的类型
- `Args` - 构造函数的参数类型
**参数:**
- `args` - 转发给 T 构造函数的参数
**返回:** `Ref<T>` - 新创建的共享指针
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/SmartPtr.h>
class MyClass {
public:
MyClass(int a, int b) : m_a(a), m_b(b) {}
int GetSum() const { return m_a + m_b; }
private:
int m_a, m_b;
};
// 创建共享指针
Core::Ref<MyClass> ref = Core::MakeRef<MyClass>(10, 20);
printf("Sum: %d\n", ref->GetSum());
// 使用 lambda
Core::Ref<std::function<void()>> callback = Core::MakeRef<std::function<void()>>([]() {
printf("Callback invoked!\n");
});
```
## 相关文档
- [SmartPtr 总览](smartptr.md) - 返回类总览
- [Ref](Ref.md) - Ref 类型说明

View File

@@ -0,0 +1,49 @@
# SmartPtr::MakeUnique
```cpp
template<typename T, typename... Args>
UniqueRef<T> MakeUnique(Args&&... args);
```
创建独占指针的工厂函数。
**描述**
`MakeUnique` 是创建 `UniqueRef<T>` 的工厂函数,使用完美转发将参数传递给 `T` 的构造函数。相比直接使用 `std::make_unique`,代码更简洁。
**模板参数:**
- `T` - 被创建对象的类型
- `Args` - 构造函数的参数类型
**参数:**
- `args` - 转发给 T 构造函数的参数
**返回:** `UniqueRef<T>` - 新创建的独占指针
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/SmartPtr.h>
class MyClass {
public:
MyClass(int value) : m_value(value) {}
int GetValue() const { return m_value; }
private:
int m_value;
};
// 创建独占指针
Core::UniqueRef<MyClass> unique = Core::MakeUnique<MyClass>(42);
printf("Value: %d\n", unique->GetValue());
// 转移所有权
Core::UniqueRef<MyClass> moved = Core::MakeUnique<MyClass>(100);
```
## 相关文档
- [SmartPtr 总览](smartptr.md) - 返回类总览
- [UniqueRef](UniqueRef.md) - UniqueRef 类型说明

View File

@@ -0,0 +1,40 @@
# SmartPtr::Ref
```cpp
template<typename T>
using Ref = std::shared_ptr<T>;
```
共享引用智能指针类型别名。
**描述**
`Ref<T>``std::shared_ptr<T>` 的类型别名,提供共享所有权的智能指针。多个 `Ref` 可以指向同一个对象,通过引用计数管理生命周期。当最后一个 `Ref` 被销毁时,对象会被自动删除。
**模板参数:**
- `T` - 被托管对象的类型
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/SmartPtr.h>
class MyClass {
public:
void DoSomething() { /* ... */ }
};
Core::Ref<MyClass> ref1 = Core::MakeRef<MyClass>();
Core::Ref<MyClass> ref2 = ref1; // 共享所有权
if (ref1) {
ref1->DoSomething();
}
```
## 相关文档
- [SmartPtr 总览](smartptr.md) - 返回类总览
- [MakeRef](MakeRef.md) - 创建 Ref 的工厂函数

View File

@@ -0,0 +1,46 @@
# SmartPtr::UniqueRef
```cpp
template<typename T>
using UniqueRef = std::unique_ptr<T>;
```
独占所有权的智能指针类型别名。
**描述**
`UniqueRef<T>``std::unique_ptr<T>` 的类型别名,提供独占所有权的智能指针。每个对象只能有一个 `UniqueRef` 持有,当 `UniqueRef` 被销毁时,对象会被自动删除。不能复制,只能移动。
**模板参数:**
- `T` - 被托管对象的类型
**复杂度:** O(1)
**示例:**
```cpp
#include <XCEngine/Core/SmartPtr.h>
class MyClass {
public:
void DoSomething() { /* ... */ }
};
Core::UniqueRef<MyClass> unique = Core::MakeUnique<MyClass>();
if (unique) {
unique->DoSomething();
}
// 自定义删除器
Core::UniqueRef<FILE, decltype(&fclose)>
file(fopen("test.txt", "r"), &fclose);
// 转移所有权
Core::UniqueRef<MyClass> moved = std::move(unique);
```
## 相关文档
- [SmartPtr 总览](smartptr.md) - 返回类总览
- [MakeUnique](MakeUnique.md) - 创建 UniqueRef 的工厂函数

View File

@@ -0,0 +1,64 @@
# SmartPtr
**命名空间**: `XCEngine::Core`
**类型**: `header-only`
**描述**: 智能指针类型别名和工厂函数,提供 `std::shared_ptr``std::unique_ptr` 的简化接口。
## 概述
`Core::SmartPtr` 提供了 `std::shared_ptr``std::unique_ptr` 的类型别名和工厂函数,使智能指针的使用更加简洁。
## 类型别名
| 别名 | 底层类型 | 描述 |
|------|----------|------|
| `Core::Ref<T>` | `std::shared_ptr<T>` | 共享引用智能指针 |
| `Core::UniqueRef<T>` | `std::unique_ptr<T>` | 独占所有权的智能指针 |
## 工厂函数
| 函数 | 返回值 | 描述 |
|------|--------|------|
| `Core::MakeRef<T>(Args&&... args)` | `Ref<T>` | 创建共享指针 |
| `Core::MakeUnique<T>(Args&&... args)` | `UniqueRef<T>` | 创建独占指针 |
## 公共方法
| 方法 | 描述 |
|------|------|
| [`Ref`](Ref.md) | `std::shared_ptr<T>` 类型别名 |
| [`UniqueRef`](UniqueRef.md) | `std::unique_ptr<T>` 类型别名 |
| [`MakeRef`](MakeRef.md) | 创建共享指针的工厂函数 |
| [`MakeUnique`](MakeUnique.md) | 创建独占指针的工厂函数 |
## 使用示例
```cpp
#include <XCEngine/Core/Core.h>
// 使用 Ref共享指针
Core::Ref<MyClass> ref = Core::MakeRef<MyClass>(arg1, arg2);
// 使用 UniqueRef独占指针
Core::UniqueRef<MyClass> unique = Core::MakeUnique<MyClass>();
// 传递所有权
Core::Ref<MyClass> ref2 = ref; // 引用计数 +1
// 检查有效性
if (ref) {
ref->DoSomething();
}
// 自定义删除器
Core::UniqueRef<FILE, decltype(&fclose)>
file(fopen("test.txt", "r"), &fclose);
```
## 相关文档
- [Core 模块总览](../core.md) - 返回模块总览
- [RefCounted](../refcounted/refcounted.md) - 引用计数基类
- [Types](../types/types.md) - 类型别名