From 0c52467f3ffb6be5df1b8344d4506b7b42753ed6 Mon Sep 17 00:00:00 2001 From: Kevan Stannard Date: Mon, 4 Jan 2021 12:05:05 +1100 Subject: [PATCH 1/2] Add basic operators to the syntax widget --- misc_docs/syntax/operators_float_addition.mdx | 19 +++ misc_docs/syntax/operators_float_division.mdx | 19 +++ .../syntax/operators_float_multiplication.mdx | 19 +++ .../syntax/operators_float_subtraction.mdx | 19 +++ .../syntax/operators_integer_addition.mdx | 21 +++ .../syntax/operators_integer_division.mdx | 21 +++ .../operators_integer_multiplication.mdx | 19 +++ .../syntax/operators_integer_subtraction.mdx | 19 +++ .../syntax/operators_string_concatenation.mdx | 19 +++ src/components/SyntaxLookupWidget.js | 128 ++++++++++++++++++ src/components/SyntaxLookupWidget.res | 99 ++++++++++++++ 11 files changed, 402 insertions(+) create mode 100644 misc_docs/syntax/operators_float_addition.mdx create mode 100644 misc_docs/syntax/operators_float_division.mdx create mode 100644 misc_docs/syntax/operators_float_multiplication.mdx create mode 100644 misc_docs/syntax/operators_float_subtraction.mdx create mode 100644 misc_docs/syntax/operators_integer_addition.mdx create mode 100644 misc_docs/syntax/operators_integer_division.mdx create mode 100644 misc_docs/syntax/operators_integer_multiplication.mdx create mode 100644 misc_docs/syntax/operators_integer_subtraction.mdx create mode 100644 misc_docs/syntax/operators_string_concatenation.mdx diff --git a/misc_docs/syntax/operators_float_addition.mdx b/misc_docs/syntax/operators_float_addition.mdx new file mode 100644 index 000000000..0aff15095 --- /dev/null +++ b/misc_docs/syntax/operators_float_addition.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator performs *floating point* addition. + + + +```res +let result = 1.3 +. 0.5 +``` + +```js +var result = 1.3 + 0.5; +``` + + + +For adding *integers* see the `+` operator. diff --git a/misc_docs/syntax/operators_float_division.mdx b/misc_docs/syntax/operators_float_division.mdx new file mode 100644 index 000000000..47d1c5d99 --- /dev/null +++ b/misc_docs/syntax/operators_float_division.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator performs *floating point* division. + + + +```res +let result = 3.0 /. 2.5 +``` + +```js +var result = 3.0 / 2.5; +``` + + + +For dividing *integers* see the `/` operator. diff --git a/misc_docs/syntax/operators_float_multiplication.mdx b/misc_docs/syntax/operators_float_multiplication.mdx new file mode 100644 index 000000000..41a4da46c --- /dev/null +++ b/misc_docs/syntax/operators_float_multiplication.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator performs *floating point* multiplication. + + + +```res +let result = 1.5 *. 2.3 +``` + +```js +var result = 1.5 * 2.3; +``` + + + +For multiplying *integers* see the `*` operator. diff --git a/misc_docs/syntax/operators_float_subtraction.mdx b/misc_docs/syntax/operators_float_subtraction.mdx new file mode 100644 index 000000000..7577712ff --- /dev/null +++ b/misc_docs/syntax/operators_float_subtraction.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator performs *floating point* subtraction. + + + +```res +let result = 3.0 -. 2.5 +``` + +```js +var result = 3.0 - 2.5; +``` + + + +For subtracting *integers* see the `-` operator. diff --git a/misc_docs/syntax/operators_integer_addition.mdx b/misc_docs/syntax/operators_integer_addition.mdx new file mode 100644 index 000000000..657efb427 --- /dev/null +++ b/misc_docs/syntax/operators_integer_addition.mdx @@ -0,0 +1,21 @@ +--- +test: "foo" +--- + +This operator performs *integers* addition. + + + +```res +let result = 1 + 2 +``` + +```js +val result = 3; +``` + + + +For adding *floats* see the `+.` operator. + +For contatenating *strings* see the `++` operator. diff --git a/misc_docs/syntax/operators_integer_division.mdx b/misc_docs/syntax/operators_integer_division.mdx new file mode 100644 index 000000000..afacaa9f7 --- /dev/null +++ b/misc_docs/syntax/operators_integer_division.mdx @@ -0,0 +1,21 @@ +--- +test: "foo" +--- + +This operator performs *integer* division, with the result truncated to an integer value. + +If the second argument is *zero* then a `Division_by_zero` exception is thrown. Refer to the [Exception](/docs/manual/latest/exception) section for handling exceptions. + + + +```res +let result = 3 / 2 +``` + +```js +var result = 1; +``` + + + +For dividing *floats* see the `/.` operator. diff --git a/misc_docs/syntax/operators_integer_multiplication.mdx b/misc_docs/syntax/operators_integer_multiplication.mdx new file mode 100644 index 000000000..dd98c1941 --- /dev/null +++ b/misc_docs/syntax/operators_integer_multiplication.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator performs *integer* multiplication. + + + +```res +let result = 2 * 3 +``` + +```js +var result = 6; +``` + + + +For multiplying *floats* see the `*.` operator. diff --git a/misc_docs/syntax/operators_integer_subtraction.mdx b/misc_docs/syntax/operators_integer_subtraction.mdx new file mode 100644 index 000000000..2f1fca644 --- /dev/null +++ b/misc_docs/syntax/operators_integer_subtraction.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator performs *integer* subtraction. + + + +```res +let result = 3 - 2 +``` + +```js +var result = 1; +``` + + + +For subtracting *floats* see the `-.` operator. diff --git a/misc_docs/syntax/operators_string_concatenation.mdx b/misc_docs/syntax/operators_string_concatenation.mdx new file mode 100644 index 000000000..c73c70379 --- /dev/null +++ b/misc_docs/syntax/operators_string_concatenation.mdx @@ -0,0 +1,19 @@ +--- +test: "foo" +--- + +This operator concatenates two *strings* together. + + + +```res +let greetings = "Hello " ++ "world!" +``` + +```js +var greetings = "Hello world!"; +``` + + + + diff --git a/src/components/SyntaxLookupWidget.js b/src/components/SyntaxLookupWidget.js index 8ed53cbaf..c7e13ef05 100644 --- a/src/components/SyntaxLookupWidget.js +++ b/src/components/SyntaxLookupWidget.js @@ -14,6 +14,15 @@ import * as GithubSlugger from "github-slugger"; import Decorator_asMdx from "misc_docs/syntax/decorator_as.mdx"; import Decorator_moduleMdx from "misc_docs/syntax/decorator_module.mdx"; import Controlflow_ifelseMdx from "misc_docs/syntax/controlflow_ifelse.mdx"; +import Operators_float_additionMdx from "misc_docs/syntax/operators_float_addition.mdx"; +import Operators_float_divisionMdx from "misc_docs/syntax/operators_float_division.mdx"; +import Operators_integer_additionMdx from "misc_docs/syntax/operators_integer_addition.mdx"; +import Operators_integer_divisionMdx from "misc_docs/syntax/operators_integer_division.mdx"; +import Operators_float_subtractionMdx from "misc_docs/syntax/operators_float_subtraction.mdx"; +import Operators_integer_subtractionMdx from "misc_docs/syntax/operators_integer_subtraction.mdx"; +import Operators_float_multiplicationMdx from "misc_docs/syntax/operators_float_multiplication.mdx"; +import Operators_string_concatenationMdx from "misc_docs/syntax/operators_string_concatenation.mdx"; +import Operators_integer_multiplicationMdx from "misc_docs/syntax/operators_integer_multiplication.mdx"; var render = (function(c) { return React.createElement(c, {}); @@ -77,6 +86,125 @@ var allItems = [ summary: "This is an `uncurried` function.", category: /* Other */3, component: Controlflow_ifelseMdx + }, + { + id: "integer-addition", + keywords: [ + "plus", + "add", + "addition", + "sum", + "int", + "integer" + ], + name: "+", + summary: "This is the `integer addition` operator.", + category: /* Operators */2, + component: Operators_integer_additionMdx + }, + { + id: "integer-subtraction", + keywords: [ + "subtract", + "minus", + "subtraction", + "int", + "integer" + ], + name: "-", + summary: "This is the `integer subtraction` operator.", + category: /* Operators */2, + component: Operators_integer_subtractionMdx + }, + { + id: "integer-multiplication", + keywords: [ + "multiply", + "multiplication", + "int", + "integer" + ], + name: "*", + summary: "This is the `integer multiplication` operator.", + category: /* Operators */2, + component: Operators_integer_multiplicationMdx + }, + { + id: "integer-division", + keywords: [ + "divide", + "division", + "int", + "integer" + ], + name: "/", + summary: "This is the `integer division` operator.", + category: /* Operators */2, + component: Operators_integer_divisionMdx + }, + { + id: "float-addition", + keywords: [ + "plus", + "add", + "addition", + "sum", + "float" + ], + name: "+.", + summary: "This is the `floating point addition` operator.", + category: /* Operators */2, + component: Operators_float_additionMdx + }, + { + id: "float-subtraction", + keywords: [ + "subtract", + "minus", + "subtraction", + "float" + ], + name: "-.", + summary: "This is the `floating point subtraction` operator.", + category: /* Operators */2, + component: Operators_float_subtractionMdx + }, + { + id: "float-multiplication", + keywords: [ + "multiply", + "multiplication", + "float" + ], + name: "*.", + summary: "This is the `floating point multiplication` operator.", + category: /* Operators */2, + component: Operators_float_multiplicationMdx + }, + { + id: "float-division", + keywords: [ + "divide", + "division", + "float" + ], + name: "/.", + summary: "This is the `floating point division` operator.", + category: /* Operators */2, + component: Operators_float_divisionMdx + }, + { + id: "string-concatenation", + keywords: [ + "concat", + "concatenation", + "add", + "string" + ], + name: "++", + summary: "This is the `string concatenation` operator.", + category: /* Operators */2, + component: Operators_string_concatenationMdx } ]; diff --git a/src/components/SyntaxLookupWidget.res b/src/components/SyntaxLookupWidget.res index a884ebd9c..017110e1f 100644 --- a/src/components/SyntaxLookupWidget.res +++ b/src/components/SyntaxLookupWidget.res @@ -23,6 +23,33 @@ external decorator_as: MdxComp.t = "default" @module("misc_docs/syntax/controlflow_ifelse.mdx") external controlflow_ifelse: MdxComp.t = "default" +@module("misc_docs/syntax/operators_integer_addition.mdx") +external operators_integer_addition: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_integer_subtraction.mdx") +external operators_integer_subtraction: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_integer_multiplication.mdx") +external operators_integer_multiplication: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_integer_division.mdx") +external operators_integer_division: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_float_addition.mdx") +external operators_float_addition: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_float_subtraction.mdx") +external operators_float_subtraction: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_float_multiplication.mdx") +external operators_float_multiplication: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_float_division.mdx") +external operators_float_division: MdxComp.t = "default" + +@module("misc_docs/syntax/operators_string_concatenation.mdx") +external operators_string_concatenation: MdxComp.t = "default" + module Category = { type t = Decorators | ControlFlow | Operators | Other @@ -87,6 +114,78 @@ let allItems = [ category: Other, component: controlflow_ifelse, }, + { + id: "integer-addition", + keywords: ["plus", "add", "addition", "sum", "int", "integer"], + name: "+", + summary: "This is the `integer addition` operator.", + category: Operators, + component: operators_integer_addition, + }, + { + id: "integer-subtraction", + keywords: ["subtract", "minus", "subtraction", "int", "integer"], + name: "-", + summary: "This is the `integer subtraction` operator.", + category: Operators, + component: operators_integer_subtraction, + }, + { + id: "integer-multiplication", + keywords: ["multiply", "multiplication", "int", "integer"], + name: "*", + summary: "This is the `integer multiplication` operator.", + category: Operators, + component: operators_integer_multiplication, + }, + { + id: "integer-division", + keywords: ["divide", "division", "int", "integer"], + name: "/", + summary: "This is the `integer division` operator.", + category: Operators, + component: operators_integer_division, + }, + { + id: "float-addition", + keywords: ["plus", "add", "addition", "sum", "float"], + name: "+.", + summary: "This is the `floating point addition` operator.", + category: Operators, + component: operators_float_addition, + }, + { + id: "float-subtraction", + keywords: ["subtract", "minus", "subtraction", "float"], + name: "-.", + summary: "This is the `floating point subtraction` operator.", + category: Operators, + component: operators_float_subtraction, + }, + { + id: "float-multiplication", + keywords: ["multiply", "multiplication", "float"], + name: "*.", + summary: "This is the `floating point multiplication` operator.", + category: Operators, + component: operators_float_multiplication, + }, + { + id: "float-division", + keywords: ["divide", "division", "float"], + name: "/.", + summary: "This is the `floating point division` operator.", + category: Operators, + component: operators_float_division, + }, + { + id: "string-concatenation", + keywords: ["concat", "concatenation", "add", "string"], + name: "++", + summary: "This is the `string concatenation` operator.", + category: Operators, + component: operators_string_concatenation, + }, ] let fuseOpts = Fuse.Options.t( From 1da0c4a44eeda1bee139c452b935d127daf947ad Mon Sep 17 00:00:00 2001 From: Kevan Stannard Date: Mon, 4 Jan 2021 18:43:20 +1100 Subject: [PATCH 2/2] Add metadata to frontmatter --- misc_docs/syntax/operators_float_addition.mdx | 6 +++++- misc_docs/syntax/operators_float_division.mdx | 6 +++++- misc_docs/syntax/operators_float_multiplication.mdx | 6 +++++- misc_docs/syntax/operators_float_subtraction.mdx | 6 +++++- misc_docs/syntax/operators_integer_addition.mdx | 6 +++++- misc_docs/syntax/operators_integer_division.mdx | 6 +++++- misc_docs/syntax/operators_integer_multiplication.mdx | 6 +++++- misc_docs/syntax/operators_integer_subtraction.mdx | 6 +++++- misc_docs/syntax/operators_string_concatenation.mdx | 6 +++++- 9 files changed, 45 insertions(+), 9 deletions(-) diff --git a/misc_docs/syntax/operators_float_addition.mdx b/misc_docs/syntax/operators_float_addition.mdx index 0aff15095..27072c4d5 100644 --- a/misc_docs/syntax/operators_float_addition.mdx +++ b/misc_docs/syntax/operators_float_addition.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "float-addition" +keywords: ["plus", "add", "addition", "sum", "float"] +name: "+." +summary: "This is the `floating point addition` operator." +category: "operators" --- This operator performs *floating point* addition. diff --git a/misc_docs/syntax/operators_float_division.mdx b/misc_docs/syntax/operators_float_division.mdx index 47d1c5d99..899e0eac0 100644 --- a/misc_docs/syntax/operators_float_division.mdx +++ b/misc_docs/syntax/operators_float_division.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "float-division" +keywords: ["divide", "division", "float"] +name: "/." +summary: "This is the `floating point division` operator." +category: "operators" --- This operator performs *floating point* division. diff --git a/misc_docs/syntax/operators_float_multiplication.mdx b/misc_docs/syntax/operators_float_multiplication.mdx index 41a4da46c..391ad78da 100644 --- a/misc_docs/syntax/operators_float_multiplication.mdx +++ b/misc_docs/syntax/operators_float_multiplication.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "float-multiplication" +keywords: ["multiply", "multiplication", "float"] +name: "*." +summary: "This is the `floating point multiplication` operator." +category: "operators" --- This operator performs *floating point* multiplication. diff --git a/misc_docs/syntax/operators_float_subtraction.mdx b/misc_docs/syntax/operators_float_subtraction.mdx index 7577712ff..256754e2e 100644 --- a/misc_docs/syntax/operators_float_subtraction.mdx +++ b/misc_docs/syntax/operators_float_subtraction.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "float-subtraction" +keywords: ["subtract", "minus", "subtraction", "float"] +name: "-." +summary: "This is the `floating point subtraction` operator." +category: "operators" --- This operator performs *floating point* subtraction. diff --git a/misc_docs/syntax/operators_integer_addition.mdx b/misc_docs/syntax/operators_integer_addition.mdx index 657efb427..3d89ab707 100644 --- a/misc_docs/syntax/operators_integer_addition.mdx +++ b/misc_docs/syntax/operators_integer_addition.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "integer-addition" +keywords: ["plus", "add", "addition", "sum", "int", "integer"] +name: "+" +summary: "This is the `integer addition` operator." +category: "operators" --- This operator performs *integers* addition. diff --git a/misc_docs/syntax/operators_integer_division.mdx b/misc_docs/syntax/operators_integer_division.mdx index afacaa9f7..7e2670ed5 100644 --- a/misc_docs/syntax/operators_integer_division.mdx +++ b/misc_docs/syntax/operators_integer_division.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "integer-division" +keywords: ["divide", "division", "int", "integer"] +name: "/" +summary: "This is the `integer division` operator." +category: "operators" --- This operator performs *integer* division, with the result truncated to an integer value. diff --git a/misc_docs/syntax/operators_integer_multiplication.mdx b/misc_docs/syntax/operators_integer_multiplication.mdx index dd98c1941..4ea81b129 100644 --- a/misc_docs/syntax/operators_integer_multiplication.mdx +++ b/misc_docs/syntax/operators_integer_multiplication.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "integer-multiplication" +keywords: ["multiply", "multiplication", "int", "integer"] +name: "*" +summary: "This is the `integer multiplication` operator." +category: "operators" --- This operator performs *integer* multiplication. diff --git a/misc_docs/syntax/operators_integer_subtraction.mdx b/misc_docs/syntax/operators_integer_subtraction.mdx index 2f1fca644..1a090e6dc 100644 --- a/misc_docs/syntax/operators_integer_subtraction.mdx +++ b/misc_docs/syntax/operators_integer_subtraction.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "integer-subtraction" +keywords: ["subtract", "minus", "subtraction", "int", "integer"] +name: "-" +summary: "This is the `integer subtraction` operator." +category: "operators" --- This operator performs *integer* subtraction. diff --git a/misc_docs/syntax/operators_string_concatenation.mdx b/misc_docs/syntax/operators_string_concatenation.mdx index c73c70379..0d6b49ac8 100644 --- a/misc_docs/syntax/operators_string_concatenation.mdx +++ b/misc_docs/syntax/operators_string_concatenation.mdx @@ -1,5 +1,9 @@ --- -test: "foo" +id: "string-concatenation" +keywords: ["concat", "concatenation", "add", "string"] +name: "++" +summary: "This is the `string concatenation` operator." +category: "operators" --- This operator concatenates two *strings* together.