Change the usage misnomer to "description" (#13598)

# Description
    
The meaning of the word usage is specific to describing how a command
function is *used* and not a synonym for general description. Usage can
be used to describe the SYNOPSIS or EXAMPLES sections of a man page
where the permitted argument combinations are shown or example *uses*
are given.
Let's not confuse people and call it what it is a description.

Our `help` command already creates its own *Usage* section based on the
available arguments and doesn't refer to the description with usage.

# User-Facing Changes

`help commands` and `scope commands` will now use `description` or
`extra_description`
`usage`-> `description`
`extra_usage` -> `extra_description`

Breaking change in the plugin protocol:

In the signature record communicated with the engine.
`usage`-> `description`
`extra_usage` -> `extra_description`

The same rename also takes place for the methods on
`SimplePluginCommand` and `PluginCommand`

# Tests + Formatting
- Updated plugin protocol specific changes
# After Submitting
- [ ] update plugin protocol doc
This commit is contained in:
Stefan Holderbach
2024-08-22 12:02:08 +02:00
committed by GitHub
parent 3ab9f0b90a
commit 95b78eee25
597 changed files with 1085 additions and 1039 deletions

View File

@ -40,7 +40,7 @@ impl PluginCommand for AppendDF {
"polars append"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Appends a new dataframe."
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for CastDF {
"polars cast"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Cast a column to a different dtype."
}

View File

@ -16,7 +16,7 @@ impl PluginCommand for ColumnsDF {
"polars columns"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Show dataframe columns."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for DropDF {
"polars drop"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates a new dataframe by dropping the selected columns."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for DropDuplicates {
"polars drop-duplicates"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Drops duplicate values in dataframe."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for DropNulls {
"polars drop-nulls"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Drops null values in dataframe."
}

View File

@ -16,7 +16,7 @@ impl PluginCommand for Dummies {
"polars dummies"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates a new dataframe with dummy variables."
}

View File

@ -23,7 +23,7 @@ impl PluginCommand for FilterWith {
"polars filter-with"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Filters dataframe using a mask or expression as reference."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for FirstDF {
"polars first"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Show only the first number of rows or create a first expression"
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for GetDF {
"polars get"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates dataframe with the selected columns."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for LastDF {
"polars last"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates new dataframe with tail rows or creates a last expression."
}

View File

@ -45,7 +45,7 @@ impl PluginCommand for OpenDataFrame {
"polars open"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Opens CSV, JSON, NDJSON/JSON lines, arrow, avro, or parquet file to create dataframe. A lazy dataframe will be created by default, if supported."
}

View File

@ -24,7 +24,7 @@ impl PluginCommand for PivotDF {
"polars pivot"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Pivot a DataFrame from wide to long format."
}

View File

@ -24,7 +24,7 @@ impl PluginCommand for QueryDf {
"polars query"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Query dataframe using SQL. Note: The dataframe is always named 'df' in your query's from clause."
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for RenameDF {
"polars rename"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Rename a dataframe column."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for SampleDF {
"polars sample"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Create sample dataframe."
}

View File

@ -29,7 +29,7 @@ impl PluginCommand for SaveDF {
"polars save"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Saves a dataframe to disk. For lazy dataframes a sink operation will be used if the file type supports it (parquet, ipc/arrow, csv, and ndjson)."
}

View File

@ -15,7 +15,7 @@ impl PluginCommand for SchemaCmd {
"polars schema"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Show schema for a dataframe."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for ShapeDF {
"polars shape"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Shows column and row size for a dataframe."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for SliceDF {
"polars slice"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates new dataframe from a slice of rows."
}

View File

@ -25,7 +25,7 @@ impl PluginCommand for Summary {
"polars summary"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"For a dataframe, produces descriptive statistics (summary statistics) for its numeric columns."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for TakeDF {
"polars take"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates new dataframe using the given indices."
}

View File

@ -25,7 +25,7 @@ impl PluginCommand for ToDataFrame {
"polars into-df"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Converts a list, table or record into a dataframe."
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for ToNu {
"polars into-nu"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Converts a dataframe or an expression into nushell value for access and exploration."
}

View File

@ -23,7 +23,7 @@ impl PluginCommand for UnpivotDF {
"polars unpivot"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Unpivot a DataFrame from wide to long format."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for WithColumn {
"polars with-column"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Adds a series to the dataframe."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for ExprAlias {
"polars as"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates an alias expression."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for ExprArgWhere {
"polars arg-where"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates an expression that returns the arguments where expression is true."
}

View File

@ -15,7 +15,7 @@ impl PluginCommand for ExprCol {
"polars col"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates a named column expression."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for ExprConcatStr {
"polars concat-str"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates a concat string expression."
}

View File

@ -27,7 +27,7 @@ impl PluginCommand for ExprDatePart {
"polars datepart"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates an expression for capturing the specified datepart in a column."
}

View File

@ -21,13 +21,13 @@ macro_rules! expr_command {
$name
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
$desc
}
fn signature(&self) -> Signature {
Signature::build(self.name())
.usage($desc)
.description($desc)
.input_output_type(
Type::Custom("expression".into()),
Type::Custom("expression".into()),
@ -76,7 +76,7 @@ macro_rules! expr_command {
fn signature(&self) -> Signature {
Signature::build(self.name())
.usage($desc)
.description($desc)
.input_output_type(
Type::Custom("expression".into()),
Type::Custom("expression".into()),
@ -127,13 +127,13 @@ macro_rules! lazy_expr_command {
$name
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
$desc
}
fn signature(&self) -> Signature {
Signature::build(self.name())
.usage($desc)
.description($desc)
.input_output_types(vec![
(
Type::Custom("expression".into()),
@ -199,7 +199,7 @@ macro_rules! lazy_expr_command {
$name
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
$desc
}
fn signature(&self) -> Signature {

View File

@ -20,7 +20,7 @@ impl PluginCommand for ExprIsIn {
"polars is-in"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates an is-in expression or checks to see if the elements are contained in the right series"
}

View File

@ -14,7 +14,7 @@ impl PluginCommand for ExprLit {
"polars lit"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates a literal expression."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for ExprOtherwise {
"polars otherwise"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Completes a when expression."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for ExprWhen {
"polars when"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates and modifies a when expression."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for LazyAggregate {
"polars agg"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Performs a series of aggregations from a group-by."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for LazyCollect {
"polars collect"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Collect lazy dataframe into eager dataframe."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for LazyExplode {
"polars explode"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Explodes a dataframe or creates a explode expression."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for LazyFetch {
"polars fetch"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Collects the lazyframe to the selected rows."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for LazyFillNA {
"polars fill-nan"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Replaces NaN values with the given expression."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for LazyFillNull {
"polars fill-null"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Replaces NULL values with the given expression."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for LazyFilter {
"polars filter"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Filter dataframe based in expression."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for LazyFlatten {
"polars flatten"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"An alias for polars explode."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for ToLazyGroupBy {
"polars group-by"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates a group-by object that can be used for other aggregations."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for LazyJoin {
"polars join"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Joins a lazy frame with other lazy frame."
}

View File

@ -19,13 +19,13 @@ macro_rules! lazy_command {
$name
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
$desc
}
fn signature(&self) -> Signature {
Signature::build(self.name())
.usage($desc)
.description($desc)
.input_output_type(
Type::Custom("dataframe".into()),
Type::Custom("dataframe".into()),
@ -74,7 +74,7 @@ macro_rules! lazy_command {
fn signature(&self) -> Signature {
Signature::build($name)
.usage($desc)
.description($desc)
.input_output_type(
Type::Custom("dataframe".into()),
Type::Custom("dataframe".into()),
@ -122,7 +122,7 @@ macro_rules! lazy_command {
$name
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
$desc
}
fn signature(&self) -> Signature {

View File

@ -19,7 +19,7 @@ impl PluginCommand for LazyMedian {
"polars median"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Median value from columns in a dataframe or creates expression for an aggregation"
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for LazyQuantile {
"polars quantile"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Aggregates the columns to the selected quantile."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for LazySelect {
"polars select"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Selects columns from lazyframe."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for LazySortBy {
"polars sort-by"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Sorts a lazy dataframe based on expression(s)."
}

View File

@ -15,7 +15,7 @@ impl PluginCommand for ToLazyFrame {
"polars into-lazy"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Converts a dataframe into a lazy dataframe."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for AllFalse {
"polars all-false"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns true if all values are false."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for AllTrue {
"polars all-true"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns true if all values are true."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ArgMax {
"polars arg-max"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Return index for max value in series."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ArgMin {
"polars arg-min"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Return index for min value in series."
}

View File

@ -51,7 +51,7 @@ impl PluginCommand for Cumulative {
"polars cumulative"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Cumulative calculation for a series."
}

View File

@ -18,11 +18,11 @@ impl PluginCommand for AsDate {
"polars as-date"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
r#"Converts string to date."#
}
fn extra_usage(&self) -> &str {
fn extra_description(&self) -> &str {
r#"Format example:
"%Y-%m-%d" => 2021-12-31
"%d-%m-%Y" => 31-12-2021

View File

@ -20,11 +20,11 @@ impl PluginCommand for AsDateTime {
"polars as-datetime"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
r#"Converts string to datetime."#
}
fn extra_usage(&self) -> &str {
fn extra_description(&self) -> &str {
r#"Format example:
"%y/%m/%d %H:%M:%S" => 21/12/31 12:54:98
"%y-%m-%d %H:%M:%S" => 2021-12-31 24:58:01

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetDay {
"polars get-day"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets day from date."
}
@ -58,7 +58,7 @@ impl PluginCommand for GetDay {
command(plugin, engine, call, input).map_err(LabeledError::from)
}
fn extra_usage(&self) -> &str {
fn extra_description(&self) -> &str {
""
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetHour {
"polars get-hour"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets hour from date."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for GetMinute {
"polars get-minute"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets minute from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetMonth {
"polars get-month"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets month from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetNanosecond {
"polars get-nanosecond"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets nanosecond from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetOrdinal {
"polars get-ordinal"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets ordinal from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetSecond {
"polars get-second"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets second from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetWeek {
"polars get-week"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets week from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetWeekDay {
"polars get-weekday"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets weekday from date."
}

View File

@ -21,7 +21,7 @@ impl PluginCommand for GetYear {
"polars get-year"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Gets year from date."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ArgSort {
"polars arg-sort"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns indexes for a sorted series."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ArgTrue {
"polars arg-true"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns indexes where values are true."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ArgUnique {
"polars arg-unique"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns indexes for unique values."
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for SetWithIndex {
"polars set-with-idx"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Sets value in the given index."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for IsDuplicated {
"polars is-duplicated"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates mask indicating duplicated values."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for IsNotNull {
"polars is-not-null"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates mask where value is not null."
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for IsNull {
"polars is-null"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates mask where value is null."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for IsUnique {
"polars is-unique"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Creates mask indicating unique values."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for NotSeries {
"polars not"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Inverts boolean mask."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for SetSeries {
"polars set"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Sets value where given mask is true."
}

View File

@ -17,7 +17,7 @@ impl PluginCommand for NNull {
"polars count-null"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Counts null values."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for NUnique {
"polars n-unique"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Counts unique values."
}

View File

@ -53,7 +53,7 @@ impl PluginCommand for Rolling {
"polars rolling"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Rolling calculation for a series."
}

View File

@ -24,7 +24,7 @@ impl PluginCommand for Shift {
"polars shift"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Shifts the values by a given period."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for Concatenate {
"polars concatenate"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Concatenates strings with other array."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for Contains {
"polars contains"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Checks if a pattern is contained in a string."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for Replace {
"polars replace"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Replace the leftmost (sub)string by a regex pattern."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for ReplaceAll {
"polars replace-all"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Replace all (sub)strings by a regex pattern."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for StrLengths {
"polars str-lengths"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Get lengths of all strings."
}

View File

@ -22,7 +22,7 @@ impl PluginCommand for StrSlice {
"polars str-slice"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Slices the string from the start position until the selected length."
}

View File

@ -19,7 +19,7 @@ impl PluginCommand for StrFTime {
"polars strftime"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Formats date based on string rule."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ToLowerCase {
"polars lowercase"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Lowercase the strings in the column."
}

View File

@ -18,7 +18,7 @@ impl PluginCommand for ToUpperCase {
"polars uppercase"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Uppercase the strings in the column."
}

View File

@ -23,7 +23,7 @@ impl PluginCommand for Unique {
"polars unique"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns unique values from a dataframe."
}

View File

@ -20,7 +20,7 @@ impl PluginCommand for ValueCount {
"polars value-counts"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Returns a dataframe with the counts for unique values in series."
}

View File

@ -13,7 +13,7 @@ impl PluginCommand for PolarsCmd {
"polars"
}
fn usage(&self) -> &str {
fn description(&self) -> &str {
"Operate with data in a dataframe format."
}
@ -23,7 +23,7 @@ impl PluginCommand for PolarsCmd {
.input_output_types(vec![(Type::Nothing, Type::String)])
}
fn extra_usage(&self) -> &str {
fn extra_description(&self) -> &str {
"You must use one of the following subcommands. Using this command as-is will only produce this help message."
}