@@ -146,11 +146,9 @@ pub trait Generator {
146146///
147147/// mod cli;
148148///
149- /// fn main() {
150- /// let _m = cli::build_cli().get_matches();
149+ /// let _m = cli::build_cli().get_matches();
151150///
152- /// // normal logic continues...
153- /// }
151+ /// // normal logic continues...
154152/// ```
155153///
156154/// Next, we set up our `Cargo.toml` to use a `build.rs` build script.
@@ -176,24 +174,22 @@ pub trait Generator {
176174///
177175/// include!("src/cli.rs");
178176///
179- /// fn main() -> Result<(), Error> {
180- /// let outdir = match env::var_os("OUT_DIR") {
181- /// None => return Ok(()),
182- /// Some(outdir) => outdir,
183- /// };
177+ /// let outdir = match env::var_os("OUT_DIR") {
178+ /// None => return Ok(()),
179+ /// Some(outdir) => outdir,
180+ /// };
184181///
185- /// let mut cmd = build_cli();
186- /// let path = generate_to(
187- /// Bash,
188- /// &mut cmd, // We need to specify what generator to use
189- /// "myapp", // We need to specify the bin name manually
190- /// outdir, // We need to specify where to write to
191- /// )?;
182+ /// let mut cmd = build_cli();
183+ /// let path = generate_to(
184+ /// Bash,
185+ /// &mut cmd, // We need to specify what generator to use
186+ /// "myapp", // We need to specify the bin name manually
187+ /// outdir, // We need to specify where to write to
188+ /// )?;
192189///
193- /// println!("cargo:warning=completion file is generated: {path:?}");
190+ /// println!("cargo:warning=completion file is generated: {path:?}");
194191///
195- /// Ok(())
196- /// }
192+ /// Ok(())
197193/// ```
198194///
199195/// Now, once we compile there will be a `{bin_name}.bash` file in the directory.
@@ -218,19 +214,17 @@ pub trait Generator {
218214///
219215/// include!("src/cli.rs");
220216///
221- /// fn main() -> Result<(), Error> {
222- /// let outdir = match env::var_os("OUT_DIR") {
223- /// None => return Ok(()),
224- /// Some(outdir) => outdir,
225- /// };
226- ///
227- /// let mut cmd = build_cli();
228- /// for &shell in Shell::value_variants() {
229- /// generate_to(shell, &mut cmd, "myapp", outdir)?;
230- /// }
217+ /// let outdir = match env::var_os("OUT_DIR") {
218+ /// None => return Ok(()),
219+ /// Some(outdir) => outdir,
220+ /// };
231221///
232- /// Ok(())
222+ /// let mut cmd = build_cli();
223+ /// for &shell in Shell::value_variants() {
224+ /// generate_to(shell, &mut cmd, "myapp", outdir)?;
233225/// }
226+ ///
227+ /// Ok(())
234228/// ```
235229pub fn generate_to < G , S , T > (
236230 generator : G ,
@@ -273,16 +267,13 @@ where
273267/// use std::io;
274268/// use clap_complete::{generate, shells::Bash};
275269///
276- /// fn main() {
277- /// let matches = cli::build_cli().get_matches();
278- ///
279- /// if matches.is_present("generate-bash-completions") {
280- /// generate(Bash, &mut cli::build_cli(), "myapp", &mut io::stdout());
281- /// }
270+ /// let matches = cli::build_cli().get_matches();
282271///
283- /// // normal logic continues...
272+ /// if matches.is_present("generate-bash-completions") {
273+ /// generate(Bash, &mut cli::build_cli(), "myapp", &mut io::stdout());
284274/// }
285275///
276+ /// // normal logic continues...
286277/// ```
287278///
288279/// Usage:
0 commit comments