Skip to content

Commit 7beb3bc

Browse files
authored
Merge pull request #10 from AutSoft/develop
Develop
2 parents cd40a40 + 8c02d1e commit 7beb3bc

File tree

11 files changed

+92
-13
lines changed

11 files changed

+92
-13
lines changed

.nuke/build.schema.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"enum": [
7878
"BuildDocs",
7979
"Compile",
80-
"CreateGithubRelease",
8180
"CreateMetadata",
8281
"GenerateUnitySolution",
8382
"Restore",
@@ -94,7 +93,6 @@
9493
"enum": [
9594
"BuildDocs",
9695
"Compile",
97-
"CreateGithubRelease",
9896
"CreateMetadata",
9997
"GenerateUnitySolution",
10098
"Restore",

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 1.0.1
2+
- Add documentation comments
3+
14
# 1.0.0
25
- Version bump, same as 0.5.0 after manual testing
36

UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/Extensions/EnumerableExtensions.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,5 @@ private static bool IsMultiple<T>(this IEnumerable<T> source)
1919
var enumerator = source.GetEnumerator();
2020
return enumerator.MoveNext() && enumerator.MoveNext();
2121
}
22-
23-
public static void ForEach<T>(this IEnumerable<T> enumerable, Action<T> action)
24-
{
25-
foreach (var item in enumerable)
26-
{
27-
action(item);
28-
}
29-
}
3022
}
3123
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
namespace AutSoft.UnityResourceGenerator.Editor.Generation
22
{
3+
/// <summary>
4+
/// Used by the file generation pipeline.
5+
/// Implement this interface to create a piece of string that you want to see in the generated file
6+
/// </summary>
37
public interface IModuleGenerator
48
{
9+
/// <summary>
10+
/// Create a piece of code as part of the generated file.
11+
/// Could be static methods, properties, fields or inner classes
12+
/// </summary>
13+
/// <param name="context">User configured settings and logger</param>
14+
/// <returns>Generated code module</returns>
515
string Generate(ResourceContext context);
616
}
717
}
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
using System.Collections.Generic;
1+
using AutSoft.UnityResourceGenerator.Editor.Generation.Modules;
2+
using System.Collections.Generic;
23

34
namespace AutSoft.UnityResourceGenerator.Editor.Generation
45
{
6+
/// <summary>
7+
/// Data used by <see cref="AllResources"/>
8+
/// </summary>
59
public interface IResourceData
610
{
11+
/// <summary>
12+
/// Name of the generated class
13+
/// </summary>
714
string ClassName { get; }
15+
16+
/// <summary>
17+
/// File extensions to look for.
18+
/// </summary>
819
IReadOnlyList<string> FileExtensions { get; }
20+
21+
/// <summary>
22+
/// Data type returned by Resources.Load
23+
/// </summary>
924
string DataType { get; }
1025
}
1126
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
11
namespace AutSoft.UnityResourceGenerator.Editor.Generation
22
{
3+
/// <summary>
4+
/// Implement this interface to do post processing of the generated file
5+
/// </summary>
36
public interface IResourcePostProcessor
47
{
8+
/// <summary>
9+
/// Priority during post processing. Higher number means it will run before others
10+
/// </summary>
511
int PostProcessPriority { get; }
12+
13+
/// <summary>
14+
/// Does post processing of the generated file
15+
/// </summary>
16+
/// <param name="context">User configured settings and logger</param>
17+
/// <param name="resourceFileContent">The current state of the generated file</param>
18+
/// <returns>The next state of the generated file</returns>
619
string PostProcess(ResourceContext context, string resourceFileContent);
720
}
821
}

UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/Modules/AllResources.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88

99
namespace AutSoft.UnityResourceGenerator.Editor.Generation.Modules
1010
{
11+
/// <summary>
12+
/// Generates code for all known and loadable Unity resource files.
13+
/// Each loadable type is produced as a static class.
14+
/// Also creates code for loading scenes
15+
/// </summary>
1116
public sealed class AllResources : IModuleGenerator
1217
{
1318
private static readonly Regex NonAlphaNumeric = new Regex(@"[^a-zA-Z0-9]", RegexOptions.Compiled, TimeSpan.FromSeconds(1));

UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/PostProcessors/RemoveDuplicateNewLines.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
namespace AutSoft.UnityResourceGenerator.Editor.Generation.PostProcessors
55
{
6+
/// <summary>
7+
/// Removes duplicate newlines
8+
/// </summary>
69
public sealed class RemoveDuplicateNewLines : IResourcePostProcessor
710
{
811
private static readonly Regex MultipleNewLines = new Regex(@"(?:\r\n|\r(?!\n)|(?!<\r)\n){2,}", RegexOptions.Compiled, TimeSpan.FromSeconds(10));

UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/ResourceContext.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
using System;
1+
using AutSoft.UnityResourceGenerator.Editor.Generation.Modules;
2+
using System;
23
using System.Collections.Generic;
34

45
namespace AutSoft.UnityResourceGenerator.Editor.Generation
56
{
7+
/// <summary>
8+
/// User defined settings and data and loggers
9+
/// </summary>
610
public sealed class ResourceContext
711
{
812
public ResourceContext
@@ -26,14 +30,45 @@ public ResourceContext
2630
Usings = usings;
2731
}
2832

33+
/// <summary>
34+
/// Full path to the Unity Assets folder
35+
/// </summary>
2936
public string AssetsFolder { get; }
37+
38+
/// <summary>
39+
/// User defined path to the desired relative folder from the <see cref="AssetsFolder"/>
40+
/// </summary>
3041
public string FolderPath { get; }
42+
43+
/// <summary>
44+
/// User defined namespace of the generated file
45+
/// </summary>
3146
public string BaseNamespace { get; }
47+
48+
/// <summary>
49+
/// User defined class name of the generated file
50+
/// </summary>
3251
public string ClassName { get; }
52+
53+
/// <summary>
54+
/// Info level logger
55+
/// </summary>
3356
public Action<string> Info { get; }
57+
58+
/// <summary>
59+
/// Error level logger
60+
/// </summary>
3461
public Action<string> Error { get; }
3562

63+
64+
/// <summary>
65+
/// Data used by <see cref="AllResources"/>
66+
/// </summary>
3667
public IReadOnlyList<IResourceData> Data { get; }
68+
69+
/// <summary>
70+
/// User defined custom usings
71+
/// </summary>
3772
public IReadOnlyList<string> Usings { get; }
3873
}
3974
}

UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator/Editor/Generation/ResourceFileGenerator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ public static class ResourceFileGenerator
1010
{
1111
private static readonly Regex NormalizedLineEndings = new Regex(@"\r\n|\n\r|\n|\r", RegexOptions.Compiled, TimeSpan.FromSeconds(10));
1212

13+
/// <summary>
14+
/// Main generator. Loads and calls all implementations of <see cref="IModuleGenerator"/> and <see cref="IResourcePostProcessor"/>
15+
/// </summary>
16+
/// <param name="context">Resource context from settings</param>
17+
/// <returns>The generated file content</returns>
1318
public static string CreateResourceFile(ResourceContext context)
1419
{
1520
// ReSharper disable once MissingIndent

0 commit comments

Comments
 (0)