Update documents for commands (#4796)

* Update documents of commands

* Change plugin names for register command examples

* Remove unused docs [ci skip]
This commit is contained in:
Justin Ma 2022-03-09 21:05:35 +08:00 committed by GitHub
parent 8fcf51908a
commit 0d82d7df60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 78 additions and 86 deletions

View file

@ -54,13 +54,13 @@ impl Command for Register {
fn examples(&self) -> Vec<Example> {
vec![
Example {
description: "Register `nu_plugin_extra_query` plugin from ~/.cargo/bin/ dir",
example: r#"register -e capnp ~/.cargo/bin/nu_plugin_extra_query"#,
description: "Register `nu_plugin_query` plugin from ~/.cargo/bin/ dir",
example: r#"register -e capnp ~/.cargo/bin/nu_plugin_query"#,
result: None,
},
Example {
description: "Register `nu_plugin_extra_query` plugin from `nu -c`(plugin will be available in that nu session only)",
example: r#"let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_extra_query'); nu -c $'register -e capnp ($plugin); version'"#,
description: "Register `nu_plugin_query` plugin from `nu -c`(plugin will be available in that nu session only)",
example: r#"let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_query'); nu -c $'register -e capnp ($plugin); version'"#,
result: None,
},
]

View file

@ -1,23 +0,0 @@
---
title: each group
layout: command
version: 0.59.1
---
Runs a block on groups of `group_size` rows of a table at a time.
## Signature
```> each group (group_size) (block)```
## Parameters
- `group_size`: the size of each group
- `block`: the block to run on each group
## Examples
Echo the sum of each pair
```shell
> echo [1 2 3 4] | each group 2 { |it| $it.0 + $it.1 }
```

View file

@ -1,29 +0,0 @@
---
title: each window
layout: command
version: 0.59.1
---
Runs a block on window groups of `window_size` that slide by n rows.
## Signature
```> each window (window_size) (block) --stride```
## Parameters
- `window_size`: the size of each window
- `block`: the block to run on each window
- `--stride {int}`: the number of rows to slide over between windows
## Examples
A sliding window of two elements
```shell
> echo [1 2 3 4] | each window 2 { |it| $it.0 + $it.1 }
```
A sliding window of two elements, with a stride of 3
```shell
> [1, 2, 3, 4, 5, 6, 7, 8] | each window 2 --stride 3 { |x| $x.0 + $x.1 }
```

22
docs/commands/group.md Normal file
View file

@ -0,0 +1,22 @@
---
title: group
layout: command
version: 0.59.1
---
Groups input into groups of `group_size`.
## Signature
```> group (group_size)```
## Parameters
- `group_size`: the size of each group
## Examples
Group the a list by pairs
```shell
> echo [1 2 3 4] | group 2
```

View file

@ -1,7 +1,7 @@
---
title: gstat
layout: command
version: 0.59.0
version: 0.59.1
---
Get the git status of a repo

View file

@ -1,23 +0,0 @@
---
title: par-each group
layout: command
version: 0.59.1
---
Runs a block on groups of `group_size` rows of a table at a time.
## Signature
```> par-each group (group_size) (block)```
## Parameters
- `group_size`: the size of each group
- `block`: the block to run on each group
## Examples
Multiplies elements in list
```shell
> echo [1 2 3 4] | par-each group 2 {|it| $it.0 + $it.1 }
```

View file

@ -38,3 +38,8 @@ Post content to url.com, with custom header
```shell
> post -H [my-header-key my-header-value] url.com
```
Post content to url.com with a json body
```shell
> post -t application/json url.com { field: value }
```

View file

@ -19,12 +19,12 @@ Register a plugin
## Examples
Register `nu_plugin_extra_query` plugin from ~/.cargo/bin/ dir
Register `nu_plugin_query` plugin from ~/.cargo/bin/ dir
```shell
> register -e capnp ~/.cargo/bin/nu_plugin_extra_query
> register -e capnp ~/.cargo/bin/nu_plugin_query
```
Register `nu_plugin_extra_query` plugin from `nu -c`(plugin will be available in that nu session only)
Register `nu_plugin_query` plugin from `nu -c`(plugin will be available in that nu session only)
```shell
> let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_extra_query'); nu -c $'register -e capnp ($plugin); version'
> let plugin = ((which nu).path.0 | path dirname | path join 'nu_plugin_query'); nu -c $'register -e capnp ($plugin); version'
```

View file

@ -8,12 +8,13 @@ Save a file.
## Signature
```> save (filename) --raw```
```> save (filename) --raw --append```
## Parameters
- `filename`: the filename to use
- `--raw`: save file as raw binary
- `--append`: append input to the end of the file
## Examples

View file

@ -8,13 +8,14 @@ Checks if string contains pattern
## Signature
```> str contains (pattern) ...rest --insensitive```
```> str contains (pattern) ...rest --insensitive --not```
## Parameters
- `pattern`: the pattern to find
- `...rest`: optionally check if string contains pattern by column paths
- `--insensitive`: search is case insensitive
- `--not`: does not contain
## Examples
@ -47,3 +48,13 @@ Check if string contains pattern
```shell
> 'hello' | str contains 'banana'
```
Check if list contains pattern
```shell
> [one two three] | str contains o
```
Check if list does not contain pattern
```shell
> [one two three] | str contains -n o
```

28
docs/commands/window.md Normal file
View file

@ -0,0 +1,28 @@
---
title: window
layout: command
version: 0.59.1
---
Creates a sliding window of `window_size` that slide by n rows/elements across input.
## Signature
```> window (window_size) --stride```
## Parameters
- `window_size`: the size of each window
- `--stride {int}`: the number of rows to slide over between windows
## Examples
A sliding window of two elements
```shell
> echo [1 2 3 4] | window 2
```
A sliding window of two elements, with a stride of 3
```shell
> [1, 2, 3, 4, 5, 6, 7, 8] | window 2 --stride 3
```