Skip to content

docs: 📝 Rewrote API class comments #279

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 6 commits into from
Jun 17, 2023
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
5 changes: 2 additions & 3 deletions addons/mod_loader/api/config.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# This Class provides functionality for working with per-mod Configurations.
class_name ModLoaderConfig
extends Object


# This Class provides functionality for working with per-mod Configurations.

const LOG_NAME := "ModLoader:Config"
const DEFAULT_CONFIG_NAME := "default"

Expand Down Expand Up @@ -163,7 +162,7 @@ static func get_config_schema(mod_id: String) -> Dictionary:
# Parameters:
# - config (ModConfig): The ModConfig object from which to retrieve the schema.
# - prop (String): The property key for which to retrieve the schema.
# e.g. "parentProp.childProp.nthChildProp" || "propKey"
# e.g. `parentProp.childProp.nthChildProp` || `propKey`
#
# Returns:
# - Dictionary: The schema dictionary for the specified property.
Expand Down
40 changes: 32 additions & 8 deletions addons/mod_loader/api/deprecated.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# API methods for deprecating funcs. Can be used by mods with public APIs.
class_name ModLoaderDeprecated
extends Node

# API methods for deprecating funcs. Can be used by mods with public APIs.

const LOG_NAME := "ModLoader:Deprecated"


# A method has changed its name/class
# Marks a method that has changed its name or class.
#
# Parameters:
# - old_method (String): The name of the deprecated method.
# - new_method (String): The name of the new method to use.
# - since_version (String): The version number from which the method has been deprecated.
# - show_removal_note (bool): (optional) If true, includes a note about future removal of the old method. Default is true.
#
# Returns: void
static func deprecated_changed(old_method: String, new_method: String, since_version: String, show_removal_note: bool = true) -> void:
_deprecated_log(str(
"DEPRECATED: ",
Expand All @@ -16,8 +24,15 @@ static func deprecated_changed(old_method: String, new_method: String, since_ver
))


# A method has been entirely removed, with no replacement
# (should never be needed but good to have just in case)
# Marks a method that has been entirely removed, with no replacement.
# Note: This should rarely be needed but is included for completeness.
#
# Parameters:
# - old_method (String): The name of the removed method.
# - since_version (String): The version number from which the method has been deprecated.
# - show_removal_note (bool): (optional) If true, includes a note about future removal of the old method. Default is true.
#
# Returns: void
static func deprecated_removed(old_method: String, since_version: String, show_removal_note: bool = true) -> void:
_deprecated_log(str(
"DEPRECATED: ",
Expand All @@ -27,15 +42,24 @@ static func deprecated_removed(old_method: String, since_version: String, show_r
))


# Freeform deprecation message.
# Allows you to add a deprecation comment without specifying the old/new method
# Marks a method with a freeform deprecation message.
#
# Parameters:
# - msg (String): The deprecation message.
# - since_version (String): (optional) The version number from which the deprecation applies.
#
# Returns: void
static func deprecated_message(msg: String, since_version: String = "") -> void:
var since_text := " (since version %s)" % since_version if since_version else ""
_deprecated_log(str("DEPRECATED: ", msg, since_text))


# Internal func for logging with support to trigger warnings instead of fatal
# errors
# Internal function for logging deprecation messages with support to trigger warnings instead of fatal errors.
#
# Parameters:
# - msg (String): The deprecation message.
#
# Returns: void
static func _deprecated_log(msg: String) -> void:
if ModLoaderStore.ml_options.ignore_deprecated_errors or OS.has_feature("standalone"):
ModLoaderLog.warning(msg, LOG_NAME)
Expand Down
Loading