| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Hertzole.ScriptableValues.Generator; |
| | | 4 | | |
| | | 5 | | internal static class DocumentationHelper |
| | | 6 | | { |
| | | 7 | | public const string EVENT_SENDER = "The object that sent the event."; |
| | | 8 | | public const string EVENT_ARGS = "The event arguments."; |
| | | 9 | | |
| | | 10 | | public const string COLLECTION_ARGS = "The collection changed arguments."; |
| | | 11 | | |
| | | 12 | | public const string POOL_ACTION = "The change that just happened on the pool."; |
| | | 13 | | public const string POOL_ITEM = "The item that was affected by the change."; |
| | | 14 | | |
| | | 15 | | public const string SUBSCRIBED_MASK_SUMMARY = "/// <summary>A bitmask of all the possible subscribed callbacks.</sum |
| | | 16 | | |
| | | 17 | | public static ReadOnlySpan<char> GetMethodCallbackDescription(in ReadOnlySpan<char> name, in CallbackType callbackTy |
| | | 18 | | { |
| | 48 | 19 | | using (ArrayBuilder<char> builder = new ArrayBuilder<char>(64)) |
| | | 20 | | { |
| | 48 | 21 | | builder.AddRange("/// <summary>Called when <see cref=\""); |
| | 48 | 22 | | builder.AddRange(name); |
| | 48 | 23 | | builder.AddRange("\" /> is "); |
| | 48 | 24 | | if (callbackType == CallbackType.Event) |
| | | 25 | | { |
| | 0 | 26 | | builder.AddRange("invoked"); |
| | | 27 | | } |
| | 48 | 28 | | else if (callbackType == CallbackType.Value && (flags & CallbackFlags.PreInvoke) != 0) |
| | | 29 | | { |
| | 16 | 30 | | builder.AddRange("changing"); |
| | | 31 | | } |
| | | 32 | | else |
| | | 33 | | { |
| | 32 | 34 | | builder.AddRange("changed"); |
| | | 35 | | } |
| | | 36 | | |
| | 48 | 37 | | builder.AddRange(".</summary>"); |
| | 48 | 38 | | return builder.AsSpan(); |
| | | 39 | | } |
| | 48 | 40 | | } |
| | | 41 | | |
| | | 42 | | public static string GetOldValueDescription(in CallbackFlags flags) |
| | | 43 | | { |
| | 48 | 44 | | if ((flags & CallbackFlags.PreInvoke) != 0) |
| | | 45 | | { |
| | 16 | 46 | | return "The previous value that is being replaced."; |
| | | 47 | | } |
| | | 48 | | |
| | 32 | 49 | | if ((flags & CallbackFlags.PostInvoke) != 0) |
| | | 50 | | { |
| | 32 | 51 | | return "The previous value that was replaced."; |
| | | 52 | | } |
| | | 53 | | |
| | 0 | 54 | | return $"UNKNOWN FLAG VALUE: {flags}"; |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | public static string GetNewValueDescription(in CallbackFlags flags) |
| | | 58 | | { |
| | 48 | 59 | | if ((flags & CallbackFlags.PreInvoke) != 0) |
| | | 60 | | { |
| | 16 | 61 | | return "The new value being set."; |
| | | 62 | | } |
| | | 63 | | |
| | 32 | 64 | | if ((flags & CallbackFlags.PostInvoke) != 0) |
| | | 65 | | { |
| | 32 | 66 | | return "The new value that was set."; |
| | | 67 | | } |
| | | 68 | | |
| | 0 | 69 | | return $"UNKNOWN FLAG VALUE: {flags}"; |
| | | 70 | | } |
| | | 71 | | } |