Skip to content

Doc comment standardization #542

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

Merged
merged 11 commits into from
Feb 16, 2025
Merged
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
7 changes: 6 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ 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
main.tscn 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
84 changes: 44 additions & 40 deletions addons/mod_loader/api/config.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ const DEFAULT_CONFIG_NAME := "default"
## Creates a new configuration for a mod.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
## - [code]config_name[/code] ([String]): The name of the configuration.[br]
## - [code]config_data[/code] ([Dictionary]): The configuration data to be stored.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## - [param config_name] ([String]): The name of the configuration.[br]
## - [param config_data] ([Dictionary]): The configuration data to be stored.[br]
## [br]
## [b]Returns:[/b][br]
## - [ModConfig]: The created ModConfig object if successful, or null otherwise.
## - [ModConfig]: The created [ModConfig] object if successful, or null otherwise.
static func create_config(mod_id: String, config_name: String, config_data: Dictionary) -> ModConfig:
var default_config: ModConfig = get_default_config(mod_id)
if not default_config:
Expand Down Expand Up @@ -72,7 +72,7 @@ static func create_config(mod_id: String, config_name: String, config_data: Dict
## Updates an existing [ModConfig] object with new data and saves the config file.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]config[/code] ([ModConfig]): The [ModConfig] object to be updated.[br]
## - [param config] ([ModConfig]): The [ModConfig] object to be updated.[br]
## [br]
## [b]Returns:[/b][br]
## - [ModConfig]: The updated [ModConfig] object if successful, or null otherwise.
Expand Down Expand Up @@ -104,10 +104,10 @@ static func update_config(config: ModConfig) -> ModConfig:
## Deletes a [ModConfig] object and performs cleanup operations.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]config[/code] ([ModConfig]): The [ModConfig] object to be deleted.[br]
## - [param config] ([ModConfig]): The [ModConfig] object to be deleted.[br]
## [br]
## [b]Returns:[/b][br]
## - [code]bool[/code]: True if the deletion was successful, False otherwise.
## - [bool]: True if the deletion was successful, False otherwise.
static func delete_config(config: ModConfig) -> bool:
# Check if the config is the "default" config, which cannot be deleted
if config.name == DEFAULT_CONFIG_NAME:
Expand All @@ -131,15 +131,15 @@ static func delete_config(config: ModConfig) -> bool:
## Sets the current configuration of a mod to the specified configuration.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]config[/code] ([ModConfig]): The [ModConfig] object to be set as current config.
## - [param config] ([ModConfig]): The [ModConfig] object to be set as current config.
static func set_current_config(config: ModConfig) -> void:
ModLoaderStore.mod_data[config.mod_id].current_config = config


## Returns the schema for the specified mod id.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] (String): the ID of the mod.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## [br]
## [b]Returns:[/b][br]
## - A dictionary representing the schema for the mod's configuration file.
Expand All @@ -158,8 +158,8 @@ static func get_config_schema(mod_id: String) -> Dictionary:
## Retrieves the schema for a specific property key.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]config[/code] ([ModConfig]): The [ModConfig] object from which to retrieve the schema.[br]
## - [code]prop[/code] ([String]): The property key for which to retrieve the schema.[br]
## - [param config] ([ModConfig]): The [ModConfig] object from which to retrieve the schema.[br]
## - [param prop] ([String]): The property key for which to retrieve the schema.[br]
## [br]
## [b]Returns:[/b][br]
## - [Dictionary]: The schema dictionary for the specified property.
Expand All @@ -182,16 +182,16 @@ static func get_schema_for_prop(config: ModConfig, prop: String) -> Dictionary:
return schema_for_prop


## Recursively traverses the schema dictionary based on the provided [code]prop_key_array[/code]
## and returns the corresponding schema for the target property.[br]
##[br]
## [b]Parameters:[/b][br]
## - [code]schema_prop[/code]: The current schema dictionary to traverse.[br]
## - [code]prop_key_array[/code]: An array containing the property keys representing the path to the target property.[br]
##[br]
## [b]Returns:[/b][br]
## The schema dictionary corresponding to the target property specified by the [code]prop_key_array[/code].[br]
## If the target property is not found, an empty dictionary is returned.
# Recursively traverses the schema dictionary based on the provided [code]prop_key_array[/code]
# and returns the corresponding schema for the target property.[br]
# [br]
# [b]Parameters:[/b][br]
# - [param schema_prop]: The current schema dictionary to traverse.[br]
# - [param prop_key_array]: An array containing the property keys representing the path to the target property.[br]
# [br]
# [b]Returns:[/b][br]
# - [Dictionary]: The schema dictionary corresponding to the target property specified by the [code]prop_key_array[/code].
# If the target property is not found, an empty dictionary is returned.
static func _traverse_schema(schema_prop: Dictionary, prop_key_array: Array) -> Dictionary:
# Return the current schema_prop if the prop_key_array is empty (reached the destination property)
if prop_key_array.is_empty():
Expand Down Expand Up @@ -219,7 +219,7 @@ static func _traverse_schema(schema_prop: Dictionary, prop_key_array: Array) ->
## Retrieves an Array of mods that have configuration files.[br]
## [br]
## [b]Returns:[/b][br]
## - An Array containing the mod data of mods that have configuration files.
## - [Array]: An Array containing the mod data of mods that have configuration files.
static func get_mods_with_config() -> Array:
# Create an empty array to store mods with configuration files
var mods_with_config := []
Expand All @@ -241,10 +241,10 @@ static func get_mods_with_config() -> Array:
## Retrieves the configurations dictionary for a given mod ID.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code]: The ID of the mod.[br]
## - [param mod_id]: The ID of the mod.[br]
## [br]
## [b]Returns:[/b][br]
## - A dictionary containing the configurations for the specified mod.
## - [Dictionary]: A dictionary containing the configurations for the specified mod.
## If the mod ID is invalid or no configurations are found, an empty dictionary is returned.
static func get_configs(mod_id: String) -> Dictionary:
# Check if the mod ID is invalid
Expand All @@ -265,11 +265,11 @@ static func get_configs(mod_id: String) -> Dictionary:
## Retrieves the configuration for a specific mod and configuration name.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
## - [code]config_name[/code] ([String]): The name of the configuration.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## - [param config_name] ([String]): The name of the configuration.[br]
## [br]
## [b]Returns:[/b][br]
## - The configuration as a [ModConfig] object or null if not found.
## - [ModConfig]: The configuration as a [ModConfig] object or null if not found.
static func get_config(mod_id: String, config_name: String) -> ModConfig:
var configs := get_configs(mod_id)

Expand All @@ -283,10 +283,10 @@ static func get_config(mod_id: String, config_name: String) -> ModConfig:
## Checks whether a mod has a current configuration set.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## [br]
## [b]Returns:[/b][br]
## - [code]bool[/code]: True if the mod has a current configuration, False otherwise.
## - [bool]: True if the mod has a current configuration, false otherwise.
static func has_current_config(mod_id: String) -> bool:
var mod_data := ModLoaderMod.get_mod_data(mod_id)
return not mod_data.current_config == null
Expand All @@ -295,11 +295,11 @@ static func has_current_config(mod_id: String) -> bool:
## Checks whether a mod has a configuration with the specified name.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
## - [code]config_name[/code] ([String]): The name of the configuration.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## - [param config_name] ([String]): The name of the configuration.[br]
## [br]
## [b]Returns:[/b][br]
## - [code]bool[/code]: True if the mod has a configuration with the specified name, False otherwise.
## - [bool]: True if the mod has a configuration with the specified name, False otherwise.
static func has_config(mod_id: String, config_name: String) -> bool:
var mod_data := ModLoaderMod.get_mod_data(mod_id)
return mod_data.configs.has(config_name)
Expand All @@ -308,10 +308,10 @@ static func has_config(mod_id: String, config_name: String) -> bool:
## Retrieves the default configuration for a specified mod ID.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code]: The ID of the mod.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## [br]
## [b]Returns:[/b][br]
## - The [ModConfig] object representing the default configuration for the specified mod.
## - [ModConfig]: The [ModConfig] object representing the default configuration for the specified mod.
## If the mod ID is invalid or no configuration is found, returns null.
static func get_default_config(mod_id: String) -> ModConfig:
return get_config(mod_id, DEFAULT_CONFIG_NAME)
Expand All @@ -320,10 +320,10 @@ static func get_default_config(mod_id: String) -> ModConfig:
## Retrieves the currently active configuration for a specific mod.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## [br]
## [b]Returns:[/b][br]
## - The configuration as a [ModConfig] object or [code]null[/code] if not found.
## - [ModConfig]: The configuration as a [ModConfig] object or [code]null[/code] if not found.
static func get_current_config(mod_id: String) -> ModConfig:
var current_config_name := get_current_config_name(mod_id)
var current_config: ModConfig
Expand All @@ -341,10 +341,10 @@ static func get_current_config(mod_id: String) -> ModConfig:
## Retrieves the name of the current configuration for a specific mod.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]mod_id[/code] ([String]): The ID of the mod.[br]
## - [param mod_id] ([String]): The ID of the mod.[br]
## [br]
## [b]Returns:[/b][br]
## - The currently active configuration name for the given mod id or an empty string if not found.
## - [String] The currently active configuration name for the given mod id or an empty string if not found.
static func get_current_config_name(mod_id: String) -> String:
# Check if user profile has been loaded
if not ModLoaderStore.current_user_profile or not ModLoaderStore.user_profiles.has(ModLoaderStore.current_user_profile.name):
Expand All @@ -369,7 +369,7 @@ static func get_current_config_name(mod_id: String) -> String:
## Refreshes the data of the provided configuration by reloading it from the config file.[br]
## [br]
## [b]Parameters:[/b][br]
## - [code]config[/code] ([ModConfig]): The [ModConfig] object whose data needs to be refreshed.[br]
## - [param config] ([ModConfig]): The [ModConfig] object whose data needs to be refreshed.[br]
## [br]
## [b]Returns:[/b][br]
## - [ModConfig]: The [ModConfig] object with refreshed data if successful, or the original object otherwise.
Expand All @@ -383,8 +383,12 @@ static func refresh_config_data(config: ModConfig) -> ModConfig:


## Iterates over all mods to refresh the data of their current configurations, if available.[br]
## Compares the previous configuration data with the refreshed data and emits the `current_config_changed` signal if changes are detected.[br]
## [br]
## [b]Returns:[/b][br]
## - No return value[br]
## [br]
## Compares the previous configuration data with the refreshed data and emits the [signal ModLoader.current_config_changed]
## signal if changes are detected.[br]
## This function ensures that any changes made to the configuration files outside the application
## are reflected within the application's runtime, allowing for dynamic updates without the need for a restart.
static func refresh_current_configs() -> void:
Expand Down
Loading