Extensibility¶
ILLEX was designed to be easily extensible, allowing you to add new handlers for custom functionality.
Creating New Handlers¶
from illex.decorators.function import function
@function("my_function")
def my_function(text):
return text.upper()
Creating Math Functions¶
from illex.decorators.function import function
from illex.decorators.math import math_function
@function("square")
@math_function
def square(value):
return value ** 2
Decorator Structure¶
ILLEX provides several decorators to simplify extension:
@function(tag)
: Registers a function with a specific tag@math_function
: Processes mathematical expressions using SymPy@multi_param_function
: Handles functions that accept multiple parameters
Full Example¶
from illex.decorators.function import function
from illex.decorators.multi_param import multi_param_function
@function("greeting")
@multi_param_function
def greeting(name, message="Hello"):
return f"{message}, {name}!"
# Usage:
# :greeting("John") # Result: "Hello, John!"
# :greeting("John", "Welcome") # Result: "Welcome, John!"
Modifying Existing Handlers¶
from illex.registry import registry
# Replace an existing handler
registry["uppercase"] = my_new_uppercase_function
Automatic Extension Loading¶
ILLEX automatically looks for extensions in the illex_extensions
directory in the current working directory, making it easy to distribute plugins.