a little experiment with yaml and styles

This commit is contained in:
Deborah Barnard 2023-01-23 16:27:26 +00:00
parent bf8ea0063a
commit 3160631116
9 changed files with 162 additions and 5 deletions

View File

@ -11,7 +11,7 @@ trim_trailing_whitespace = false
indent_style = space
indent_size = 2
[mkdocs.yml]
[*.yml]
indent_style = space
indent_size = 2

17
_yaml/data-functions.yml Normal file
View File

@ -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.

View File

@ -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 */

View File

@ -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;
}

View File

@ -0,0 +1,28 @@
[[% macro dataFunctions(funcName, returnType, description, funcArgs) %]]
<div class="dt-func-wrapper" >
<h3 class="dt-func-title-h3" id="[[ funcName ]]">
[[funcName]]([[% if funcArgs %]][[% for arg in funcArgs %]][[arg.argName]][[% if arg.optional %]]?[[% endif %]]:
[[arg.longName]][[ "," if not loop.last ]][[% endfor %]][[% endif %]]):
[[returnType]]
<a class="dt-func-header-link" href="#[[ funcName ]]" title="Permanent link">#</a>
</h3>
<div class="dt-func-desc">
[[description]]
</div>
[[% if funcArgs %]]
<h4 class="dt-func-title-h4">Function parameters</h4>
[[% for arg in funcArgs %]]
<div class="dt-func-args">
<span class="dt-func-name" id="[[funcName]]-[[arg.argName]]">[[arg.argName]]</span><span class="dt-func-optional">[[% if arg.optional %]]Optional[[% else %]]Required[[% endif %]]</span><a class="dt-func-arg-name-anchor" href="#[[funcName]]-[[arg.argName]]"></a>
<div class="dt-func-options">[[% if arg.options %]]
<p>Default: <code>[[ arg.default ]]</code></p>
<p>One of: [[% for option in arg.options %]]
<code>[[option]]</code>[[ "," if not loop.last ]]
[[% endfor %]]
</p>
[[% endif %]]</div>
</div>
[[% endfor %]]
[[% endif %]]
</div>
[[% endmacro %]]

View File

@ -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 %]]

View File

@ -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 %]]

View File

@ -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

View File

@ -1,2 +1,3 @@
mkdocs-literate-nav==0.4.1
mkdocs-macros-plugin==0.7.0
neoteroi-mkdocs==0.0.5