Establishing XMLDoc conventions

This commit is contained in:
Jordan Wages 2026-06-24 13:10:29 -05:00
commit 4072775c09
2 changed files with 53 additions and 3 deletions

View file

@ -8,14 +8,33 @@ using CSMic.StandardLibrary.Functions.Random;
namespace CSMic.StandardLibrary namespace CSMic.StandardLibrary
{ {
/// <summary>
/// Offers helper methods to initialize a <see cref="InputInterpreter"/> with collections of
/// standard mathematical expressions and constants.
/// </summary>
public static class Initializer public static class Initializer
{ {
public static void InitializeAll(InputInterpreter interpreter) /// <summary> Initializes all standard library functions and constants. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
/// <seealso cref="InitializeAllFunctions(InputInterpreter)"/>
/// <seealso cref="InitializeConstants(InputInterpreter)"/>
///
/// ### <param name="interpreter"> The interpreter to hydrate. </param>
public static void InitializeAll(InputInterpreter inputInterpreter)
{ {
InitializeAllFunctions(interpreter); if (inputInterpreter == null)
InitializeConstants(interpreter); {
throw new ArgumentNullException("inputInterpreter", "Cannot initialize a null InputInterpreter.");
}
InitializeAllFunctions(inputInterpreter);
InitializeConstants(inputInterpreter);
} }
/// <summary> Initializes all standard library functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeAllFunctions(InputInterpreter inputInterpreter) public static void InitializeAllFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -31,6 +50,9 @@ namespace CSMic.StandardLibrary
InitializeRandomFunctions(inputInterpreter); InitializeRandomFunctions(inputInterpreter);
} }
/// <summary> Initializes the base standard library functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeBaseFunctions(InputInterpreter inputInterpreter) public static void InitializeBaseFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -44,6 +66,9 @@ namespace CSMic.StandardLibrary
inputInterpreter.RegisterFunction(new Max()); inputInterpreter.RegisterFunction(new Max());
} }
/// <summary> Initializes the angle-related functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeAngleFunctions(InputInterpreter inputInterpreter) public static void InitializeAngleFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -56,6 +81,9 @@ namespace CSMic.StandardLibrary
inputInterpreter.RegisterFunction(new WrapAngle()); inputInterpreter.RegisterFunction(new WrapAngle());
} }
/// <summary> Initializes the number theory functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeNumberTheoryFunctions(InputInterpreter inputInterpreter) public static void InitializeNumberTheoryFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -70,6 +98,9 @@ namespace CSMic.StandardLibrary
inputInterpreter.RegisterFunction(new LeastCommonMultiple()); inputInterpreter.RegisterFunction(new LeastCommonMultiple());
} }
/// <summary> Initializes the rounding functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeRoundingFunctions(InputInterpreter inputInterpreter) public static void InitializeRoundingFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -85,6 +116,9 @@ namespace CSMic.StandardLibrary
inputInterpreter.RegisterFunction(new Clamp()); inputInterpreter.RegisterFunction(new Clamp());
} }
/// <summary> Initializes the trigonometry functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeTrigonometryFunctions(InputInterpreter inputInterpreter) public static void InitializeTrigonometryFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -110,6 +144,9 @@ namespace CSMic.StandardLibrary
inputInterpreter.RegisterFunction(new Atanh()); inputInterpreter.RegisterFunction(new Atanh());
} }
/// <summary> Initializes the psuedorandom generation and statistics functions. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeRandomFunctions(InputInterpreter inputInterpreter) public static void InitializeRandomFunctions(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)
@ -125,6 +162,9 @@ namespace CSMic.StandardLibrary
inputInterpreter.RegisterFunction(new RandomNormalSpread()); inputInterpreter.RegisterFunction(new RandomNormalSpread());
} }
/// <summary> Initializes the standard library constants. </summary>
/// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
/// <param name="inputInterpreter"> The input interpreter. </param>
public static void InitializeConstants(InputInterpreter inputInterpreter) public static void InitializeConstants(InputInterpreter inputInterpreter)
{ {
if (inputInterpreter == null) if (inputInterpreter == null)

View file

@ -3,11 +3,16 @@
namespace CSMic.StandardLibrary.Functions namespace CSMic.StandardLibrary.Functions
{ {
/// <summary> A function that returns <c>1</c> if the expression is positive and <c>-1</c> if it is negative. </summary>
public class Sign : FunctionBase, ICodedFunction public class Sign : FunctionBase, ICodedFunction
{ {
/// <summary> (Immutable) The return value representing "positive". </summary>
private const decimal POSITIVE = 1; private const decimal POSITIVE = 1;
/// <summary> (Immutable) The return value representing "negative". </summary>
private const decimal NEGATIVE = -1; private const decimal NEGATIVE = -1;
/// <summary> Gets the name of the function. </summary>
/// <value> sign. </value>
public string Name public string Name
{ {
get get
@ -16,6 +21,8 @@ namespace CSMic.StandardLibrary.Functions
} }
} }
/// <summary> Gets the expected arguments. </summary>
/// <value> The expected arguments. </value>
public override IEnumerable<FunctionArgument> ExpectedArguments public override IEnumerable<FunctionArgument> ExpectedArguments
{ {
get get
@ -24,6 +31,9 @@ namespace CSMic.StandardLibrary.Functions
} }
} }
/// <summary> Executes the function with the given arguments. </summary>
/// <param name="args"> A variable-length parameters list containing arguments. </param>
/// <returns> A <see cref="FunctionValue"/> representing the result of the function execution. </returns>
public FunctionValue Execute(params FunctionArgument[] args) public FunctionValue Execute(params FunctionArgument[] args)
{ {
return base.Execute(args, (_args) => return base.Execute(args, (_args) =>