diff --git a/.editorconfig b/.editorconfig index 7dee340d9..4b9ad97bc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ trim_trailing_whitespace = false indent_style = space indent_size = 2 -[mkdocs.yml] +[*.yml] indent_style = space indent_size = 2 diff --git a/_yaml/data-functions.yml b/_yaml/data-functions.yml new file mode 100644 index 000000000..77e8e30fb --- /dev/null +++ b/_yaml/data-functions.yml @@ -0,0 +1,17 @@ +df_string: + - funcName: hash + args: + - argName: algo + optional: true + longName: Algorithm + type: String + default: md5 + options: + - md5 + - base64 + - sha1 + returns: String + description: Returns a string hashed with the given algorithm. + - funcName: removeMarkdown + returns: String + description: Removes Markdown formatting from a string. diff --git a/docs/_extra/css/extra.css b/docs/_extra/css/extra.css index 90d59f251..2c3b8bfd0 100644 --- a/docs/_extra/css/extra.css +++ b/docs/_extra/css/extra.css @@ -25,6 +25,7 @@ --color-background-light: #f2f4f8; --color-foreground-base: #dbdfe7; + /* https://squidfunk.github.io/mkdocs-material/setup/changing-the-fonts/?h=font#additional-fonts */ --md-text-font: "Moderat-Regular-Web"; /* https://squidfunk.github.io/mkdocs-material/reference/admonitions/#custom-admonitions */ diff --git a/docs/_extra/css/macro-styles.css b/docs/_extra/css/macro-styles.css new file mode 100644 index 000000000..4f651609d --- /dev/null +++ b/docs/_extra/css/macro-styles.css @@ -0,0 +1,70 @@ +:root { + --color-red-600: #BF2F51; + --small-font: 0.6em; +} + +.dt-func-title-h3 { + font-size: 1em !important; + font-weight: 800 !important; +} + +.dt-func-title-h4 { + font-weight: 600; +} + +.dt-func-wrapper { + border-bottom: 1px solid var(--color-foreground-base); + margin-bottom: 2em; + padding: 1em; +} + +.dt-func-desc { + +} + +.dt-func-name { + font-weight: bold; + padding: 0.1em; + text-transform: lowercase; +} + +.dt-func-optional { + color: var(--color-red-600); + font-size: var(--small-font); + font-weight: bold; + padding: 0.1em; + text-transform: uppercase; +} + +.dt-func-options { + +} + +.dt-func-args { + border-top: 1px solid var(--color-foreground-base); +} + +.dt-func-header-link { + display: inline-block; + opacity: 0; +} + +.dt-func-header-link:hover, .dt-func-header-link:active, .dt-func-header-link:focus { + color: var(--md-typeset-a-color); + opacity: 1; + transition: color .25s,opacity 125ms; +} + +.dt-func-arg-name-anchor { + display: inline-block; + opacity: 0; +} + +.dt-func-arg-name-anchor:hover, .dt-func-arg-name-anchor:active, .dt-func-arg-name-anchor:focus { + color: var(--md-typeset-a-color); + opacity: 1; + transition: color .25s,opacity 125ms; +} + + + diff --git a/docs/_macros/data-functions.html b/docs/_macros/data-functions.html new file mode 100644 index 000000000..0baeb29ac --- /dev/null +++ b/docs/_macros/data-functions.html @@ -0,0 +1,28 @@ +[[% macro dataFunctions(funcName, returnType, description, funcArgs) %]] +
+

+ [[funcName]]([[% if funcArgs %]][[% for arg in funcArgs %]][[arg.argName]][[% if arg.optional %]]?[[% endif %]]: + [[arg.longName]][[ "," if not loop.last ]][[% endfor %]][[% endif %]]): + [[returnType]] + # +

+
+[[description]] +
+[[% if funcArgs %]] +

Function parameters

+ [[% for arg in funcArgs %]] +
+ [[arg.argName]][[% if arg.optional %]]Optional[[% else %]]Required[[% endif %]] +
[[% if arg.options %]] +

Default: [[ arg.default ]]

+

One of: [[% for option in arg.options %]] + [[option]][[ "," if not loop.last ]] + [[% endfor %]] +

+ [[% endif %]]
+
+[[% endfor %]] +[[% endif %]] +
+[[% endmacro %]] diff --git a/docs/code-examples/expressions/data-transformation-functions.md b/docs/code-examples/expressions/data-transformation-functions.md new file mode 100644 index 000000000..b25e970fc --- /dev/null +++ b/docs/code-examples/expressions/data-transformation-functions.md @@ -0,0 +1,29 @@ +--- +title: Data transformation functions +description: A reference document listing built-in convenience functions to support data transformation in expressions. +--- + +# Data transformation functions + +## Arrays + +## Dates + +## Numbers + +## Objects + +## Strings + +[[% import "_macros/data-functions.html" as dataFunctions %]] + +[[% for func in df_string %]] +[[ dataFunctions.dataFunctions(func.funcName, func.returns, func.description, func.args ) ]] +[[% endfor %]] + + + + + + + diff --git a/docs/code-examples/expressions/jmespath.md b/docs/code-examples/expressions/jmespath.md index b6437e87c..bb87fca76 100644 --- a/docs/code-examples/expressions/jmespath.md +++ b/docs/code-examples/expressions/jmespath.md @@ -218,10 +218,10 @@ Given this JSON from a webhook node: Use multiselect list to get the first and last names and create new lists containing both names: - +[[% raw %]] ```js {{$jmespath($json.body.people, "[].[first, last]")}} // Returns [["James","Green"],["Jacob","Jones"],["Jayden","Smith"]] ``` - +[[% endraw %]] diff --git a/mkdocs.yml b/mkdocs.yml index c1beb9d03..66d232262 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -39,6 +39,7 @@ extra: # https://squidfunk.github.io/mkdocs-material/customization/?h=#additional-css extra_css: - _extra/css/extra.css + - _extra/css/macro-styles.css # https://squidfunk.github.io/mkdocs-material/customization/?h=#additional-javascript extra_javascript: - _extra/javascript/extra.js @@ -84,6 +85,15 @@ plugins: - search # https://github.com/oprypin/mkdocs-literate-nav - literate-nav + # https://mkdocs-macros-plugin.readthedocs.io/en/latest/ + - macros: + # https://mkdocs-macros-plugin.readthedocs.io/en/latest/advanced/#including-external-yaml-files + include_yaml: + - _yaml/data-functions.yml + j2_block_start_string: '[[%' + j2_block_end_string: '%]]' + j2_variable_start_string: '[[' + j2_variable_end_string: ']]' # https://squidfunk.github.io/mkdocs-material/setup/setting-up-tags/ - tags: enabled: true @@ -153,11 +163,12 @@ nav: - (node-name).all: code-examples/methods-variables-examples/all.md - runIndex: code-examples/methods-variables-examples/run-index.md - workflow: code-examples/methods-variables-examples/workflow.md - - Expressions examples: + - Expressions: - code-examples/expressions/index.md - Date and time with Luxon: code-examples/expressions/luxon.md - JSON with JMESPath: code-examples/expressions/jmespath.md - - JavaScript examples: + - Data transformation functions: code-examples/expressions/data-transformation-functions.md + - JavaScript: - code-examples/javascript-functions/index.md - Date and time with Luxon: code-examples/javascript-functions/luxon.md - JSON with JMESPath: code-examples/javascript-functions/jmespath.md diff --git a/requirements.txt b/requirements.txt index 05c3ef2d0..6c32e85b0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ mkdocs-literate-nav==0.4.1 +mkdocs-macros-plugin==0.7.0 neoteroi-mkdocs==0.0.5