Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc comment standardization #542

Draft
wants to merge 9 commits into
base: 4.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ test/ export-ignore

# Files not required by AssetLib downloads (provided via download for manual installers)
addons/mod_loader/vendor/ export-ignore
addons/mod_loader/mod_loader_setup.gd export-ignore
addons/mod_loader/mod_loader_setup.gd export-ignore

# Used during docs generation, but not relevant for addon users
project.godot export-ignore
icon.png export-ignore
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

.godot
.godot/
# IDEs
.idea
.vscode
Expand Down
32 changes: 23 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contributing Guidelines

Thank you for considering contributing to our project! We welcome contributions from everyone. Before getting started, please take a moment to read our guidelines.
Thank you for considering contributing to our project! We welcome contributions from everyone.
Before getting started, please take a moment to read our guidelines.

## How to contribute

Expand All @@ -12,11 +13,14 @@ Thank you for considering contributing to our project! We welcome contributions

## Reporting bugs

If you find a bug, please let us know by opening an issue. Be as detailed as possible when describing the issue, including any steps to reproduce the bug. If applicable, please provide your `modloader.log` file from the `user://` (Godot app_userdata) folder. This file contains valuable information that can help us identify the cause of the issue.
If you find a bug, please let us know by opening an issue. Be as detailed as possible when describing the issue,
including any steps to reproduce the bug. If applicable, please provide your `modloader.log` file from the `user://`
(Godot app_userdata) folder. This file contains valuable information that can help us identify the cause of the issue.

## Suggesting features

If you have an idea for a new feature or improvement, please open an issue to discuss it. We welcome all suggestions and will consider them carefully.
If you have an idea for a new feature or improvement, please open an issue to discuss it.
We welcome all suggestions and will consider them carefully.

## Coding style

Expand All @@ -27,17 +31,22 @@ In addition, please follow these guidelines:
### Naming Convention
- Prefix local (private) to file vars / functions with `_`
- Prefix classes that should only be used by the ModLoader with `_`
- If a method is in a non-prefixed class and ModLoader Internal, but used outside of the private scope, prefix with `_`, use it outside the scope, but add a comment why it was used there
- If a method is in a non-prefixed class and ModLoader Internal, but used outside the private scope, prefix with `_`,
use it outside the scope, but add a comment why it was used there

Reasoning:
1. Underscore methods/vars should only be used within the same file
2. Most classes should not be used by mods, only by the ModLoader. if they are prefixed with an underscore, no mod should access them and we are free to change the internal structure without breaking mods and needing deprecations
3. In some cases we need to use private methods outside of their file (`_rotate_log_file` for example) and the class is a public one (`ModLoaderLog` here). Since the method should not be accessible to mods, we are using a "private" method outside of its scope here - and that needs an explanation
2. Most classes should not be used by mods, only by the ModLoader. if they are prefixed with an underscore,
no mod should access them and we are free to change the internal structure without breaking mods and needing deprecations
3. In some cases we need to use private methods outside their file (`_rotate_log_file` for example) and the class is a
public one (`ModLoaderLog` here). Since the method should not be accessible to mods, we are using a "private" method outside
its scope here - and that needs an explanation

### String Standards
- Double quotes over single quotes: `"string"`, not `'string'`
- Quote escaping over single quotes : `"\"hello\" world"`, not `'"hello" world'`
- Format strings over string concatenation and `str()`: `"hello %s!" % place`, not `"hello " + place + "!"`, not `str("hello", place)`. Except for very simple cases/single concatenation: `"hello " + place`, not `"hello %s" % place`
- Format strings over string concatenation and `str()`: `"hello %s!" % place`, not `"hello " + place + "!"`,
not `str("hello", place)`. Except for very simple cases/single concatenation: `"hello " + place`, not `"hello %s" % place`
- split long strings into shorter ones with string concatenation `"" + "" + ...`, not `str("", "", ...)`
```gdscript
ModLoaderLog.info(
Expand All @@ -49,8 +58,13 @@ ModLoaderLog.info(

## Documentation

The documentation for this project is located in the repository's wiki. Please make sure to update the relevant documentation pages when making changes to the code. If you're not sure what needs to be updated, please ask in your pull request or issue.
*Note that you will mostly edit the [Upcoming Features](https://github.com/GodotModding/godot-mod-loader/wiki/Upcoming-Features) page, where all changes to the dev branch are documented until they become part of the next major update.*
The documentation for this project is kept in the [gmlwiki repository](https://github.com/GodotModding/gmlwiki).
Please make sure to update the relevant documentation pages when making changes to the code. If you're not sure what
needs to be updated, please ask in your pull request or issue.
*Note that you will mostly edit the [Upcoming Features](https://github.com/GodotModding/godot-mod-loader/wiki/Upcoming-Features)
page, where all changes to the dev branch are documented until they become part of the next major update.*



## Communicating over Discord
We use Discord for communication and collaboration. You can join our Discord server at [discord.godotmodding.com](https://discord.godotmodding.com). Please use appropriate channels for your discussions and keep conversations respectful and on-topic.
Expand Down
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# GDScript Mod Loader

<img alt="Godot Modding Logo" src="https://github.com/KANAjetzt/godot-mod-loader/assets/41547570/44df4f33-883e-4c1d-baac-06f87b0656f4" width="256" />
<img alt="Godot Modding Logo" src="icon.png" width="256" />

</div>

Expand Down Expand Up @@ -37,16 +37,7 @@ Importantly, it provides methods to change existing scripts, scenes, and resourc

## Getting Started

You can find detailed documentation, for game and mod developers, on the [Wiki](https://wiki.godotmodding.com/) page.

1. Add ModLoader to your [Godot Project](https://wiki.godotmodding.com/guides/integration/godot_project_setup/)
*Details on how to set up the Mod Loader in your Godot Project, relevant for game and mod developers.*
2. Create your [Mod Structure](https://wiki.godotmodding.com/guides/modding/mod_structure/)
*The mods loaded by the Mod Loader must follow a specific directory structure.*
3. Create your [Mod Files](https://wiki.godotmodding.com/guides/modding/mod_files/)
*Learn about the required files to create your first mod.*
4. Use the [API Methods](https://wiki.godotmodding.com/api/mod_loader_api/)
*A list of all available API Methods.*
You can find quickstart guides and more on the [Wiki](https://wiki.godotmodding.com/).

## Godot Version
The current version of the Mod Loader is developed for Godot 3.
Expand Down
5 changes: 4 additions & 1 deletion addons/mod_loader/api/deprecated.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ static func deprecated_changed(old_method: String, new_method: String, since_ver


## Marks a method that has been entirely removed, with no replacement.[br]
## Note: This should rarely be needed but is included for completeness.[br]
## ===[br]
## [b]Note:[/b][br]
## This should rarely be needed but is included for completeness.[br]
## ===[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]old_method[/code] ([String]): The name of the removed method.[br]
Expand Down
31 changes: 15 additions & 16 deletions addons/mod_loader/api/log.gd
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ class ModLoaderLogEntry:


## Logs the error in red and a stack trace. Prefixed FATAL-ERROR.[br]
## [br]
## [i]Note: Stops the execution in editor[/i][br]
## Always logged.[br]
## ===[br]
## [b]Note:[color=bug "Breakpoint"][/color][/b][br]
## Stops execution in the editor, use this when something really needs to be fixed.[br]
## ===[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as an error.[br]
Expand All @@ -139,8 +142,7 @@ static func fatal(message: String, mod_name: String, only_once := false) -> void


## Logs the message and pushes an error. Prefixed ERROR.[br]
## [br]
## [i]Note: Always logged[/i][br]
## Always logged.[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as an error.[br]
Expand All @@ -153,8 +155,7 @@ static func error(message: String, mod_name: String, only_once := false) -> void


## Logs the message and pushes a warning. Prefixed WARNING.[br]
## [br]
## [i]Note: Logged with verbosity level at or above warning (-v).[/i][br]
## Logged with verbosity level at or above warning ([code]-v[/code] or [code]--log-warning[/code]).[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as a warning.[br]
Expand All @@ -167,8 +168,7 @@ static func warning(message: String, mod_name: String, only_once := false) -> vo


## Logs the message. Prefixed INFO.[br]
## [br]
## [i]Note: Logged with verbosity level at or above info (-vv).[/i][br]
## Logged with verbosity level at or above info ([code]-vv[/code] or [code]--log-info[/code]).[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as an information.[br]
Expand All @@ -181,8 +181,7 @@ static func info(message: String, mod_name: String, only_once := false) -> void:


## Logs the message. Prefixed SUCCESS.[br]
## [br]
## [i]Note: Logged with verbosity level at or above info (-vv).[/i][br]
## Logged with verbosity level at or above info ([code]-vv[/code] or [code]--log-info[/code]).[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as a success.[br]
Expand All @@ -195,8 +194,7 @@ static func success(message: String, mod_name: String, only_once := false) -> vo


## Logs the message. Prefixed DEBUG.[br]
## [br]
## [i]Note: Logged with verbosity level at or above debug (-vvv).[/i][br]
## Logged with verbosity level at or above debug ([code]-vvv[/code] or [code]--log-debug[/code]).[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as a debug.[br]
Expand All @@ -209,9 +207,11 @@ static func debug(message: String, mod_name: String, only_once := false) -> void


## Logs the message. Prefixed HINT and highligted.[br]
## [br]
## [i]Note: Logged with verbosity level at or above debug (-vvv) and in the editor only. Not written to mod loader log.[/i][br]
## Logged with verbosity level at or above debug ([code]-vvv[/code] or [code]--log-debug[/code]) and in the editor only. Not written to mod loader log.[br]
## ===[br]
## [b]Note:[/b][br]
## Use this to help other developers debug issues by giving them error-specific hints.[br]
## ===[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as a debug.[br]
Expand All @@ -224,8 +224,7 @@ static func hint(message: String, mod_name: String, only_once := false) -> void:


## Logs the message formatted with [method JSON.print]. Prefixed DEBUG.[br]
## [br]
## [i]Note: Logged with verbosity level at or above debug (-vvv).[/i] [br]
## Logged with verbosity level at or above debug ([code]-vvv[/code] or [code]--log-debug[/code]).[br]
## [br]
## [b]Parameters:[/b][br]
## [param message] ([String]): The message to be logged as a debug.[br]
Expand Down
30 changes: 20 additions & 10 deletions addons/mod_loader/api/mod.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ const LOG_NAME := "ModLoader:Mod"
## Example: [code]"MOD/extensions/singletons/utils.gd"[/code][br]
## Inside the extender script, include [code]extends {target}[/code] where [code]{target}[/code] is the vanilla path.[br]
## Example: [code]extends "res://singletons/utils.gd"[/code].[br]
##
## [b]Note:[/b] Your extender script doesn't have to follow the same directory path as the vanilla file,
## ===[br]
## [b]Note:[/b][br]
## Your extender script doesn't have to follow the same directory path as the vanilla file,
## but it's good practice to do so.[br]
##
## [br][b]Parameters:[/b][br]
## ===[br]
## [br]
## [b]Parameters:[/b][br]
## - [param child_script_path] ([String]): The path to the mod's extender script.[br]
##
## [br][b]Returns:[/b] [code]void[/code][br]
Expand Down Expand Up @@ -193,8 +195,11 @@ static func add_hook(mod_callable: Callable, script_path: String, method_name: S
##
## Format: [code]{ "base": "ParentClass", "class": "ClassName", "language": "GDScript", "path": "res://path/class_name.gd" }[/code][br]
##
## [b]Note:[/b] You can find these easily in the project.godot file under `_global_script_classes`
## ===[br]
## [b]Tip:[/b][color=tip][/color][br]
## You can find these easily in the project.godot file under `_global_script_classes`[br]
## (but you should only include classes belonging to your mod)[br]
## ===[br]
##
## [br][b]Parameters:[/b][br]
## - [param new_global_classes] ([Array]): An array of class definitions to be registered.[br]
Expand All @@ -205,11 +210,13 @@ static func register_global_classes_from_array(new_global_classes: Array) -> voi
var _savecustom_error: int = ProjectSettings.save_custom(_ModLoaderPath.get_override_path())


## Adds a translation file.
## [br]
## Adds a translation file.[br]
## [br]
## [i]Note: The translation file should have been created in Godot already,
## such as when importing a CSV file. The translation file should be in the format [code]mytranslation.en.translation[/code].[/i][br]
## ===[br]
## [b]Note:[/b][br]
## The [code].translation[/code] file should have been created by the Godot editor already, usually when importing a CSV file.
## The translation file should named [code]name.langcode.translation[/code] -> [code]mytranslation.en.translation[/code].[br]
## ===[br]
##
## [br][b]Parameters:[/b][br]
## - [param resource_path] ([String]): The path to the translation resource file.[br]
Expand All @@ -229,7 +236,10 @@ static func add_translation(resource_path: String) -> void:



## [i]Note: This function requires Godot 4.3 or higher.[/i][br]
## ===[br]
## [b]Note:[/b][color=abstract "Version"][/color][br]
## This function requires Godot 4.3 or higher.[br]
## ===[br]
## [br]
## Refreshes a specific scene by marking it for refresh.[br]
## [br]
Expand Down
4 changes: 2 additions & 2 deletions addons/mod_loader/internal/path.gd
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static func get_file_paths_in_dir(src_dir_path: String) -> Array:
var dir := DirAccess.open(src_dir_path)

if dir == null:
ModLoaderLog.error("Encountered an error (%s) when attempting to open a directory, with the path: %s" % [DirAccess.get_open_error(), src_dir_path], LOG_NAME)
ModLoaderLog.error("Encountered an error (%s) when attempting to open a directory, with the path: %s" % [error_string(DirAccess.get_open_error()), src_dir_path], LOG_NAME)
return file_paths

dir.list_dir_begin() # TODOGODOT4 fill missing arguments https://github.com/godotengine/godot/pull/40547
Expand All @@ -146,7 +146,7 @@ static func get_dir_paths_in_dir(src_dir_path: String) -> Array:
var dir := DirAccess.open(src_dir_path)

if dir == null:
ModLoaderLog.error("Encountered an error (%s) when attempting to open a directory, with the path: %s" % [DirAccess.get_open_error(), src_dir_path], LOG_NAME)
ModLoaderLog.error("Encountered an error (%s) when attempting to open a directory, with the path: %s" % [error_string(DirAccess.get_open_error()), src_dir_path], LOG_NAME)
return dir_paths

dir.list_dir_begin()
Expand Down
1 change: 0 additions & 1 deletion addons/mod_loader/mod_loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ func _ready():
# Variables initialized with an autoload property cause errors otherwise.
if ModLoaderStore.any_mod_hooked:
if OS.has_feature("editor"):
_ModLoaderModHookPacker.start()
ModLoaderLog.hint("No mod hooks .zip will be created when running from the editor.", LOG_NAME)
ModLoaderLog.hint("You can test mod hooks by running the preprocessor on the vanilla scripts once.", LOG_NAME)
ModLoaderLog.hint("We recommend using the Mod Loader Dev Tool to process scripts in the editor. You can find it here: %s" % ModLoaderStore.MOD_LOADER_DEV_TOOL_URL, LOG_NAME)
Expand Down
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions icon.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://b3e7kl6hdpe55"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
9 changes: 9 additions & 0 deletions main.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[gd_scene format=3 uid="uid://w21r4jjqs6a0"]

[node name="Main" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
37 changes: 37 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=5

[application]

config/name="Godot Mod Loader"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.3")
config/icon="res://icon.png"

[autoload]

ModLoaderStore="*res://addons/mod_loader/mod_loader_store.gd"
ModLoader="*res://addons/mod_loader/mod_loader.gd"

[editor_plugins]

enabled=PackedStringArray()

[godots]

version_hint=""

[gui]

common/drop_mouse_on_gui_input_disabled=true

[physics]

common/enable_pause_aware_picking=true