Skip to content

Commit 1c6dee7

Browse files
simplify method help info
1 parent 4790dbe commit 1c6dee7

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

Code/Plugin/Commands/HelpSystem/DocsProvider.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,14 @@ private static string GetEnum(Type enumType)
343343
return
344344
$"""
345345
Enum {enumType.Name} has the following values:
346-
{string.Join("\n", Enum.GetValues(enumType).Cast<Enum>().Select(e => $"> {e}"))}
346+
{string.Join("\n", Enum.GetValues(enumType)
347+
.Cast<Enum>()
348+
.Where(e => {
349+
Type type = e.GetType();
350+
FieldInfo field = type.GetField(e.ToString());
351+
return field.GetCustomAttribute<ObsoleteAttribute>() == null;
352+
})
353+
.Select(e => $"> {e}"))}
347354
""";
348355
}
349356

@@ -464,22 +471,20 @@ private static string GetMethodHelp(Method method)
464471
}
465472

466473
sb.AppendLine();
467-
sb.AppendLine($"This method returns a {typeReturn}, which can be saved or used directly. ");
474+
sb.AppendLine($"Returns a {typeReturn}.");
468475
break;
469476
}
470477
case IReturningMethod<CollectionValue>:
471478
sb.AppendLine();
472-
sb.AppendLine("This method returns a collection of values, which can be saved or used directly.");
479+
sb.AppendLine("Returns a collection of values.");
473480
break;
474481
case IReturningMethod<PlayerValue>:
475482
sb.AppendLine();
476-
sb.AppendLine("This method returns players, which can be saved or used directly.");
483+
sb.AppendLine("Returns a player value.");
477484
break;
478485
case IReferenceReturningMethod refMethod:
479486
sb.AppendLine();
480-
sb.AppendLine($"This method returns a reference to {refMethod.ReturnType.GetAccurateName()} object, which can be saved or used directly.\n" +
481-
$"References represent an object which cannot be fully represented in text.\n" +
482-
$"If you wish to use that reference further, find methods supporting references of this type.");
487+
sb.AppendLine($"Returns a reference to {refMethod.ReturnType.GetAccurateName()} object.");
483488
break;
484489
case IReturningMethod ret:
485490
{
@@ -528,6 +533,7 @@ private static string GetMethodHelp(Method method)
528533
if (argument.DefaultValue is { } defVal)
529534
{
530535
sb.AppendLine($" - Default value/behavior: {defVal.StringRep ?? defVal.Value?.ToString() ?? "<unknown>"}");
536+
sb.AppendLine(" (if needed, you can skip providing this argument by using '_' character)");
531537
}
532538

533539
if (argument.ConsumesRemainingValues)

0 commit comments

Comments
 (0)