From c0ad659985d7d45c1fe0589ed84461ba38515de9 Mon Sep 17 00:00:00 2001 From: Douglas <32344964+NotTheDr01ds@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:18:23 -0500 Subject: [PATCH] Doc file fixes (#14608) # Description With great thanks to @fdncred and especially @PerchunPak (see #14601) for finding and fixing a number of issues that I pulled in here due to the filename changes and upcoming freeze. This PR primarily fixes a poor wording choice in the new filenames and `config` command options. The fact that these were called `sample_config.nu` (etc.) and accessed via `config --sample` created a great deal of confusion. These were never intended to be used as-is as config files, but rather as in-shell documentation. As such, I've renamed them: * `sample_config.nu` becomes `doc_config.nu` * `sample_env.nu` becomes `doc_env.nu` * `config nu --sample` becomes `config nu --doc` * `config env --sample` because `config env --doc` Also the following: * Updates `doc_config.nu` with a few additional comment-fixes on top of @PerchunPak's changes. * Adds version numbers to all files - Will need to update the version script to add some files after this PR. * Additional doc on plugin and plugin_gc configuration which I had failed to previously completely update from the older wording * Updated the comments in the `scaffold_*.nu` files to point people to `help config`/`help nu` so that, if things change in the future, it will become more difficult for the comments to be outdated. * # User-Facing Changes Mostly doc. `config nu` and `config env` changes update new behavior previously added in 0.100.1 # Tests + Formatting - :green_circle: `toolkit fmt` - :green_circle: `toolkit clippy` - :green_circle: `toolkit test` - :green_circle: `toolkit test stdlib` # After Submitting * Update configuration chapter of doc * Update the blog entry on migrating config * Update `bump-version.nu` --- .../nu-command/src/env/config/config_env.rs | 22 +++++----- crates/nu-command/src/env/config/config_nu.rs | 22 +++++----- crates/nu-utils/src/default_files/README.md | 18 ++++---- .../{sample_config.nu => doc_config.nu} | 41 ++++++++++--------- .../{sample_env.nu => doc_env.nu} | 6 ++- .../src/default_files/scaffold_config.nu | 6 +-- .../src/default_files/scaffold_env.nu | 6 +-- crates/nu-utils/src/lib.rs | 4 +- crates/nu-utils/src/utils.rs | 8 ++-- 9 files changed, 65 insertions(+), 68 deletions(-) rename crates/nu-utils/src/default_files/{sample_config.nu => doc_config.nu} (97%) rename crates/nu-utils/src/default_files/{sample_env.nu => doc_env.nu} (74%) diff --git a/crates/nu-command/src/env/config/config_env.rs b/crates/nu-command/src/env/config/config_env.rs index 5fdc39a903..f078b365d2 100644 --- a/crates/nu-command/src/env/config/config_env.rs +++ b/crates/nu-command/src/env/config/config_env.rs @@ -18,8 +18,8 @@ impl Command for ConfigEnv { Some('d'), ) .switch( - "sample", - "Print a commented, sample `env.nu` file instead.", + "doc", + "Print a commented `env.nu` with documentation instead.", Some('s'), ) // TODO: Signature narrower than what run actually supports theoretically @@ -37,8 +37,8 @@ impl Command for ConfigEnv { result: None, }, Example { - description: "pretty-print a commented, sample `env.nu` that explains common settings", - example: "config env --sample | nu-highlight,", + description: "pretty-print a commented `env.nu` that explains common settings", + example: "config env --doc | nu-highlight,", result: None, }, Example { @@ -57,13 +57,13 @@ impl Command for ConfigEnv { _input: PipelineData, ) -> Result { let default_flag = call.has_flag(engine_state, stack, "default")?; - let sample_flag = call.has_flag(engine_state, stack, "sample")?; - if default_flag && sample_flag { + let doc_flag = call.has_flag(engine_state, stack, "doc")?; + if default_flag && doc_flag { return Err(ShellError::IncompatibleParameters { left_message: "can't use `--default` at the same time".into(), left_span: call.get_flag_span(stack, "default").expect("has flag"), - right_message: "because of `--sample`".into(), - right_span: call.get_flag_span(stack, "sample").expect("has flag"), + right_message: "because of `--doc`".into(), + right_span: call.get_flag_span(stack, "doc").expect("has flag"), }); } // `--default` flag handling @@ -72,10 +72,10 @@ impl Command for ConfigEnv { return Ok(Value::string(nu_utils::get_default_env(), head).into_pipeline_data()); } - // `--sample` flag handling - if sample_flag { + // `--doc` flag handling + if doc_flag { let head = call.head; - return Ok(Value::string(nu_utils::get_sample_env(), head).into_pipeline_data()); + return Ok(Value::string(nu_utils::get_doc_env(), head).into_pipeline_data()); } super::config_::start_editor("env-path", engine_state, stack, call) diff --git a/crates/nu-command/src/env/config/config_nu.rs b/crates/nu-command/src/env/config/config_nu.rs index 75d971f36e..66e24e2a94 100644 --- a/crates/nu-command/src/env/config/config_nu.rs +++ b/crates/nu-command/src/env/config/config_nu.rs @@ -18,8 +18,8 @@ impl Command for ConfigNu { Some('d'), ) .switch( - "sample", - "Print a commented, sample `config.nu` file instead.", + "doc", + "Print a commented `config.nu` with documentation instead.", Some('s'), ) // TODO: Signature narrower than what run actually supports theoretically @@ -37,8 +37,8 @@ impl Command for ConfigNu { result: None, }, Example { - description: "pretty-print a commented, sample `config.nu` that explains common settings", - example: "config nu --sample | nu-highlight", + description: "pretty-print a commented `config.nu` that explains common settings", + example: "config nu --doc | nu-highlight", result: None, }, Example { @@ -58,13 +58,13 @@ impl Command for ConfigNu { _input: PipelineData, ) -> Result { let default_flag = call.has_flag(engine_state, stack, "default")?; - let sample_flag = call.has_flag(engine_state, stack, "sample")?; - if default_flag && sample_flag { + let doc_flag = call.has_flag(engine_state, stack, "doc")?; + if default_flag && doc_flag { return Err(ShellError::IncompatibleParameters { left_message: "can't use `--default` at the same time".into(), left_span: call.get_flag_span(stack, "default").expect("has flag"), - right_message: "because of `--sample`".into(), - right_span: call.get_flag_span(stack, "sample").expect("has flag"), + right_message: "because of `--doc`".into(), + right_span: call.get_flag_span(stack, "doc").expect("has flag"), }); } @@ -74,10 +74,10 @@ impl Command for ConfigNu { return Ok(Value::string(nu_utils::get_default_config(), head).into_pipeline_data()); } - // `--sample` flag handling - if sample_flag { + // `--doc` flag handling + if doc_flag { let head = call.head; - return Ok(Value::string(nu_utils::get_sample_config(), head).into_pipeline_data()); + return Ok(Value::string(nu_utils::get_doc_config(), head).into_pipeline_data()); } super::config_::start_editor("config-path", engine_state, stack, call) diff --git a/crates/nu-utils/src/default_files/README.md b/crates/nu-utils/src/default_files/README.md index 68a36b865d..926870d20a 100644 --- a/crates/nu-utils/src/default_files/README.md +++ b/crates/nu-utils/src/default_files/README.md @@ -9,7 +9,7 @@ * During a startup where the user specifies an alternative `env.nu` via `nu --env-config ` * During a `nu -c ` or `nu