diff --git a/apps/jsii-docgen/src/docgen/view/wing-filters.ts b/apps/jsii-docgen/src/docgen/view/wing-filters.ts index 143af2a9156..44d34271085 100644 --- a/apps/jsii-docgen/src/docgen/view/wing-filters.ts +++ b/apps/jsii-docgen/src/docgen/view/wing-filters.ts @@ -6,6 +6,8 @@ export const VISIBLE_SUBMODULES = [ "util", "redis", "http", + "math", + "regex", ]; export const HIDDEN_METHODS = ["toString", "toJSON", "bind"]; export const HIDDEN_PROPS = ["node", "display"]; diff --git a/docs/docs/04-standard-library/07-math/_category_.yml b/docs/docs/04-standard-library/07-math/_category_.yml new file mode 100644 index 00000000000..32e397260de --- /dev/null +++ b/docs/docs/04-standard-library/07-math/_category_.yml @@ -0,0 +1,3 @@ +label: Math +collapsible: true +collapsed: true diff --git a/docs/docs/04-standard-library/07-math/api-reference.md b/docs/docs/04-standard-library/07-math/api-reference.md new file mode 100644 index 00000000000..57be91c9734 --- /dev/null +++ b/docs/docs/04-standard-library/07-math/api-reference.md @@ -0,0 +1,772 @@ +--- +title: API reference +id: api-reference +description: Wing standard library API reference for the math module +keywords: [Wing sdk, sdk, Wing API Reference] +hide_title: true +sidebar_position: 100 +--- + + + +# API Reference + + +## Classes + +### Math + +Utility class for mathematical operations. + + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| abs | Returns the absolute value of a number. | +| acos | Returns the inverse cosine (in radians) of a number. | +| acot | Calculates the inverse cotangent (acot) of a number. | +| acsc | Calculates the inverse cosecant (acsc) of a number. | +| arithmeticMean | Calculates the mean value of an array of numbers. | +| asec | Calculates the inverse secant (asec) of a number. | +| asin | Returns the inverse sine (in radians) of a number. | +| atan | Returns the inverse tangent (in radians) of a number. | +| atan2 | Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.atan2(y, x). | +| ceil | Returns the smallest integer greater than or equal to a given number. | +| combinations | Calculates the number of combinations for choosing r items from a total of n items. | +| cos | Returns the cosine of a number in radians. | +| cot | Calculates the cotangent of an angle (in radians). | +| csc | Calculates the cosecant of an angle (in radians). | +| degreesToRadians | Convert degrees to radians. | +| factorial | Calculates the factorial of a given number. | +| fibonacci | Calculates the nth Fibonacci number. | +| floor | Returns the largest integer less than or equal to a given number. | +| geometricMean | Calculates the geometric mean of an array of numbers. | +| harmonicMean | Calculates the harmonic mean of an array of numbers. | +| hypot | Calculate the length of the vector from the origin to the point given by the coordinates. | +| isPrime | Checks if a number is prime. | +| max | Returns the maximum value from an array of numbers. | +| median | Calculates the median value of an array of numbers. | +| min | Returns the minimum value from an array of numbers. | +| mode | Calculates the mode values of an array of numbers. | +| radiansToDegrees | Convert radians to degrees. | +| random | Generates a pseudo-random number between 0 and max (default of 1). | +| round | Rounds the given number to the nearest integer. | +| sec | Calculates the secant of an angle (in radians). | +| sin | Returns the sine of a number in radians. | +| sqrt | Returns the square root of a number. | +| tan | Returns the tangent of a number in radians. | + +--- + +##### `abs` + +```wing +bring math; + +math.abs(value: num); +``` + +Returns the absolute value of a number. + +###### `value`Required + +- *Type:* num + +The input number. + +--- + +##### `acos` + +```wing +bring math; + +math.acos(value: num); +``` + +Returns the inverse cosine (in radians) of a number. + +###### `value`Required + +- *Type:* num + +A number between -1 and 1, inclusive, representing the angle's cosine value. + +--- + +##### `acot` + +```wing +bring math; + +math.acot(value: num); +``` + +Calculates the inverse cotangent (acot) of a number. + +###### `value`Required + +- *Type:* num + +A number representing the cotangent value. + +--- + +##### `acsc` + +```wing +bring math; + +math.acsc(value: num); +``` + +Calculates the inverse cosecant (acsc) of a number. + +###### `value`Required + +- *Type:* num + +A number equal or greater than |1|, representing the cosecant value. + +--- + +##### `arithmeticMean` + +```wing +bring math; + +math.arithmeticMean(arr: MutArray); +``` + +Calculates the mean value of an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `asec` + +```wing +bring math; + +math.asec(value: num); +``` + +Calculates the inverse secant (asec) of a number. + +###### `value`Required + +- *Type:* num + +A number equal or greater than |1|, representing the secant value. + +--- + +##### `asin` + +```wing +bring math; + +math.asin(value: num); +``` + +Returns the inverse sine (in radians) of a number. + +###### `value`Required + +- *Type:* num + +A number between -1 and 1, inclusive, representing the angle's sine value. + +--- + +##### `atan` + +```wing +bring math; + +math.atan(value: num); +``` + +Returns the inverse tangent (in radians) of a number. + +###### `value`Required + +- *Type:* num + +A number. + +--- + +##### `atan2` + +```wing +bring math; + +math.atan2(y: num, x: num); +``` + +Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y), for Math.atan2(y, x). + +###### `y`Required + +- *Type:* num + +The y coordinate of the point. + +--- + +###### `x`Required + +- *Type:* num + +The x coordinate of the point. + +--- + +##### `ceil` + +```wing +bring math; + +math.ceil(value: num); +``` + +Returns the smallest integer greater than or equal to a given number. + +###### `value`Required + +- *Type:* num + +The input number. + +--- + +##### `combinations` + +```wing +bring math; + +math.combinations(n: num, r: num); +``` + +Calculates the number of combinations for choosing r items from a total of n items. + +###### `n`Required + +- *Type:* num + +The total number of items. + +--- + +###### `r`Required + +- *Type:* num + +The number of items to be chosen. + +--- + +##### `cos` + +```wing +bring math; + +math.cos(value: num); +``` + +Returns the cosine of a number in radians. + +###### `value`Required + +- *Type:* num + +A number representing an angle in radians. + +--- + +##### `cot` + +```wing +bring math; + +math.cot(value: num); +``` + +Calculates the cotangent of an angle (in radians). + +###### `value`Required + +- *Type:* num + +The angle in radians. + +--- + +##### `csc` + +```wing +bring math; + +math.csc(value: num); +``` + +Calculates the cosecant of an angle (in radians). + +###### `value`Required + +- *Type:* num + +The angle in radians. + +--- + +##### `degreesToRadians` + +```wing +bring math; + +math.degreesToRadians(degrees: num); +``` + +Convert degrees to radians. + +###### `degrees`Required + +- *Type:* num + +Degree value. + +--- + +##### `factorial` + +```wing +bring math; + +math.factorial(n: num); +``` + +Calculates the factorial of a given number. + +###### `n`Required + +- *Type:* num + +The number to calculate the factorial for. + +--- + +##### `fibonacci` + +```wing +bring math; + +math.fibonacci(n: num); +``` + +Calculates the nth Fibonacci number. + +###### `n`Required + +- *Type:* num + +The position of the Fibonacci number to calculate. + +--- + +##### `floor` + +```wing +bring math; + +math.floor(value: num); +``` + +Returns the largest integer less than or equal to a given number. + +###### `value`Required + +- *Type:* num + +The input number. + +--- + +##### `geometricMean` + +```wing +bring math; + +math.geometricMean(arr: MutArray); +``` + +Calculates the geometric mean of an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `harmonicMean` + +```wing +bring math; + +math.harmonicMean(arr: MutArray); +``` + +Calculates the harmonic mean of an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `hypot` + +```wing +bring math; + +math.hypot(coordinates: MutArray); +``` + +Calculate the length of the vector from the origin to the point given by the coordinates. + +###### `coordinates`Required + +- *Type:* MutArray<num> + +Array of coordinates. + +--- + +##### `isPrime` + +```wing +bring math; + +math.isPrime(n: num); +``` + +Checks if a number is prime. + +###### `n`Required + +- *Type:* num + +The number to check for primality. + +--- + +##### `max` + +```wing +bring math; + +math.max(arr: MutArray); +``` + +Returns the maximum value from an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `median` + +```wing +bring math; + +math.median(arr: MutArray); +``` + +Calculates the median value of an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `min` + +```wing +bring math; + +math.min(arr: MutArray); +``` + +Returns the minimum value from an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `mode` + +```wing +bring math; + +math.mode(arr: MutArray); +``` + +Calculates the mode values of an array of numbers. + +###### `arr`Required + +- *Type:* MutArray<num> + +The array of numbers. + +--- + +##### `radiansToDegrees` + +```wing +bring math; + +math.radiansToDegrees(radians: num); +``` + +Convert radians to degrees. + +###### `radians`Required + +- *Type:* num + +Radians value. + +--- + +##### `random` + +```wing +bring math; + +math.random(max?: num); +``` + +Generates a pseudo-random number between 0 and max (default of 1). + +###### `max`Optional + +- *Type:* num + +The maximum value of the random number. + +--- + +##### `round` + +```wing +bring math; + +math.round(value: num, options?: RoundingOptions); +``` + +Rounds the given number to the nearest integer. + +###### `value`Required + +- *Type:* num + +The number to be rounded. + +--- + +###### `options`Optional + +- *Type:* RoundingOptions + +--- + +##### `sec` + +```wing +bring math; + +math.sec(value: num); +``` + +Calculates the secant of an angle (in radians). + +###### `value`Required + +- *Type:* num + +The angle in radians. + +--- + +##### `sin` + +```wing +bring math; + +math.sin(value: num); +``` + +Returns the sine of a number in radians. + +###### `value`Required + +- *Type:* num + +A number representing an angle in radians. + +--- + +##### `sqrt` + +```wing +bring math; + +math.sqrt(value: num); +``` + +Returns the square root of a number. + +###### `value`Required + +- *Type:* num + +A number greater than or equal to 0. + +--- + +##### `tan` + +```wing +bring math; + +math.tan(value: num); +``` + +Returns the tangent of a number in radians. + +###### `value`Required + +- *Type:* num + +A number representing an angle in radians. + +--- + + +#### Constants + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| E | num | Euler's number, a mathematical constant approximately equal to 2.71828. | +| INF | num | Positive infinity constant. | +| PI | num | The mathematical constant representing the ratio of a circle's circumference to its diameter. | +| TAU | num | The mathematical constant representing the ratio of a circle's circumference to the radius. | + +--- + +##### `E`Required + +```wing +E: num; +``` + +- *Type:* num + +Euler's number, a mathematical constant approximately equal to 2.71828. + +--- + +##### `INF`Required + +```wing +INF: num; +``` + +- *Type:* num + +Positive infinity constant. + +--- + +##### `PI`Required + +```wing +PI: num; +``` + +- *Type:* num + +The mathematical constant representing the ratio of a circle's circumference to its diameter. + +--- + +##### `TAU`Required + +```wing +TAU: num; +``` + +- *Type:* num + +The mathematical constant representing the ratio of a circle's circumference to the radius. + +--- + +## Structs + +### RoundingOptions + +Options for rounding a number. + +#### Initializer + +```wing +bring math; + +let RoundingOptions = math.RoundingOptions{ ... }; +``` + +#### Properties + +| **Name** | **Type** | **Description** | +| --- | --- | --- | +| decimalPlaces | num | The number of decimal places to round to. | + +--- + +##### `decimalPlaces`Optional + +```wing +decimalPlaces: num; +``` + +- *Type:* num + +The number of decimal places to round to. + +--- + + diff --git a/docs/docs/04-standard-library/08-regex/_category_.yml b/docs/docs/04-standard-library/08-regex/_category_.yml new file mode 100644 index 00000000000..f3dc604db2f --- /dev/null +++ b/docs/docs/04-standard-library/08-regex/_category_.yml @@ -0,0 +1,3 @@ +label: Regular expressions +collapsible: true +collapsed: true diff --git a/docs/docs/04-standard-library/08-regex/api-reference.md b/docs/docs/04-standard-library/08-regex/api-reference.md new file mode 100644 index 00000000000..98ef5aee74c --- /dev/null +++ b/docs/docs/04-standard-library/08-regex/api-reference.md @@ -0,0 +1,59 @@ +--- +title: API reference +id: api-reference +description: Wing standard library API reference for the regex module +keywords: [Wing sdk, sdk, Wing API Reference] +hide_title: true +sidebar_position: 100 +--- + + + +# API Reference + + +## Classes + +### Regex + +Regex utilities and functions. + + +#### Static Functions + +| **Name** | **Description** | +| --- | --- | +| match | Check if a regex pattern is matched by a given string. | + +--- + +##### `match` + +```wing +bring regex; + +regex.match(pattern: str, text: str); +``` + +Check if a regex pattern is matched by a given string. + +###### `pattern`Required + +- *Type:* str + +regex pattern. + +--- + +###### `text`Required + +- *Type:* str + +given input string. + +--- + + + + + diff --git a/libs/wingsdk/.projen/tasks.json b/libs/wingsdk/.projen/tasks.json index 31a4f654668..a502985c507 100644 --- a/libs/wingsdk/.projen/tasks.json +++ b/libs/wingsdk/.projen/tasks.json @@ -183,6 +183,30 @@ { "exec": "cat API.md >> ../../docs/docs/04-standard-library/06-ex/api-reference.md" }, + { + "exec": "jsii-docgen -o API.md -l wing --submodule math" + }, + { + "exec": "mkdir -p ../../docs/docs/04-standard-library/07-math" + }, + { + "exec": "echo '---\ntitle: API reference\nid: api-reference\ndescription: Wing standard library API reference for the math module\nkeywords: [Wing sdk, sdk, Wing API Reference]\nhide_title: true\nsidebar_position: 100\n---\n\n\n' > ../../docs/docs/04-standard-library/07-math/api-reference.md" + }, + { + "exec": "cat API.md >> ../../docs/docs/04-standard-library/07-math/api-reference.md" + }, + { + "exec": "jsii-docgen -o API.md -l wing --submodule regex" + }, + { + "exec": "mkdir -p ../../docs/docs/04-standard-library/08-regex" + }, + { + "exec": "echo '---\ntitle: API reference\nid: api-reference\ndescription: Wing standard library API reference for the regex module\nkeywords: [Wing sdk, sdk, Wing API Reference]\nhide_title: true\nsidebar_position: 100\n---\n\n\n' > ../../docs/docs/04-standard-library/08-regex/api-reference.md" + }, + { + "exec": "cat API.md >> ../../docs/docs/04-standard-library/08-regex/api-reference.md" + }, { "exec": "jsii-docgen -o API.md -l wing --submodule cloud/api" }, diff --git a/libs/wingsdk/.projenrc.ts b/libs/wingsdk/.projenrc.ts index 21660e15749..5a55ee67b77 100644 --- a/libs/wingsdk/.projenrc.ts +++ b/libs/wingsdk/.projenrc.ts @@ -33,7 +33,7 @@ const CDKTF_PROVIDERS = [ "google@~>4.63.1", ]; -const PUBLIC_MODULES = ["std", "http", "util", "aws", "ex"]; +const PUBLIC_MODULES = ["std", "http", "util", "aws", "ex", "math", "regex"]; const CLOUD_DOCS_PREFIX = "../../docs/docs/04-standard-library/01-cloud/";