2022-02-14 03:22:51 +01:00
|
|
|
let vers = (version).version
|
|
|
|
|
2022-03-03 01:55:03 +01:00
|
|
|
for command in ($scope.commands | where is_custom == false && is_extern == false) {
|
2022-02-14 03:22:51 +01:00
|
|
|
let top = $"---
|
|
|
|
title: ($command.command)
|
|
|
|
layout: command
|
|
|
|
version: ($vers)
|
|
|
|
---
|
|
|
|
|
|
|
|
($command.usage)
|
|
|
|
|
|
|
|
"
|
2022-02-21 14:38:15 +01:00
|
|
|
let sig = ($command.signature | each { |param|
|
2022-02-14 03:22:51 +01:00
|
|
|
if $param.parameter_type == "positional" {
|
|
|
|
$"('(')($param.parameter_name)(')')"
|
|
|
|
} else if $param.parameter_type == "switch" {
|
|
|
|
$"--($param.parameter_name)"
|
|
|
|
} else if $param.parameter_type == "named" {
|
|
|
|
$"--($param.parameter_name)"
|
|
|
|
} else if $param.parameter_type == "rest" {
|
|
|
|
$"...($param.parameter_name)"
|
|
|
|
}
|
|
|
|
} | str collect " ")
|
|
|
|
|
|
|
|
let signature = $"## Signature(char nl)(char nl)```> ($command.command) ($sig)```(char nl)(char nl)"
|
|
|
|
|
|
|
|
let params = ($command.signature | each { |param|
|
|
|
|
if $param.parameter_type == "positional" {
|
|
|
|
$" - `($param.parameter_name)`: ($param.description)"
|
|
|
|
} else if $param.parameter_type == "switch" {
|
|
|
|
$" - `--($param.parameter_name)`: ($param.description)"
|
|
|
|
} else if $param.parameter_type == "named" {
|
|
|
|
$" - `--($param.parameter_name) {($param.syntax_shape)}`: ($param.description)"
|
|
|
|
} else if $param.parameter_type == "rest" {
|
|
|
|
$" - `...($param.parameter_name)`: ($param.description)"
|
|
|
|
}
|
|
|
|
} | str collect (char nl))
|
|
|
|
|
|
|
|
let parameters = if ($command.signature | length) > 0 {
|
|
|
|
$"## Parameters(char nl)(char nl)($params)(char nl)(char nl)"
|
|
|
|
} else {
|
|
|
|
""
|
|
|
|
}
|
|
|
|
|
|
|
|
let examples = if ($command.examples | length) > 0 {
|
|
|
|
let example_top = $"## Examples(char nl)(char nl)"
|
|
|
|
|
|
|
|
let $examples = ($command.examples | each { |example|
|
|
|
|
$"($example.description)
|
|
|
|
```shell
|
|
|
|
> ($example.example)
|
|
|
|
```
|
|
|
|
|
|
|
|
"
|
|
|
|
} | str collect)
|
|
|
|
|
|
|
|
$example_top + $examples
|
|
|
|
} else { "" }
|
2022-02-21 14:38:15 +01:00
|
|
|
|
2022-02-22 14:11:46 +01:00
|
|
|
let doc = (
|
|
|
|
($top + $signature + $parameters + $examples) |
|
|
|
|
lines |
|
|
|
|
each {|it| ($it | str trim -r) } |
|
|
|
|
str collect (char nl)
|
|
|
|
)
|
2022-02-14 03:22:51 +01:00
|
|
|
|
|
|
|
let safe_name = ($command.command | str find-replace '\?' '' | str find-replace ' ' '_')
|
|
|
|
$doc | save --raw $"./docs/commands/($safe_name).md"
|
2022-02-20 21:20:41 +01:00
|
|
|
$"./docs/commands/($safe_name).md"
|
2022-02-14 03:22:51 +01:00
|
|
|
} | length | $"($in) commands written"
|
|
|
|
|