vscode_generator/snippets/
mod.rs

1//! # The Snippets Module
2//! 
3//! 📦 This module provides a comprehensive toolkit for working with VS Code snippets.
4//! It allows creating, managing, and serializing code snippets with rich customization options.
5//! 
6//! ## Components
7//! 
8//! - [`Snippet`] - Individual snippet representation
9//! - [`SnippetBuilder`] - Fluent builder for snippets
10//! - [`SnippetsFile`] - Collection of snippets for VS Code
11//! 
12//! ## Overview
13//! 
14//! - 📝 Create and edit snippets with rich formatting
15//! - 🔧 Customize triggers, descriptions, and scopes
16//! - 📦 Manage collections of snippets
17//! - 💾 Serialize/deserialize to VS Code format
18//! 
19//! ## Examples
20//! 
21//! #### 🎨 Creating a Simple Snippet
22//! ```rust
23//! use snippets::SnippetBuilder;
24//! 
25//! let snippet = SnippetBuilder::new()
26//!     .set_prefix("fn")
27//!     .add_line("fn ${1:name}() {")
28//!     .add_line("    ${0:// TODO: ${0}}")
29//!     .add_line("}")
30//!     .build()
31//!     .unwrap();
32//! ```
33//! 
34//! #### 📁 Managing Snippet Collections
35//! ```rust
36//! use snippets::{ SnippetsFile, SnippetBuilder };
37//! 
38//! let mut file = SnippetsFile::new(vec![
39//!     SnippetBuilder::new()
40//!         .set_prefix("fn")
41//!         .set_body(vec![
42//!             "fn main() {",
43//!             "    $0",
44//!             "}"
45//!         ])
46//!         .set_scope("rust")
47//! ]);
48//! 
49//! // Add test snippet
50//! file.add_snippet(
51//!     SnippetBuilder::new()
52//!         .set_prefix("test")
53//!         .set_body(vec![
54//!             "#[test]",
55//!             "fn test_${1:name}() {",
56//!             "    $0",
57//!             "}"
58//!         ])
59//!         .set_scope("rust")
60//!         .build()
61//!         .unwrap()
62//! );
63//! ```
64//! 
65//! ## Panics
66//! 
67//! The builder's `build()` method will panic if
68//! - `prefix` is empty
69//! - `name` is empty
70//! - `body` is empty
71//! 
72//! ## Notes
73//! 
74//! #### The syntax of VS Code snippets:
75//! 
76//! - 📌 Use `$0` to specify the final cursor position
77//! - 📌 Use `$1`, `$2`, etc. for tabstops
78//! - 📌 Use `${1:default text}` for placeholders with default values
79//! - 📌 Use `${1|one,two,three|}` for dropdown choices
80//! 
81//! 
82//! #### See Also
83//! 
84//! - 🔗 Structure [`SnippetFile`](super::SnippetFile) - For more flexible snippet construction
85//! - 🔗 VS Code [Snippet Guide](https://code.visualstudio.com/docs/editor/userdefinedsnippets)
86
87pub mod snippet;            pub use snippet::Snippet;
88pub mod snippet_builder;    pub use snippet_builder::SnippetBuilder;
89pub mod snippets_file;      pub use snippets_file::SnippetsFile;