From a61d09222fa5e1b81fdf141fba4c402669fbef21 Mon Sep 17 00:00:00 2001 From: WindSoilder Date: Sun, 8 May 2022 21:11:28 +0800 Subject: [PATCH] document out positional argument type (#5461) --- crates/nu-command/tests/format_conversions/html.rs | 4 ++-- crates/nu-engine/src/documentation.rs | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/nu-command/tests/format_conversions/html.rs b/crates/nu-command/tests/format_conversions/html.rs index f705bd826..5e36b3d0e 100644 --- a/crates/nu-command/tests/format_conversions/html.rs +++ b/crates/nu-command/tests/format_conversions/html.rs @@ -56,7 +56,7 @@ fn test_cd_html_color_flag_dark_false() { ); assert_eq!( actual.out, - r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help
Display this help message

Parameters:
(optional) path: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
>
cd
d/s/9

" + r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help
Display this help message

Parameters:
(optional) path <Directory>: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
>
cd
d/s/9

" ); } @@ -71,6 +71,6 @@ fn test_no_color_flag() { ); assert_eq!( actual.out, - r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help
Display this help message

Parameters:
(optional) path: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
> cd d/s/9

" + r"Change directory.

Usage:
> cd (path)

Flags:
-h, --help
Display this help message

Parameters:
(optional) path <Directory>: the path to change to

Examples:
Change to your home directory
> cd ~

Change to a directory via abbreviations
> cd d/s/9

" ); } diff --git a/crates/nu-engine/src/documentation.rs b/crates/nu-engine/src/documentation.rs index aaf9a5466..8d3ef97b6 100644 --- a/crates/nu-engine/src/documentation.rs +++ b/crates/nu-engine/src/documentation.rs @@ -87,19 +87,22 @@ fn get_documentation( { long_desc.push_str("\nParameters:\n"); for positional in &sig.required_positional { - long_desc.push_str(&format!(" {}: {}\n", positional.name, positional.desc)); + long_desc.push_str(&format!( + " {} <{:?}>: {}\n", + positional.name, positional.shape, positional.desc + )); } for positional in &sig.optional_positional { long_desc.push_str(&format!( - " (optional) {}: {}\n", - positional.name, positional.desc + " (optional) {} <{:?}>: {}\n", + positional.name, positional.shape, positional.desc )); } if let Some(rest_positional) = &sig.rest_positional { long_desc.push_str(&format!( - " ...{}: {}\n", - rest_positional.name, rest_positional.desc + " ...{} <{:?}>: {}\n", + rest_positional.name, rest_positional.shape, rest_positional.desc )); } }