mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-07 00:39:00 +08:00
docs(generated): 添加源码生成器文档
- 新增 AutoRegisterExportedCollections 生成器文档 - 新增 AutoRegisterModule 生成器文档 - 新增 AutoScene 生成器文档 - 新增 AutoUiPage 生成器文档 - 更新源码生成器总览索引文档 - 添加各生成器的使用示例和参数说明 - 补充诊断信息和使用约束说明
This commit is contained in:
parent
01b32f6cfb
commit
3d169ca91f
@ -38,6 +38,13 @@ public sealed class TextureConfig : Resource, IKeyValue<string, Texture2D>
|
||||
{
|
||||
}
|
||||
|
||||
public sealed class TextureRegistry : IAssetRegistry<Texture2D>
|
||||
{
|
||||
public void Registry(IKeyValue<string, Texture2D> mapping)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[AutoRegisterExportedCollections]
|
||||
public partial class GameEntryPoint : Node
|
||||
{
|
||||
@ -49,11 +56,16 @@ public partial class GameEntryPoint : Node
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_textureRegistry ??= new TextureRegistry();
|
||||
__RegisterExportedCollections_Generated();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
为了让示例具备完整的调用路径,这里在 `_Ready()` 里先初始化了 `_textureRegistry`。
|
||||
实际项目里,这个字段通常来自架构容器、服务定位或外部注入;关键点是调用 `__RegisterExportedCollections_Generated()`
|
||||
之前,注册器成员必须已经可用,否则生成代码会按设计静默跳过注册。
|
||||
|
||||
## 生成的代码
|
||||
|
||||
```csharp
|
||||
@ -158,5 +170,5 @@ partial class GameEntryPoint
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [源码生成器总览](./index.md)
|
||||
- [源码生成器总览](./index)
|
||||
- [游戏内容配置系统](/zh-CN/game/config-system)
|
||||
|
||||
@ -149,5 +149,5 @@ partial class GameplayModule
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [源码生成器总览](./index.md)
|
||||
- [Context Get 注入生成器](./context-get-generator.md)
|
||||
- [源码生成器总览](./index)
|
||||
- [Context Get 注入生成器](./context-get-generator)
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
```csharp
|
||||
using GFramework.Godot.SourceGenerators.Abstractions;
|
||||
using GFramework.Game.Abstractions.Enums;
|
||||
using Godot;
|
||||
|
||||
[AutoScene(nameof(SceneKey.Gameplay))]
|
||||
@ -114,5 +115,5 @@ partial class GameplayRoot
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [源码生成器总览](./index.md)
|
||||
- [AutoUiPage 生成器](./auto-ui-page-generator.md)
|
||||
- [源码生成器总览](./index)
|
||||
- [AutoUiPage 生成器](./auto-ui-page-generator)
|
||||
|
||||
@ -31,7 +31,8 @@ public partial class MainMenu : Control
|
||||
}
|
||||
```
|
||||
|
||||
上面的 `nameof(UiKey.MainMenu)` 和 `nameof(UiLayer.Page)` 最终都会在编译期转成字符串常量。
|
||||
上面的 `nameof(UiKey.MainMenu)` 会生成字符串常量 `UiKeyStr`,`nameof(UiLayer.Page)` 则会在生成代码中解析为对应的枚举成员
|
||||
`UiLayer.Page`,并传入页面行为工厂。
|
||||
|
||||
## 生成的代码
|
||||
|
||||
@ -123,6 +124,7 @@ partial class MainMenu
|
||||
|
||||
```csharp
|
||||
using GFramework.Godot.SourceGenerators.Abstractions;
|
||||
using GFramework.Game.Abstractions.Enums;
|
||||
using GFramework.SourceGenerators.Abstractions.Rule;
|
||||
using Godot;
|
||||
|
||||
@ -146,6 +148,6 @@ public partial class PauseMenu : Control
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [源码生成器总览](./index.md)
|
||||
- [GetNode 生成器](./get-node-generator.md)
|
||||
- [BindNodeSignal 生成器](./bind-node-signal-generator.md)
|
||||
- [源码生成器总览](./index)
|
||||
- [GetNode 生成器](./get-node-generator)
|
||||
- [BindNodeSignal 生成器](./bind-node-signal-generator)
|
||||
|
||||
@ -494,7 +494,7 @@ public partial class GameplayModule
|
||||
}
|
||||
```
|
||||
|
||||
**完整文档**:[AutoRegisterModule 生成器](./auto-register-module-generator.md)
|
||||
**完整文档**:[AutoRegisterModule 生成器](./auto-register-module-generator)
|
||||
|
||||
## BindNodeSignal 生成器
|
||||
|
||||
@ -560,7 +560,7 @@ public partial class MainMenu : Control
|
||||
}
|
||||
```
|
||||
|
||||
**完整文档**:[AutoUiPage 生成器](./auto-ui-page-generator.md)
|
||||
**完整文档**:[AutoUiPage 生成器](./auto-ui-page-generator)
|
||||
|
||||
## AutoScene 生成器
|
||||
|
||||
@ -576,6 +576,7 @@ AutoScene 生成器为场景根节点自动生成 `SceneKeyStr`、缓存的 `ISc
|
||||
|
||||
```csharp
|
||||
using GFramework.Godot.SourceGenerators.Abstractions;
|
||||
using GFramework.Game.Abstractions.Enums;
|
||||
using Godot;
|
||||
|
||||
[AutoScene(nameof(SceneKey.Gameplay))]
|
||||
@ -584,7 +585,7 @@ public partial class GameplayRoot : Node2D
|
||||
}
|
||||
```
|
||||
|
||||
**完整文档**:[AutoScene 生成器](./auto-scene-generator.md)
|
||||
**完整文档**:[AutoScene 生成器](./auto-scene-generator)
|
||||
|
||||
## AutoRegisterExportedCollections 生成器
|
||||
|
||||
@ -610,7 +611,7 @@ public partial class GameEntryPoint : Node
|
||||
}
|
||||
```
|
||||
|
||||
**完整文档**:[AutoRegisterExportedCollections 生成器](./auto-register-exported-collections-generator.md)
|
||||
**完整文档**:[AutoRegisterExportedCollections 生成器](./auto-register-exported-collections-generator)
|
||||
|
||||
## 诊断信息
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user