Skip to content

Commit

Permalink
Merge pull request #5122 from epage/docs
Browse files Browse the repository at this point in the history
docs(tutorial): Split into separate modules per section
  • Loading branch information
epage committed Sep 12, 2023
2 parents 20987de + 32586c7 commit 3d53641
Show file tree
Hide file tree
Showing 17 changed files with 591 additions and 499 deletions.
255 changes: 0 additions & 255 deletions src/_derive/_tutorial.rs

This file was deleted.

25 changes: 25 additions & 0 deletions src/_derive/_tutorial/chapter_0.rs
@@ -0,0 +1,25 @@
//! ## Quick Start
//!
//! You can create an application declaratively with a `struct` and some
//! attributes.
//!
//! First, ensure `clap` is available with the [`derive` feature flag][crate::_features]:
//! ```console
//! $ cargo add clap --features derive
//! ```
//!
//! ```rust
#![doc = include_str!("../../../examples/tutorial_derive/01_quick.rs")]
//! ```
//!
#![doc = include_str!("../../../examples/tutorial_derive/01_quick.md")]
//!
//! See also
//! - [FAQ: When should I use the builder vs derive APIs?][crate::_faq#when-should-i-use-the-builder-vs-derive-apis]
//! - The [cookbook][crate::_cookbook] for more application-focused examples

#![allow(unused_imports)]
use crate::builder::*;

pub use super::chapter_1 as next;
pub use crate::_tutorial as table_of_contents;
29 changes: 29 additions & 0 deletions src/_derive/_tutorial/chapter_1.rs
@@ -0,0 +1,29 @@
//! ## Configuring the Parser
//!
//! You use derive [`Parser`][crate::Parser] to start building a parser.
//!
//! ```rust
#![doc = include_str!("../../../examples/tutorial_derive/02_apps.rs")]
//! ```
//!
#![doc = include_str!("../../../examples/tutorial_derive/02_apps.md")]
//!
//! You can use [`#[command(author, version, about)]` attribute defaults][super#command-attributes] on the struct to fill these fields in from your `Cargo.toml` file.
//!
//! ```rust
#![doc = include_str!("../../../examples/tutorial_derive/02_crate.rs")]
//! ```
#![doc = include_str!("../../../examples/tutorial_derive/02_crate.md")]
//!
//! You can use `#[command]` attributes on the struct to change the application level behavior of clap. Any [`Command`][crate::Command] builder function can be used as an attribute, like [`Command::next_line_help`].
//!
//! ```rust
#![doc = include_str!("../../../examples/tutorial_derive/02_app_settings.rs")]
//! ```
#![doc = include_str!("../../../examples/tutorial_derive/02_app_settings.md")]
#![allow(unused_imports)]
use crate::builder::*;

pub use super::chapter_0 as previous;
pub use super::chapter_2 as next;
pub use crate::_tutorial as table_of_contents;

0 comments on commit 3d53641

Please sign in to comment.