fix strip trailing whitespace for make_docs script (#4597)

This commit is contained in:
Justin Ma 2022-02-22 21:11:46 +08:00 committed by GitHub
parent 3e8a41fbc9
commit b448d1dbe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 29 additions and 14 deletions

View File

@ -8,11 +8,12 @@ Run a block on each element of input
## Signature
```> each (block) --numbered```
```> each (block) --keep-empty --numbered```
## Parameters
- `block`: the block to run
- `--keep-empty`: keep empty result cells
- `--numbered`: iterate with an index
## Examples
@ -21,3 +22,13 @@ Multiplies elements in list
```shell
> [1 2 3] | each { |it| 2 * $it }
```
Iterate over each element, keeping only values that succeed
```shell
> [1 2 3] | each { |it| if $it == 2 { echo "found 2!"} }
```
Iterate over each element, keeping all results
```shell
> [1 2 3] | each --keep-empty { |it| if $it == 2 { echo "found 2!"} }
```

View File

@ -8,9 +8,10 @@ Runs external command
## Signature
```> run-external ...rest --last-expression```
```> run-external ...rest --redirect-stdout --redirect-stderr```
## Parameters
- `...rest`: external command to run
- `--last-expression`: last-expression
- `--redirect-stdout`: redirect-stdout
- `--redirect-stderr`: redirect-stderr

View File

@ -57,9 +57,12 @@ $"($example.description)
$example_top + $examples
} else { "" }
let doc = (($top + $signature + $parameters + $examples) |
each {|it| ($it | str trim -r)} |
str collect (char nl)) + (char nl)
let doc = (
($top + $signature + $parameters + $examples) |
lines |
each {|it| ($it | str trim -r) } |
str collect (char nl)
)
let safe_name = ($command.command | str find-replace '\?' '' | str find-replace ' ' '_')
$doc | save --raw $"./docs/commands/($safe_name).md"