Skip to content

Commit

Permalink
docs: 📝 Rewrote API class comments (#279)
Browse files Browse the repository at this point in the history
* docs: 📝 moved class description above class_name

* docs: 📝 extended comments for docs

* docs: 📝 extended comments for docs in `ModLoaderLog`

* docs: 📝 extended comments for docs in `ModLoaderMod`

* docs: 📝 comments for docs in `ModLoaderUserProfile`

* docs: 📝 added backticks to example
  • Loading branch information
KANAjetzt authored Jun 17, 2023
1 parent 90334fc commit a01a703
Show file tree
Hide file tree
Showing 5 changed files with 363 additions and 64 deletions.
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

0 comments on commit a01a703

Please # to comment.