diff --git a/src/Discord.Net.Commands/Attributes/DescriptionAttribute.cs b/src/Discord.Net.Commands/Attributes/DescriptionAttribute.cs index db9c57057..efa5f42a4 100644 --- a/src/Discord.Net.Commands/Attributes/DescriptionAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/DescriptionAttribute.cs @@ -2,7 +2,8 @@ namespace Discord.Commands { - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Parameter)] + // Full summary of method + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class)] public class DescriptionAttribute : Attribute { public string Text { get; } @@ -12,11 +13,12 @@ namespace Discord.Commands } } - [AttributeUsage(AttributeTargets.Method)] - public class SynopsisAttribute : Attribute + // Brief summary of method/module/parameter + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Parameter)] + public class SummaryAttribute : Attribute { public string Text { get; } - public SynopsisAttribute(string text) + public SummaryAttribute(string text) { Text = text; } diff --git a/src/Discord.Net.Commands/Command.cs b/src/Discord.Net.Commands/Command.cs index 2b0f34eb3..046753ede 100644 --- a/src/Discord.Net.Commands/Command.cs +++ b/src/Discord.Net.Commands/Command.cs @@ -15,7 +15,7 @@ namespace Discord.Commands public string Name { get; } public string Description { get; } - public string Synopsis { get; } + public string Summary { get; } public string Text { get; } public Module Module { get; } public IReadOnlyList Parameters { get; } @@ -33,9 +33,9 @@ namespace Discord.Commands if (description != null) Description = description.Text; - var synopsis = methodInfo.GetCustomAttribute(); - if (synopsis != null) - Synopsis = synopsis.Text; + var summary = methodInfo.GetCustomAttribute(); + if (summary != null) + Summary = summary.Text; Parameters = BuildParameters(methodInfo); Preconditions = BuildPreconditions(methodInfo); @@ -129,11 +129,11 @@ namespace Discord.Commands throw new InvalidOperationException("Remainder parameters must be the last parameter in a command."); string name = parameter.Name; - string description = typeInfo.GetCustomAttribute()?.Text; + string summary = parameter.GetCustomAttribute()?.Text; bool isOptional = parameter.IsOptional; object defaultValue = parameter.HasDefaultValue ? parameter.DefaultValue : null; - paramBuilder.Add(new CommandParameter(name, description, type, reader, isOptional, isRemainder, isMultiple, defaultValue)); + paramBuilder.Add(new CommandParameter(name, summary, type, reader, isOptional, isRemainder, isMultiple, defaultValue)); } return paramBuilder.ToImmutable(); } diff --git a/src/Discord.Net.Commands/CommandParameter.cs b/src/Discord.Net.Commands/CommandParameter.cs index f18b1a13b..f0b6f16b3 100644 --- a/src/Discord.Net.Commands/CommandParameter.cs +++ b/src/Discord.Net.Commands/CommandParameter.cs @@ -10,17 +10,17 @@ namespace Discord.Commands private readonly TypeReader _reader; public string Name { get; } - public string Description { get; } + public string Summary { get; } public bool IsOptional { get; } public bool IsRemainder { get; } public bool IsMultiple { get; } public Type Type { get; } internal object DefaultValue { get; } - public CommandParameter(string name, string description, Type type, TypeReader reader, bool isOptional, bool isRemainder, bool isMultiple, object defaultValue) + public CommandParameter(string name, string summary, Type type, TypeReader reader, bool isOptional, bool isRemainder, bool isMultiple, object defaultValue) { Name = name; - Description = description; + Summary = summary; Type = type; _reader = reader; IsOptional = isOptional; diff --git a/src/Discord.Net.Commands/Module.cs b/src/Discord.Net.Commands/Module.cs index 07feaeca2..326b7af9d 100644 --- a/src/Discord.Net.Commands/Module.cs +++ b/src/Discord.Net.Commands/Module.cs @@ -10,6 +10,8 @@ namespace Discord.Commands { public CommandService Service { get; } public string Name { get; } + public string Summary { get; } + public string Description { get; } public IEnumerable Commands { get; } internal object Instance { get; } @@ -21,6 +23,14 @@ namespace Discord.Commands Name = typeInfo.Name; Instance = instance; + var summaryAttr = typeInfo.GetCustomAttribute(); + if (summaryAttr != null) + Summary = summaryAttr.Text; + + var descriptionAttr = typeInfo.GetCustomAttribute(); + if (descriptionAttr != null) + Description = descriptionAttr.Text; + List commands = new List(); SearchClass(instance, commands, typeInfo, moduleAttr.Prefix ?? ""); Commands = commands;