-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from QuVery/generic-rules
Add support for generic rules
- Loading branch information
Showing
11 changed files
with
112 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Naming Convention | ||
|
||
Cheching namin convention is a generic rule. These rules are needed to run on all kinds of assets. Either it is a 3D model, a texture, a sound, etc. The rules are the same for all assets. | ||
Directories are not considered as assets but it is easy to define rules for them too. | ||
|
||
To design a generic rule for checking the naming convention of assets in QuVery, we have to consider the following points: | ||
|
||
- The name of the asset should be unique. | ||
- The name of the asset should be descriptive. | ||
- The name of the asset should be consistent. | ||
|
||
### Unique | ||
|
||
This means that the name of the asset should be unique in the project. This is important because it will be used to identify the asset in the project. | ||
|
||
### Descriptive | ||
|
||
The name of the asset should be able to describe the asset. By reading the name of the asset, we should be able to know what the asset is about and what it is used for. | ||
|
||
### Consistent | ||
|
||
The name of the asset should be consistent with the other assets in the project. This means that the name of the asset should follow the same naming convention as the other assets in the project. It will make it easier to find the asset in the project. | ||
|
||
## Some Naming Convention Examples | ||
### UE5 Naming Convention | ||
|
||
[Recommended Asset Naming Convention in UE5](https://docs.unrealengine.com/5.3/en-US/recommended-asset-naming-conventions-in-unreal-engine-projects/) | ||
[UE5 Style](https://github.com/Allar/ue5-style-guide) | ||
|
||
[AssetTypePrefix]_[AssetName]_[Descriptor]_[OptionalVariantLetterOrNumber] | ||
|
||
Eample: | ||
- A static mesh for a table in the game would be named SM_Table_Wood_01 | ||
- A diffuse/albedo/color texture for a table in the game would be named T_Table_Wood_01_D | ||
- If we have multiple versions of the metal door with different diffuse textures, we would name those T_Door_Metal_01_D, T_Door_Metal_02_D, etc. | ||
- A no | ||
|
||
### Unity Naming Convention by Justin Wasilenko | ||
|
||
[Unity Asset Naming Conventions](https://github.com/justinwasilenko/Unity-Style-Guide?tab=readme-ov-file#4-asset-naming-conventions) | ||
|
||
[AssetTypePrefix]_[AssetName]_[Variant]_[Suffix] | ||
|
||
Example: | ||
- A static mesh for a table in the game would be named SM_Table_Wood_01 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import os | ||
import re | ||
|
||
# imports here | ||
|
||
# necessary for the rule to be loaded | ||
|
||
|
||
RULE_NAME = "NamingConvention" | ||
|
||
def process(input): | ||
""" | ||
This function is called for each file that is checked. The input is the file path. | ||
the function should return an empty json if the file is valid and a json object with the status and required information. | ||
status can be one of the following: "error", "warning", "info" | ||
example: | ||
for a single error: {"status": "error" , "details": {"object_name": "error message"}} | ||
for multiple errors: {"status": "error" , "details": {"object_name": "error message", "object_name2": "error message2"}} | ||
for a single warning: {"status": "warning" , "details": {"object_name": "warning message"}} | ||
for info: {"status": "info" , "details": {"object_name": "info message"}} | ||
""" | ||
|
||
result_json = {"status": "error"} # default status is info | ||
details_json = {} | ||
|
||
# the naming convention for files is: [AssetTypePrefix]_[AssetName]_[Descriptor]_[OptionalVariantLetterOrNumber] | ||
# AssetTypePrefix is mandatory and can be like T for texture, SM for static mesh, A for audio clip, etc. | ||
# AssetName is mandatory and can be like: Tree, Rock, etc. | ||
# Descriptor is optional. like _Blue or _Zombie | ||
# OptionalVariantLetterOrNumber is optional. like _a or _1 or _a1 | ||
|
||
match_regex = r"^[A-Z]{1,2}_[a-zA-Z0-9]+(_[a-zA-Z0-9]+)*(_[a-zA-Z0-9]+)*(_[a-zA-Z0-9]+)*$" | ||
file_name_without_extension = os.path.splitext(os.path.basename(input))[0] | ||
if not re.match(match_regex, file_name_without_extension): | ||
details_json[file_name_without_extension] = f"File name '{file_name_without_extension}' does not match the naming convention: [AssetTypePrefix]_[AssetName]_[Descriptor]_[OptionalVariantLetterOrNumber]" | ||
|
||
if details_json != {}: | ||
result_json["details"] = details_json | ||
return result_json | ||
else: | ||
return {} |
Empty file.
Empty file.