diff --git a/Katheryne/Abstractions/IChatRobot.cs b/Katheryne/Abstractions/IChatRobot.cs
index 48575ad..0dc962b 100644
--- a/Katheryne/Abstractions/IChatRobot.cs
+++ b/Katheryne/Abstractions/IChatRobot.cs
@@ -5,11 +5,27 @@ namespace Katheryne.Abstractions;
///
public interface IChatRobot
{
+ ///
+ /// 定义机器人的名称
+ ///
public string RobotName { get; }
-
+
+ ///
+ /// 机器人在启动时输出的对话
+ ///
+ /// 对话列表
public IEnumerable OnChatStart();
+ ///
+ /// 机器人在结束对话时输出的对话列表
+ ///
+ /// 对话列表
public IEnumerable OnChatStop();
+ ///
+ /// 机器人在获得用户输入时输出的对话列表
+ ///
+ /// 用户的输入
+ /// 机器人输出的对话列表
public IEnumerable ChatNext(string input);
}
\ No newline at end of file
diff --git a/Katheryne/Abstractions/IChatRobotFactory.cs b/Katheryne/Abstractions/IChatRobotFactory.cs
index d8b7127..db22248 100644
--- a/Katheryne/Abstractions/IChatRobotFactory.cs
+++ b/Katheryne/Abstractions/IChatRobotFactory.cs
@@ -3,7 +3,7 @@ using Katheryne.Exceptions;
namespace Katheryne.Abstractions;
///
-/// 聊天机器人接口
+/// 聊天机器人工厂接口
///
public interface IChatRobotFactory
{
diff --git a/Katheryne/Abstractions/IParamsModule.cs b/Katheryne/Abstractions/IParamsModule.cs
index ddaa168..6ed4f8d 100644
--- a/Katheryne/Abstractions/IParamsModule.cs
+++ b/Katheryne/Abstractions/IParamsModule.cs
@@ -5,9 +5,21 @@ namespace Katheryne.Abstractions;
///
public interface IParamsModule
{
+ ///
+ /// 模块的名称
+ ///
public string ModuleName { get; }
+ ///
+ /// 获得模块中特定指定参数的文本
+ ///
+ /// 指定参数
public string this[string param] { get; }
+ ///
+ /// 判断模块是否提供指定参数
+ ///
+ /// 指定参数
+ /// 如果为真,说明模块提供该参数,反之没有提供
public bool ContainsParam(string param);
}
\ No newline at end of file
diff --git a/Katheryne/Models/FormatTag.cs b/Katheryne/Models/FormatTag.cs
index 112ba8e..321069b 100644
--- a/Katheryne/Models/FormatTag.cs
+++ b/Katheryne/Models/FormatTag.cs
@@ -1,3 +1,8 @@
namespace Katheryne.Models;
+///
+/// 格式化标记
+///
+/// 原始字符串
+/// 在匹配结果中的序号
public record FormatTag(string Value, int Index);
\ No newline at end of file
diff --git a/Katheryne/Models/GrammarParam.cs b/Katheryne/Models/GrammarParam.cs
index f6e400b..87a1ff5 100644
--- a/Katheryne/Models/GrammarParam.cs
+++ b/Katheryne/Models/GrammarParam.cs
@@ -1,3 +1,9 @@
namespace Katheryne.Models;
+///
+/// 语法中的模块参数
+///
+/// 原始字符串
+/// 模块名称
+/// 参数
public record GrammarParam(string OriginString, string Module, string Param);
\ No newline at end of file
diff --git a/Katheryne/Models/GrammarTree.cs b/Katheryne/Models/GrammarTree.cs
index 070594f..90031d3 100644
--- a/Katheryne/Models/GrammarTree.cs
+++ b/Katheryne/Models/GrammarTree.cs
@@ -3,6 +3,9 @@ using Katheryne.Exceptions;
namespace Katheryne.Models;
+///
+/// 语法树
+///
public class GrammarTree
{
private readonly Dictionary _stages = new();
diff --git a/Katheryne/Models/LexicalModel.cs b/Katheryne/Models/LexicalModel.cs
index 5b150c2..f6c8fc6 100644
--- a/Katheryne/Models/LexicalModel.cs
+++ b/Katheryne/Models/LexicalModel.cs
@@ -1,5 +1,8 @@
namespace Katheryne.Models;
+///
+/// 词法模型
+///
public class LexicalModel
{
public required string RobotName { get; set; }
diff --git a/Katheryne/Models/StringFormatter.cs b/Katheryne/Models/StringFormatter.cs
index 514618a..32ad1e7 100644
--- a/Katheryne/Models/StringFormatter.cs
+++ b/Katheryne/Models/StringFormatter.cs
@@ -27,10 +27,21 @@ public class StringFormatter
GetFormatTags();
}
+ ///
+ /// 字符串是否需要进行格式化
+ ///
public bool IsFormat => _formatTags.Count != 0 || _params.Count != 0;
+ ///
+ /// 原始字符串
+ ///
public string RowString => _originString;
+ ///
+ /// 格式化字符串
+ ///
+ /// 正则表达式匹配的结果列表
+ /// 格式化之后的字符串
public string Format(GroupCollection collection)
{
var result = new string(_originString);
@@ -54,6 +65,10 @@ public class StringFormatter
return result;
}
+ ///
+ /// 解析字符串中需要格式化的标签
+ ///
+ /// 文法中调用的模块不存在
private void GetFormatTags()
{
List tagIndices = new();
diff --git a/Katheryne/Modules/ModuleBase.cs b/Katheryne/Modules/ModuleBase.cs
index 61553c3..d0efb8f 100644
--- a/Katheryne/Modules/ModuleBase.cs
+++ b/Katheryne/Modules/ModuleBase.cs
@@ -3,6 +3,9 @@ using Katheryne.Abstractions;
namespace Katheryne.Modules;
+///
+/// 参数模块实现基类
+///
public abstract class ModuleBase : IParamsModule
{
protected readonly Dictionary> Functions = new();
diff --git a/Katheryne/Modules/WeatherModule.cs b/Katheryne/Modules/WeatherModule.cs
index 4fb79dc..79f5f4a 100644
--- a/Katheryne/Modules/WeatherModule.cs
+++ b/Katheryne/Modules/WeatherModule.cs
@@ -4,6 +4,9 @@ using Katheryne.Exceptions;
namespace Katheryne.Modules;
+///
+/// 提供天气服务的模块
+///
public class WeatherModule : ModuleBase
{
private static readonly HttpClient s_httpClient = new();
diff --git a/Katheryne/ServiceCollectionExtensions.cs b/Katheryne/ServiceCollectionExtensions.cs
index 52883cb..6ac6d47 100644
--- a/Katheryne/ServiceCollectionExtensions.cs
+++ b/Katheryne/ServiceCollectionExtensions.cs
@@ -8,6 +8,9 @@ namespace Katheryne;
public static class ServiceCollectionExtensions
{
+ ///
+ /// 在服务集合中添加Katheryne DSL解释机器人服务
+ ///
public static void AddKatheryne(this IServiceCollection collection)
{
collection.AddSingleton();
diff --git a/Katheryne/Services/KatheryneChatRobotFactory.cs b/Katheryne/Services/KatheryneChatRobotFactory.cs
index 7483ab2..e12c87c 100644
--- a/Katheryne/Services/KatheryneChatRobotFactory.cs
+++ b/Katheryne/Services/KatheryneChatRobotFactory.cs
@@ -6,6 +6,9 @@ using YamlDotNet.Serialization;
namespace Katheryne.Services;
+///
+/// Katheryne 聊天机器人工厂实现
+///
public class KatheryneChatRobotFactory : IChatRobotFactory
{
private readonly YamlDeserializerFactory _deserializerFactory;
diff --git a/Katheryne/Services/YamlDeserializerFactory.cs b/Katheryne/Services/YamlDeserializerFactory.cs
index 7f1c8e9..e8c9714 100644
--- a/Katheryne/Services/YamlDeserializerFactory.cs
+++ b/Katheryne/Services/YamlDeserializerFactory.cs
@@ -3,6 +3,9 @@ using YamlDotNet.Serialization.NamingConventions;
namespace Katheryne.Services;
+///
+/// YAML 反序列化对象工厂
+///
public class YamlDeserializerFactory
{
private readonly DeserializerBuilder _builder;