1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
//! The Visual Studio Code package generator [BETA]
//!
//! # Examples:
//! ```
//! use vscode_generator::{ prelude::* , Package, Snippets, Snippet, License };
//!
//! fn main() -> Result<()> {
//! // generating package:
//! let pkg = Package::snippets(
//! "vscode_rust_snippets",
//! "VSCode Rust snippets",
//! "The snippets for Rust programming language",
//! "0.0.1".parse()?,
//! "images/icon.png",
//! Some("https://github.com/DrakeN-inc/vscode-rust-snippets"),
//! vec![
//! // TEXT SNIPPETS:
//! Snippets::new(
//! "rust",
//! "Text",
//! "The simple text snippets",
//! vec![
//! Snippet::text("print-hello", "hello", r#"println!("Hello, world!"); // TEMP:"#),
//! Snippet::comment("comment-todo", "TODO"),
//! Snippet::comment("comment-note", "NOTE"),
//! Snippet::comment("comment-debug", "DEBUG"),
//! Snippet::comment("comment-fixme", "FIXME"),
//! ]
//! ),
//!
//! // ATTRIBUTES SNIPPETS:
//! Snippets::new(
//! "rust",
//! "Attributes",
//! "The attributes snippets",
//! vec![
//! Snippet::attribute("attr-derive", "derive", Some(vec![
//! "Debug",
//! "Display",
//! "Clone",
//! "Copy",
//! "Eq\\, PartialEq",
//! "Serialize\\, Deserialize",
//! ])),
//!
//! Snippet::attribute("attr-allow", "allow", Some(vec![
//! "dead_code",
//! "unused_variables",
//! "non_snake_case",
//! ])),
//!
//! Snippet::attribute("attr-cfg", "cfg", Some(vec![""])),
//! Snippet::attribute("attr-test", "test", None),
//! ]
//! ),
//!
//! // BLOCKS SNIPPETS:
//! Snippets::new(
//! "rust",
//! "Blocks",
//! "The block snippets",
//! vec![
//! Snippet::block("block-struct", "struct"),
//! Snippet::block("block-enum", "enum"),
//! Snippet::double_block("block-struct-impl", "struct", "impl"),
//! Snippet::double_block("block-enum-impl", "enum", "impl"),
//!
//! Snippet::function_block("block-fn", "fn"),
//!
//! Snippet::block("block-if", "if"),
//! Snippet::double_block("block-if-else", "if", "else")
//! .set_descr("if ... { ... } else { ... }")
//! .set_body(vec![
//! "if $1 {",
//! " $2",
//! "} else {",
//! " $3",
//! "}",
//! ]),
//! Snippet::block("block-short-if-else", "if?")
//! .set_descr("if ... { ... }else{ ... }")
//! .set_prefix("if?")
//! .set_body(vec![
//! "if $1 { $2 }else{ $3 }",
//! ]),
//!
//! Snippet::block("block-match", "match"),
//! Snippet::block("block-match-result", "match Result<T, E>")
//! .set_descr("match Result<T, E> { ... }")
//! .set_body(vec![
//! "match $1 {",
//! " Ok(r) => $2,",
//! " Err(e) => $3,",
//! "}",
//! ]),
//! Snippet::block("block-match-option", "match Option<T>")
//! .set_descr("match Option<T> { ... }")
//! .set_body(vec![
//! "match $1 {",
//! " Some(r) => $2,",
//! " None => $3,",
//! "}",
//! ]),
//!
//! Snippet::block("block-while", "while"),
//!
//! Snippet::block("block-for", "for")
//! .set_descr("for ... in ... {}")
//! .set_body(vec![
//! "for $1 in $2 {",
//! " $3",
//! "}",
//! ]),
//! Snippet::block("block-for-k-v", "for")
//! .set_prefix("for (k, v) in ... {}")
//! .set_descr("for (k, v) in ... {}")
//! .set_body(vec![
//! "for (${1:k, v}) in ${2:.enumerate()} {",
//! " $3",
//! "}",
//! ]),
//!
//! Snippet::simple_block("block-loop", "loop"),
//! ]
//! ),
//!
//! // OPERATORS SNIPPETS:
//! Snippets::new(
//! "rust",
//! "Operators",
//! "The operator snippets",
//! vec![
//! Snippet::operator("operator-mod", "mod", Some("")),
//! Snippet::operator("operator-use", "use", Some(""))
//! .set_body(vec!["use $1::$2;"]),
//! Snippet::operator("operator-mod-use", "mod use", Some(""))
//! .set_descr("mod ...; use ...::...;")
//! .set_body(vec!["mod $1; pub use $1::$2;"]),
//!
//! Snippet::operator("operator-return", "return", Some("")),
//! Snippet::operator("operator-break", "break", Some("")),
//! Snippet::operator("operator-break", "break", None),
//! Snippet::operator("operator-continue", "continue", None),
//! ]
//! ),
//!
//! // FUNCTIONS & METHODS SNIPPETS:
//! Snippets::new(
//! "rust",
//! "Functions",
//! "The functions and methods snippets",
//! vec![
//! Snippet::function("fn-read_to_string", "read_to_string", None, None),
//! Snippet::function("fn-write_all", "write_all", None, None),
//!
//! Snippet::function("fn-unwrap", ".unwrap", None, None),
//! Snippet::function("fn-unwrap_or", ".unwrap_or", None, Some("")),
//! Snippet::function("fn-unwrap_or_else", ".unwrap_or_else", None, Some("")),
//! Snippet::function("fn-map_err", ".map_err", None, Some("Error::from")),
//!
//! Snippet::function("fn-new", "::new", None, Some("")),
//! Snippet::function("fn-from", "::from", None, Some("")),
//!
//! Snippet::function("macro-vec", "vec!", Some(("[", "]")), Some("")),
//! Snippet::function("macro-map", "map!", Some(("{", "}")), Some("")),
//! ]
//! ),
//! ],
//! License::mit("DrakeN-inc"),
//! );
//!
//! // writing package files to directory "package/":
//! pkg.write_to("package")?;
//!
//! /* OUTPUT DIR STRUCTURE:
//! * package/
//! * - snippets/
//! * - attributes.code-snippets
//! * - blocks.code-snippets
//! * - functions.code-snippets
//! * - operators.code-snippets
//! * - text.code-snippets
//! * - package.json
//! * - README.md
//! * - LICENSE.md
//! */
//!
//! Ok(())
//! }
//! ```
pub mod error;
pub mod tools;
pub mod prelude;
pub mod snippets; pub use snippets::*;
pub mod package; pub use package::*;